Class: Kubes::Compiler::Dsl::Syntax::Job

Inherits:
Resource
  • Object
show all
Defined in:
lib/kubes/compiler/dsl/syntax/job.rb

Instance Attribute Summary

Attributes inherited from Resource

#kind_from_block

Instance Method Summary collapse

Methods inherited from Resource

#default_kind, #default_metadata, #default_result, #default_result_append, #default_top, #field, #top

Methods included from Util::Normalize

#extract_type, #normalize_kind

Instance Method Details

#command_readerObject

Override command instead of default_command since we want to change a String to an Array



213
214
215
# File 'lib/kubes/compiler/dsl/syntax/job.rb', line 213

def command_reader
  @command.is_a?(String) ? @command.split(' ') : @command # else assume Array
end

#default_apiVersionObject



89
90
91
# File 'lib/kubes/compiler/dsl/syntax/job.rb', line 89

def default_apiVersion
  "batch/v1"
end

#default_containerObject



175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
# File 'lib/kubes/compiler/dsl/syntax/job.rb', line 175

def default_container
  {
    args: args,
    command: command,
    env: env,
    envFrom: envFrom,
    image: image,
    imagePullPolicy: imagePullPolicy,
    lifecycle: lifecycle,
    livenessProbe: livenessProbe,
    name: containerName || name,
    ports: ports,
    readinessProbe: readinessProbe,
    resources: resources,
    securityContext: securityContext,
    startupProbe: startupProbe,
    stdin: stdin,
    stdinOnce: stdinOnce,
    terminationMessagePath: terminationMessagePath,
    terminationMessagePolicy: terminationMessagePolicy,
    tty: tty,
    volumeDevices: volumeDevices,
    volumeMounts: volumeMounts,
    workingDir: workingDir,
  }
end

#default_containersObject



160
161
162
# File 'lib/kubes/compiler/dsl/syntax/job.rb', line 160

def default_containers
  [container, sidecar].compact
end

#default_matchLabelsObject



106
107
108
# File 'lib/kubes/compiler/dsl/syntax/job.rb', line 106

def default_matchLabels
  labels
end

#default_portsObject



202
203
204
205
206
207
208
209
210
# File 'lib/kubes/compiler/dsl/syntax/job.rb', line 202

def default_ports
  [
    containerPort: containerPort,
    hostIP: hostIP,
    hostPort: hostPort,
    name: portName,
    protocol: protocol,
  ]
end

#default_sidecarObject



164
165
166
167
168
169
# File 'lib/kubes/compiler/dsl/syntax/job.rb', line 164

def default_sidecar
  {
    name:  sidecar_name,
    image: sidecar_image,
  }
end

#default_sidecar_nameObject



171
172
173
# File 'lib/kubes/compiler/dsl/syntax/job.rb', line 171

def default_sidecar_name
  "sidecar" if sidecar_image # othewise will create invalid sidecar field w/o image
end

#default_specObject



93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/kubes/compiler/dsl/syntax/job.rb', line 93

def default_spec
  {
    activeDeadlineSeconds: activeDeadlineSeconds,
    backoffLimit: backoffLimit,
    completions: completions,
    manualSelector: manualSelector,
    parallelism: parallelism,
    selector: selector,
    template: template,
    ttlSecondsAfterFinished:  ttlSecondsAfterFinished,
  }
end

#default_templateObject



110
111
112
113
114
115
# File 'lib/kubes/compiler/dsl/syntax/job.rb', line 110

def default_template
  {
    metadata: ,
    spec: templateSpec,
  }
end

#default_templateMetadataObject



156
157
158
# File 'lib/kubes/compiler/dsl/syntax/job.rb', line 156

def 
  { labels: labels }
end

#default_templateSpecObject



117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
# File 'lib/kubes/compiler/dsl/syntax/job.rb', line 117

def default_templateSpec
  {
    activeDeadlineSeconds: activeDeadlineSeconds,
    affinity: affinity,
    automountServiceAccountToken: automountServiceAccountToken,
    containers: containers,
    dnsConfig: dnsConfig,
    dnsPolicy: dnsPolicy,
    enableServiceLinks: enableServiceLinks,
    ephemeralContainers: ephemeralContainers,
    hostAliases: hostAliases,
    hostIPC: hostIPC,
    hostNetwork: hostNetwork,
    hostPID: hostPID,
    hostname: hostname,
    imagePullSecrets: imagePullSecrets,
    initContainers: initContainers,
    nodeName: nodeName,
    nodeSelector: nodeSelector,
    overhead: overhead,
    preemptionPolicy: preemptionPolicy,
    priority: priority,
    priorityClassName: priorityClassName,
    readinessGates: readinessGates,
    restartPolicy: restartPolicy,
    runtimeClassName: runtimeClassName,
    schedulerName: schedulerName,
    securityContext: securityContext,
    serviceAccount: serviceAccount,
    serviceAccountName: serviceAccountName,
    shareProcessNamespace: shareProcessNamespace,
    subdomain: subdomain,
    terminationGracePeriodSeconds: terminationGracePeriodSeconds,
    tolerations: tolerations,
    topologySpreadConstraints: topologySpreadConstraints,
    volumes: volumes,
  }
end