Module: Kontena::Cli::Stacks::Common::StackValuesFromOption::InstanceMethods
- Defined in:
- lib/kontena/cli/stacks/common.rb
Instance Method Summary collapse
-
#dependency_values_from_options(name) ⇒ Object
Transforms a hash dependency_values_from_options(‘foo.bar’ => 1, ‘foo’) => { ‘bar’ => 1 } Used for dependency variable injection.
- #read_values_from_stacks(stackname) ⇒ Object
- #values_from_file ⇒ Object
- #values_from_installed_stacks ⇒ Object
- #values_from_options ⇒ Object
- #values_from_value_options ⇒ Object
Instance Method Details
#dependency_values_from_options(name) ⇒ Object
Transforms a hash dependency_values_from_options(‘foo.bar’ => 1, ‘foo’)
=> { 'bar' => 1 }
Used for dependency variable injection
159 160 161 162 163 164 165 166 167 |
# File 'lib/kontena/cli/stacks/common.rb', line 159 def (name) name_with_dot = name.to_s + '.' .each_with_object({}) do |kv_pair, obj| key = kv_pair.first.to_s value = kv_pair.last next unless key.start_with?(name_with_dot) obj[key.sub(name_with_dot, '')] = value end end |
#read_values_from_stacks(stackname) ⇒ Object
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
# File 'lib/kontena/cli/stacks/common.rb', line 118 def read_values_from_stacks(stackname) result = {} response = client.get("stacks/#{current_grid}/#{stackname}") result.merge!(response['variables']) if response['variables'] if response['children'] response['children'].each do |child_info| result.merge!( read_values_from_stacks(child_info['name']).tap do |child_result| child_result.keys.each do |key| new_key = child_info['name'].dup # foofoo-redis-monitor new_key.sub!("#{stackname}-", '') # monitor new_key.concat ".#{key}" # monitor.foovariable child_result[new_key] = child_result.delete(key) end end ) end end result end |
#values_from_file ⇒ Object
139 140 141 |
# File 'lib/kontena/cli/stacks/common.rb', line 139 def values_from_file @values_from_file ||= {} end |
#values_from_installed_stacks ⇒ Object
147 148 149 |
# File 'lib/kontena/cli/stacks/common.rb', line 147 def values_from_installed_stacks @values_from_installed_stacks ||= {} end |
#values_from_options ⇒ Object
151 152 153 |
# File 'lib/kontena/cli/stacks/common.rb', line 151 def @values_from_options ||= values_from_installed_stacks.merge(values_from_file).merge() end |
#values_from_value_options ⇒ Object
143 144 145 |
# File 'lib/kontena/cli/stacks/common.rb', line 143 def @values_from_value_options ||= {} end |