Class: Kontena::Cli::Apps::YAML::ServiceExtender

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(service_config) ⇒ ServiceExtender

Returns a new instance of ServiceExtender.

Parameters:

  • service_config (Hash)


10
11
12
# File 'lib/kontena/cli/apps/yaml/service_extender.rb', line 10

def initialize(service_config)
  @service_config = service_config
end

Instance Attribute Details

#service_configObject (readonly)

Returns the value of attribute service_config.



7
8
9
# File 'lib/kontena/cli/apps/yaml/service_extender.rb', line 7

def service_config
  @service_config
end

Instance Method Details

#extend(from) ⇒ Hash

Parameters:

  • from (Hash)

Returns:

  • (Hash)


16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/kontena/cli/apps/yaml/service_extender.rb', line 16

def extend(from)
  service_config['environment'] = extend_env_vars(
    from['environment'],
    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'] = {} unless service_config['build']
    service_config['build']['args'] = build_args
  end

  from.merge(service_config)
end