Sha256: a111005e40c2001e0a663bef11980d14ac2634bd163baa8cb0461f16ab48bb78

Contents?: true

Size: 1.62 KB

Versions: 14

Compression:

Stored size: 1.62 KB

Contents

# frozen_string_literal: true

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

      attr_accessor :schedule, :suspend, :concurrency_policy, :starting_deadline_seconds,
                    :successful_jobs_history_limit, :failed_jobs_history_limit,
                    :backoff_limit

      alias backoffLimit backoff_limit
      alias concurrencyPolicy concurrency_policy
      alias startingDeadlineSeconds starting_deadline_seconds
      alias successfulJobsHistoryLimit successful_jobs_history_limit
      alias failedJobsHistoryLimit failed_jobs_history_limit

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

      # rubocop:disable Metrics/AbcSize
      def render
        {
          apiVersion:,
          kind:,
          metadata: {
            labels: { "#{label_namespace}/name": name }.merge(additional_labels),
            name:
          }.merge(formatted_annotations).merge(formatted_namespace),
          spec: {
            schedule:,
            suspend:,
            concurrencyPolicy:,
            startingDeadlineSeconds:,
            successfulJobsHistoryLimit:,
            failedJobsHistoryLimit:,
            jobTemplate: {
              spec: {
                backoffLimit:
              }.merge(pod_template).compact
            }.merge(formatted_tolerations).compact
          }.compact
        }
      end
      # rubocop:enable Metrics/AbcSize
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
metatron-0.6.0 lib/metatron/templates/cron_job.rb
metatron-0.5.0 lib/metatron/templates/cron_job.rb
metatron-0.4.2 lib/metatron/templates/cron_job.rb
metatron-0.4.1 lib/metatron/templates/cron_job.rb
metatron-0.4.0 lib/metatron/templates/cron_job.rb
metatron-0.3.4 lib/metatron/templates/cron_job.rb
metatron-0.3.3 lib/metatron/templates/cron_job.rb
metatron-0.3.2 lib/metatron/templates/cron_job.rb
metatron-0.3.1 lib/metatron/templates/cron_job.rb
metatron-0.3.0 lib/metatron/templates/cron_job.rb
metatron-0.2.8 lib/metatron/templates/cron_job.rb
metatron-0.2.7 lib/metatron/templates/cron_job.rb
metatron-0.2.6 lib/metatron/templates/cron_job.rb
metatron-0.2.5 lib/metatron/templates/cron_job.rb