module Kontena::Cli::Stacks::Common::StackValuesFromOption
Public Class Methods
included(where)
click to toggle source
Include to add –values-from option to read variable values from a YAML
file and the -v variable=value option that can be used to pass variable values directly from command line
# File lib/kontena/cli/stacks/common.rb, line 94 def self.included(where) where.prepend InstanceMethods where.option '--values-from', '[FILE]', 'Read variable values from a YAML file', multivalued: true do |filename| values_from_file.merge!(::YAML.safe_load(File.read(filename), [], [], true, filename)) filename end where.option '--values-from-stack', '[STACK_NAME]', 'Read variable values from an installed stack', multivalued: true do |stackname| variables = read_values_from_stacks(stackname) Kontena.logger.debug { "Received variables from stack #{stackname} on Master: #{variables.inspect}" } warn "Stack #{stackname} does not have any values for variables" if variables.empty? values_from_installed_stacks.merge!(variables) stackname end where.option '-v', "VARIABLE=VALUE", "Set stack variable values, example: -v domain=example.com. Can be used multiple times.", multivalued: true, attribute_name: :var_option do |var_pair| var_name, var_value = var_pair.split('=', 2) values_from_value_options.merge!(::YAML.safe_load(::YAML.dump(var_name => var_value))) var_pair end end