Class: ConfCtl::Cli::Swpins::Cluster
- Includes:
- Utils
- Defined in:
- lib/confctl/cli/swpins/cluster.rb
Instance Attribute Summary
Attributes inherited from Command
Instance Method Summary collapse
Methods included from Utils
#channel_list, #cluster_name_list, #each_channel, #each_channel_spec, #each_cluster_name, #each_cluster_name_spec, #spec_set_msg, #spec_update_msg
Methods inherited from Command
#ask_action, #ask_confirmation, #ask_confirmation!, #initialize, #require_args!, run, #run_method, #use_color?, #use_pager?
Constructor Details
This class inherits a constructor from ConfCtl::Cli::Command
Instance Method Details
#list ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/confctl/cli/swpins/cluster.rb', line 8 def list rows = [] each_cluster_name_spec(args[0] || '*', args[1] || '*') do |cn, spec| rows << { cluster_name: cn.name, sw: spec.name, channel: spec.channel, type: spec.type, pin: spec.status } end OutputFormatter.print( rows, %i[cluster_name sw channel type pin], layout: :columns ) end |
#set ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/confctl/cli/swpins/cluster.rb', line 28 def set require_args!('cluster-name', 'sw', 'version...', strict: false) cluster_names = [] change_set = ConfCtl::Swpins::ChangeSet.new each_cluster_name_spec(args[0], args[1]) do |cluster_name, spec| if spec.from_channel? puts "Skipping #{spec.name} as it comes from channel #{spec.channel}" else change_set.add(cluster_name, spec) spec_set_msg(cluster_name, spec) { spec.prefetch_set(args[2..]) } cluster_names << cluster_name unless cluster_names.include?(cluster_name) end end cluster_names.each(&:save) return unless opts[:commit] change_set.commit( type: opts[:downgrade] ? :downgrade : :upgrade, changelog: opts[:changelog] ) end |
#update ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/confctl/cli/swpins/cluster.rb', line 53 def update require_args!(optional: %w[cluster-name sw]) cluster_names = [] change_set = ConfCtl::Swpins::ChangeSet.new each_cluster_name_spec(args[0] || '*', args[1] || '*') do |cluster_name, spec| if spec.from_channel? puts "Skipping #{spec.name} as it comes from channel #{spec.channel}" elsif spec.can_update? change_set.add(cluster_name, spec) spec_update_msg(cluster_name, spec) { spec.prefetch_update } cluster_names << cluster_name unless cluster_names.include?(cluster_name) else puts "#{spec.name} not configured for update" end end cluster_names.each(&:save) return unless opts[:commit] change_set.commit( type: opts[:downgrade] ? :downgrade : :upgrade, changelog: opts[:changelog] ) end |