Sha256: f0efa4ec1c1b0d87dd41285a09bab14c7bdb21d8178262dab1135ed59d092c9f

Contents?: true

Size: 1.6 KB

Versions: 4

Compression:

Stored size: 1.6 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: base_labels.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

4 entries across 4 versions & 1 rubygems

Version Path
metatron-0.8.2 lib/metatron/templates/cron_job.rb
metatron-0.8.0 lib/metatron/templates/cron_job.rb
metatron-0.7.0 lib/metatron/templates/cron_job.rb
metatron-0.6.1 lib/metatron/templates/cron_job.rb