Class: KubeQueue::JobSpecification

Inherits:
Object
  • Object
show all
Defined in:
lib/kube_queue/job_specification.rb

Defined Under Namespace

Classes: MissingParameterError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(job_class) ⇒ JobSpecification

Returns a new instance of JobSpecification.



16
17
18
# File 'lib/kube_queue/job_specification.rb', line 16

def initialize(job_class)
  @job_class = job_class
end

Instance Attribute Details

#active_deadline_secondsObject

Returns the value of attribute active_deadline_seconds.



11
12
13
# File 'lib/kube_queue/job_specification.rb', line 11

def active_deadline_seconds
  @active_deadline_seconds
end

#backoff_limitObject

Returns the value of attribute backoff_limit.



11
12
13
# File 'lib/kube_queue/job_specification.rb', line 11

def backoff_limit
  @backoff_limit
end

#commandObject



40
41
42
# File 'lib/kube_queue/job_specification.rb', line 40

def command
  @command || ['bundle', 'exec', 'kube_queue', 'runner', job_class.name]
end

#container_nameObject



36
37
38
# File 'lib/kube_queue/job_specification.rb', line 36

def container_name
  @container_name || worker_name
end

#imageObject



24
25
26
# File 'lib/kube_queue/job_specification.rb', line 24

def image
  @image || raise_not_found_required_parameter('image')
end

#job_classObject (readonly)

Returns the value of attribute job_class.



9
10
11
# File 'lib/kube_queue/job_specification.rb', line 9

def job_class
  @job_class
end

#job_labelsObject



48
49
50
# File 'lib/kube_queue/job_specification.rb', line 48

def job_labels
  @job_labels || {}
end

#nameObject

Returns the value of attribute name.



11
12
13
# File 'lib/kube_queue/job_specification.rb', line 11

def name
  @name
end

#namespaceObject



28
29
30
# File 'lib/kube_queue/job_specification.rb', line 28

def namespace
  @namespace || 'default'
end

#payloadObject

Returns the value of attribute payload.



11
12
13
# File 'lib/kube_queue/job_specification.rb', line 11

def payload
  @payload
end

#pod_labelsObject



52
53
54
# File 'lib/kube_queue/job_specification.rb', line 52

def pod_labels
  @pod_labels || {}
end

#restart_policyObject



44
45
46
# File 'lib/kube_queue/job_specification.rb', line 44

def restart_policy
  @restart_policy || 'Never'
end

#worker_nameObject



32
33
34
# File 'lib/kube_queue/job_specification.rb', line 32

def worker_name
  @worker_name || raise_not_found_required_parameter('worker_name')
end

Instance Method Details

#envObject



56
57
58
# File 'lib/kube_queue/job_specification.rb', line 56

def env
  KubeQueue.default_env.merge(@env || {})
end

#job_name(job_id) ⇒ Object



20
21
22
# File 'lib/kube_queue/job_specification.rb', line 20

def job_name(job_id)
  "#{worker_name}-#{job_id}"
end

#raise_not_found_required_parameter(field) ⇒ Object



60
61
62
# File 'lib/kube_queue/job_specification.rb', line 60

def raise_not_found_required_parameter(field)
  raise MissingParameterError, "#{field} is required"
end