Module: Dapp::Deployment::Mod::Jobs

Included in:
App, Config::Directive::App, Deployment
Defined in:
lib/dapp/deployment/mod/jobs.rb

Instance Method Summary collapse

Instance Method Details

#to_kube_default_job_pods(directive, repo, image_version) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/dapp/deployment/mod/jobs.rb', line 11

def to_kube_default_job_pods(directive, repo, image_version)
  return {} if (directive_config = config.public_send("_#{directive}")).empty?
  {}.tap do |hash|
    hash[name(directive)] = {}.tap do |pod|
      pod['metadata'] = {}.tap do ||
        ['name']   = name(directive)
        ['labels'] = kube.labels
      end
      pod['spec'] = {}.tap do |spec|
        spec['restartPolicy'] = 'Never'
        spec['containers'] = [].tap do |containers|
          containers << {}.tap do |container|
            container['imagePullPolicy'] = 'Always'
            container['image']           = [repo, [directive_config._dimg || config._dimg, image_version].compact.join('-')].join(':')
            container['name']            = name(directive)
            container['command']         = directive_config._run unless directive_config._run.empty?
            container['env']             = environments unless environments.empty?
          end
        end
      end
    end
  end
end