Sha256: b40911dbc1ddb72e1c5a3b53f43e3b7687af0151b990b1343108117de33ad39f

Contents?: true

Size: 1.74 KB

Versions: 5

Compression:

Stored size: 1.74 KB

Contents

require 'aws'
require 'opsworks/stack'

module OpsWorks
  module CLI
    module Subcommands
      module Config
        # rubocop:disable MethodLength
        # rubocop:disable CyclomaticComplexity
        def self.included(thor)
          thor.class_eval do
            desc 'config:get KEY [--stack STACK]', 'Get a single config value'
            option :stack, type: :array
            define_method 'config:get' do |key|
              fetch_credentials unless env_credentials?
              table = parse_stacks(options).map do |stack|
                value = stack.custom_json_at(key)
                [stack.name, value || '(null)']
              end
              table.compact!
              table.sort! { |x, y| x.first <=> y.first }
              print_table table
            end

            desc 'config:set KEY VALUE [--stack STACK]', 'Set a config value'
            option :stack, type: :array
            define_method 'config:set' do |key, value|
              fetch_credentials unless env_credentials?
              parse_stacks(options).each do |stack|
                say "Updating #{stack.name}..."
                stack.set_custom_json_at(key, typecast_string_argument(value))
              end
            end

            desc 'config:unset KEY [--stack STACK]', 'Unset a config value'
            option :stack, type: :array
            define_method 'config:unset' do |key|
              fetch_credentials unless env_credentials?
              parse_stacks(options).map do |stack|
                say "Updating #{stack.name}..."
                stack.set_custom_json_at(key, nil)
              end
            end
          end
        end
        # rubocop:enable CyclomaticComplexity
        # rubocop:enable MethodLength
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
opsworks-cli-0.4.5 lib/opsworks/cli/subcommands/config.rb
opsworks-cli-0.4.4 lib/opsworks/cli/subcommands/config.rb
opsworks-cli-0.4.3 lib/opsworks/cli/subcommands/config.rb
opsworks-cli-0.4.2 lib/opsworks/cli/subcommands/config.rb
opsworks-cli-0.4.1 lib/opsworks/cli/subcommands/config.rb