Class: Kontena::Cli::Stacks::YAML::ServiceExtender

Inherits:
Object
  • Object
show all
Includes:
Util
Defined in:
lib/kontena/cli/stacks/yaml/service_extender.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Util

included, #longest_string_in_array, #safe_dig, #seconds_to_human, stringify_keys, stringify_keys!, symbolize_keys, symbolize_keys!, #time_ago, #time_until, which

Constructor Details

#initialize(service_config) ⇒ ServiceExtender

Returns a new instance of ServiceExtender.

Parameters:

  • service_config (Hash)


8
9
10
# File 'lib/kontena/cli/stacks/yaml/service_extender.rb', line 8

def initialize(service_config)
  @service_config = service_config
end

Instance Attribute Details

#service_configObject (readonly)

Returns the value of attribute service_config.



5
6
7
# File 'lib/kontena/cli/stacks/yaml/service_extender.rb', line 5

def service_config
  @service_config
end

Instance Method Details

#extend_from(from) ⇒ Hash

Parameters:

  • from (Hash)

Returns:

  • (Hash)


14
15
16
17
18
19
20
21
22
23
# File 'lib/kontena/cli/stacks/yaml/service_extender.rb', line 14

def extend_from(from)
  service_config['environment'] = extend_env_vars(from['env'], service_config['environment'])
  service_config['secrets']     = extend_secrets( from['secrets'], service_config['secrets'])
  build_args                    = extend_build_args(safe_dig(from, 'build', 'args'), safe_dig(service_config, 'build', 'args'))
  unless build_args.empty?
    service_config['build'] ||= {}
    service_config['build']['args'] = build_args
  end
  from.merge(service_config)
end