Class: CronKubernetes::CronJob

Inherits:
Object
  • Object
show all
Defined in:
lib/cron_kubernetes/cron_job.rb

Overview

A single job to run on a given schedule.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(schedule: nil, command: nil, job_manifest: nil, name: nil, identifier: nil) ⇒ CronJob

Returns a new instance of CronJob.



10
11
12
13
14
15
16
# File 'lib/cron_kubernetes/cron_job.rb', line 10

def initialize(schedule: nil, command: nil, job_manifest: nil, name: nil, identifier: nil)
  @schedule     = schedule
  @command      = command
  @job_manifest = job_manifest
  @name         = name
  @identifier   = identifier
end

Instance Attribute Details

#commandObject

Returns the value of attribute command.



8
9
10
# File 'lib/cron_kubernetes/cron_job.rb', line 8

def command
  @command
end

#identifierObject

Returns the value of attribute identifier.



8
9
10
# File 'lib/cron_kubernetes/cron_job.rb', line 8

def identifier
  @identifier
end

#job_manifestObject

Returns the value of attribute job_manifest.



8
9
10
# File 'lib/cron_kubernetes/cron_job.rb', line 8

def job_manifest
  @job_manifest
end

#nameObject

Returns the value of attribute name.



8
9
10
# File 'lib/cron_kubernetes/cron_job.rb', line 8

def name
  @name
end

#scheduleObject

Returns the value of attribute schedule.



8
9
10
# File 'lib/cron_kubernetes/cron_job.rb', line 8

def schedule
  @schedule
end

Instance Method Details

#cron_job_manifestObject

rubocop:disable Metrics/MethodLength



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/cron_kubernetes/cron_job.rb', line 19

def cron_job_manifest
  {
      "apiVersion" => "batch/v1",
      "kind"       => "CronJob",
      "metadata"   => {
          "name"      => "#{identifier}-#{cron_job_name}",
          "namespace" => namespace,
          "labels"    => {"cron-kubernetes-identifier" => identifier}
      },
      "spec"       => {
          "schedule"    => schedule,
          "jobTemplate" => {
              "metadata" => ,
              "spec"     => job_spec
          }
      }
  }
end