Sha256: d16b329fe9524d65afc557655203d34ed1aeb3bdf6a5997a686863bfc124a49a

Contents?: true

Size: 1.29 KB

Versions: 2

Compression:

Stored size: 1.29 KB

Contents

# frozen_string_literal: true

module Metatron
  module Templates
    # Template for basic Job k8s resource
    class Job < Template
      include Concerns::Annotated
      include Concerns::PodProducer
      include Concerns::Namespaced

      attr_accessor :backoff_limit, :completions, :parallelism, :restart_policy,
                    :pod_failure_policy, :active_deadline_seconds, :ttl_seconds_after_finished,
                    :suspend

      alias activeDeadlineSeconds active_deadline_seconds
      alias backoffLimit backoff_limit
      alias podFailurePolicy pod_failure_policy
      alias restartPolicy restart_policy
      alias ttlSecondsAfterFinished ttl_seconds_after_finished

      def initialize(name)
        super
        @api_version = "batch/v1"
      end

      def render
        {
          apiVersion:,
          kind:,
          metadata: {
            labels: base_labels.merge(additional_labels),
            name:
          }.merge(formatted_annotations).merge(formatted_namespace),
          spec: {
            suspend:,
            backoffLimit:,
            activeDeadlineSeconds:,
            completions:,
            parallelism:,
            podFailurePolicy:,
            ttlSecondsAfterFinished:
          }.merge(pod_template).compact
        }
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
metatron-0.8.2 lib/metatron/templates/job.rb
metatron-0.8.0 lib/metatron/templates/job.rb