Sha256: 4c5b1db35a292ee108ab69acb024c44e53102b9b3e3f53073bfb842cd50c6704
Contents?: true
Size: 857 Bytes
Versions: 13
Compression:
Stored size: 857 Bytes
Contents
class Kubes::Kubectl module Ordering def sorted_files sorted = files.sort_by do |file| # .kubes/output/web/service.yaml words = file.split('/') role, kind = words[2], words[3] # web, deployment kind = kind.sub('.yaml','').underscore.camelize if kind kind_i = index_for(:kinds, kind) role_i = index_for(:roles, role) "#{role_i}/#{kind_i}" end @name == "delete" ? sorted.reverse : sorted end # type: kinds or roles # value: Examples: kind: deployment, role: web def index_for(type, value) order = Kubes.config.kubectl.order.send(type) # kinds or roles index = order.index(value.to_s) || 999 i = index.to_s.rjust(3, "0") # pad with 0 "#{i}-#{value}" # append name so that terms with same index get order alphabetically end end end
Version data entries
13 entries across 13 versions & 1 rubygems