Class: KubeQueue::ManifestBuilder
- Inherits:
-
Object
- Object
- KubeQueue::ManifestBuilder
- Defined in:
- lib/kube_queue/manifest_builder.rb
Instance Attribute Summary collapse
-
#job ⇒ Object
readonly
Returns the value of attribute job.
Instance Method Summary collapse
- #build_cron_job(cron) ⇒ Object
- #build_job ⇒ Object
-
#initialize(job) ⇒ ManifestBuilder
constructor
A new instance of ManifestBuilder.
- #payload ⇒ Object
- #spec ⇒ Object
Constructor Details
#initialize(job) ⇒ ManifestBuilder
Returns a new instance of ManifestBuilder.
8 9 10 |
# File 'lib/kube_queue/manifest_builder.rb', line 8 def initialize(job) @job = job end |
Instance Attribute Details
#job ⇒ Object (readonly)
Returns the value of attribute job.
6 7 8 |
# File 'lib/kube_queue/manifest_builder.rb', line 6 def job @job end |
Instance Method Details
#build_cron_job(cron) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/kube_queue/manifest_builder.rb', line 24 def build_cron_job(cron) template = YAML.safe_load(ERB.new(job.read_template, nil, "-").result(binding)) { apiVersion: "batch/v1beta1", kind: "CronJob", metadata: template["metadata"], spec: { startingDeadlineSeconds: job.job_spec.starting_deadline_seconds, concurrentPolicy: job.job_spec.concurrent_policy, schedule: cron, jobTemplate: { spec: template["spec"] } } } end |
#build_job ⇒ Object
20 21 22 |
# File 'lib/kube_queue/manifest_builder.rb', line 20 def build_job YAML.safe_load(ERB.new(job.read_template, nil, "-").result(binding)) end |
#payload ⇒ Object
16 17 18 |
# File 'lib/kube_queue/manifest_builder.rb', line 16 def payload JSON.generate(job.serialized_payload, quirks_mode: true) end |
#spec ⇒ Object
12 13 14 |
# File 'lib/kube_queue/manifest_builder.rb', line 12 def spec job.job_spec end |