Class: Metatron::Templates::CronJob

Inherits:
Metatron::Template show all
Includes:
Metatron::Templates::Concerns::Annotated, Metatron::Templates::Concerns::Namespaced, Metatron::Templates::Concerns::PodProducer
Defined in:
lib/metatron/templates/cron_job.rb

Overview

Template for basic CronJob k8s resource

Instance Attribute Summary collapse

Attributes inherited from Metatron::Template

#additional_labels, #api_version, #kind, #label_namespace, #name

Instance Method Summary collapse

Methods included from Metatron::Templates::Concerns::Namespaced

#formatted_namespace, included, #namespaced_initialize

Methods included from Metatron::Templates::Concerns::PodProducer

#formatted_affinity, #formatted_containers, #formatted_image_pull_secrets, #formatted_init_containers, #formatted_node_selector, #formatted_pod_annotations, #formatted_security_context, #formatted_tolerations, #formatted_volumes, included, #pod_metadata, #pod_producer_initialize, #pod_spec, #pod_template, #volume_claim_templates

Methods included from Metatron::Templates::Concerns::Annotated

#annotated_initialize, #formatted_annotations, included

Methods inherited from Metatron::Template

initializer, initializers, metatron_template_class?, nearest_metatron_ancestor

Constructor Details

#initialize(name, schedule = "* * * * *") ⇒ CronJob

Returns a new instance of CronJob.



21
22
23
24
25
# File 'lib/metatron/templates/cron_job.rb', line 21

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

Instance Attribute Details

#backoff_limitObject Also known as: backoffLimit

Returns the value of attribute backoff_limit.



11
12
13
# File 'lib/metatron/templates/cron_job.rb', line 11

def backoff_limit
  @backoff_limit
end

#concurrency_policyObject Also known as: concurrencyPolicy

Returns the value of attribute concurrency_policy.



11
12
13
# File 'lib/metatron/templates/cron_job.rb', line 11

def concurrency_policy
  @concurrency_policy
end

#failed_jobs_history_limitObject Also known as: failedJobsHistoryLimit

Returns the value of attribute failed_jobs_history_limit.



11
12
13
# File 'lib/metatron/templates/cron_job.rb', line 11

def failed_jobs_history_limit
  @failed_jobs_history_limit
end

#scheduleObject

Returns the value of attribute schedule.



11
12
13
# File 'lib/metatron/templates/cron_job.rb', line 11

def schedule
  @schedule
end

#starting_deadline_secondsObject Also known as: startingDeadlineSeconds

Returns the value of attribute starting_deadline_seconds.



11
12
13
# File 'lib/metatron/templates/cron_job.rb', line 11

def starting_deadline_seconds
  @starting_deadline_seconds
end

#successful_jobs_history_limitObject Also known as: successfulJobsHistoryLimit

Returns the value of attribute successful_jobs_history_limit.



11
12
13
# File 'lib/metatron/templates/cron_job.rb', line 11

def successful_jobs_history_limit
  @successful_jobs_history_limit
end

#suspendObject

Returns the value of attribute suspend.



11
12
13
# File 'lib/metatron/templates/cron_job.rb', line 11

def suspend
  @suspend
end

Instance Method Details

#renderObject

rubocop:disable Metrics/AbcSize



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/metatron/templates/cron_job.rb', line 28

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