Sha256: ee08a543410fcde120f0c84a4f8f016eb9b4b762fe06a759842cda993b1f117a

Contents?: true

Size: 1.94 KB

Versions: 7

Compression:

Stored size: 1.94 KB

Contents

module Pfab
  module Templates
    class Job < Base
      def write_to(f)
        f << YAML.dump(job.deep_stringify_keys)
      end

      def application_type
        "job"
      end

      def job
        {
          apiVersion: "batch/v1",
          kind: "Job",
          metadata: {
            name: "job-#{@data['deployed_name']}-#{@data['sha']}",
            namespace: get_namespace,
            labels: {
              application: @data['application'],
              "deployed-name" => @data['deployed_name'],
              "application-type" => application_type,
              "deploy-id" => deploy_id,
              "tags.datadoghq.com/env": @data['env'],
              "tags.datadoghq.com/service": @data['deployed_name'],
              "tags.datadoghq.com/version":"#{@data['sha']}"
            }
          },
          spec: {
            template: {
              metadata: {
                name: "#{@data['deployed_name']}-#{@data['sha']}",
                namespace: get_namespace,
                labels: {
                  application: @data['application'],
                  "deployed-name" => @data['deployed_name'],
                  "application-type" => "job",
                  "tags.datadoghq.com/env": @data['env'],
                  "tags.datadoghq.com/service": @data['deployed_name'],
                  "tags.datadoghq.com/version": "#{@data['sha']}"
                },
              },
              spec: {
                serviceAccountName: get('serviceAccountName'),
                containers: [
                  {
                    image: image_name,
                    name: @data['deployed_name'],
                    command: app_vars["command"].split(" "),
                    env: env_vars,
                    resources: resources,
                  },
                ],
                restartPolicy: "Never",
              }.compact,
            },
            backoffLimit: 0,
          },
        }
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
pfab-0.37.0 lib/pfab/templates/job.rb
pfab-0.36.0 lib/pfab/templates/job.rb
pfab-0.35.0 lib/pfab/templates/job.rb
pfab-0.34.0 lib/pfab/templates/job.rb
pfab-0.32.0 lib/pfab/templates/job.rb
pfab-0.31.0 lib/pfab/templates/job.rb
pfab-0.30.0 lib/pfab/templates/job.rb