Class: ConfCtl::Cli::Swpins::Core
- Includes:
- Utils
- Defined in:
- lib/confctl/cli/swpins/core.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 27 28 29 |
# File 'lib/confctl/cli/swpins/core.rb', line 8 def list core = ConfCtl::Swpins::Core.get rows = [] core.specs.each do |name, spec| next if args[0] && !ConfCtl::Pattern.match(args[0], name) rows << { sw: spec.name, channel: spec.channel, type: spec.type, pin: spec.status } end OutputFormatter.print( rows, %i[sw channel type pin], layout: :columns ) end |
#set ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/confctl/cli/swpins/core.rb', line 31 def set require_args!('sw', 'version...', strict: false) core = ConfCtl::Swpins::Core.get change_set = ConfCtl::Swpins::ChangeSet.new core.specs.each_value do |spec| if spec.from_channel? puts "Skipping #{spec.name} as it comes from channel #{spec.channel}" else change_set.add(core, spec) spec_set_msg(core, spec) { spec.prefetch_set(args[1..]) } end end core.save core.pre_evaluate return unless opts[:commit] change_set.commit( type: opts[:downgrade] ? :downgrade : :upgrade, changelog: opts[:changelog] ) end |
#update ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/confctl/cli/swpins/core.rb', line 57 def update require_args!(optional: %w[sw]) core = ConfCtl::Swpins::Core.get change_set = ConfCtl::Swpins::ChangeSet.new core.specs.each do |name, spec| next if args[0] && !ConfCtl::Pattern.match(args[0], name) if spec.from_channel? puts "Skipping #{spec.name} as it comes from channel #{spec.channel}" elsif spec.can_update? change_set.add(core, spec) spec_update_msg(core, spec) { spec.prefetch_update } else puts "#{spec.name} not configured for update" end end core.save core.pre_evaluate return unless opts[:commit] change_set.commit( type: opts[:downgrade] ? :downgrade : :upgrade, changelog: opts[:changelog] ) end |