mirror of
https://github.com/truenas/charts.git
synced 2024-04-21 15:21:45 +00:00
job and cron pod metadata
This commit is contained in:
@@ -29,6 +29,13 @@ tests:
|
||||
annotations:
|
||||
annotation1: "{{ .Values.annotation1 }}"
|
||||
annotation2: annotation2
|
||||
podSpec:
|
||||
labels:
|
||||
pod-label1: pod-label1
|
||||
pod-label2: "{{ .Values.label2 }}"
|
||||
annotations:
|
||||
pod-annotation1: pod-annotation1
|
||||
pod-annotation2: "{{ .Values.annotation2 }}"
|
||||
asserts:
|
||||
- documentIndex: &cronJobDoc 0
|
||||
isKind:
|
||||
@@ -55,3 +62,61 @@ tests:
|
||||
g_label2: global_label2
|
||||
label1: label1
|
||||
label2: label2
|
||||
- documentIndex: *cronJobDoc
|
||||
equal:
|
||||
path: spec.jobTemplate.spec.template.metadata.labels
|
||||
value:
|
||||
pod.name: release-name-common-test
|
||||
app: common-test-1.0.0
|
||||
release: release-name
|
||||
app.kubernetes.io/instance: RELEASE-NAME
|
||||
app.kubernetes.io/managed-by: Helm
|
||||
app.kubernetes.io/name: common-test
|
||||
app.kubernetes.io/version: v9.9.9
|
||||
helm-revision: 0
|
||||
helm.sh/chart: common-test-1.0.0
|
||||
g_label1: global_label1
|
||||
g_label2: global_label2
|
||||
pod-label1: pod-label1
|
||||
pod-label2: global_label2
|
||||
- documentIndex: *cronJobDoc
|
||||
matchRegex:
|
||||
path: spec.jobTemplate.spec.template.metadata.annotations.rollme
|
||||
pattern: '^[0-9a-zA-Z]{5}$'
|
||||
|
||||
- it: should pass with 2 cronjob created with correct selector labels
|
||||
set:
|
||||
controllers:
|
||||
controller-name:
|
||||
enabled: true
|
||||
primary: true
|
||||
type: CronJob
|
||||
schedule: "*/1 * * * *"
|
||||
podSpec: {}
|
||||
other-controller-name:
|
||||
enabled: true
|
||||
primary: false
|
||||
type: CronJob
|
||||
schedule: "*/1 * * * *"
|
||||
podSpec: {}
|
||||
asserts:
|
||||
- documentIndex: *cronJobDoc
|
||||
isKind:
|
||||
of: CronJob
|
||||
- documentIndex: *cronJobDoc
|
||||
isSubset:
|
||||
path: spec.jobTemplate.spec.template.metadata.labels
|
||||
content:
|
||||
pod.name: release-name-common-test
|
||||
app.kubernetes.io/instance: RELEASE-NAME
|
||||
app.kubernetes.io/name: common-test
|
||||
- documentIndex: &otherCronJobDoc 1
|
||||
isKind:
|
||||
of: CronJob
|
||||
- documentIndex: *otherCronJobDoc
|
||||
isSubset:
|
||||
path: spec.jobTemplate.spec.template.metadata.labels
|
||||
content:
|
||||
pod.name: release-name-common-test-other-controller-name
|
||||
app.kubernetes.io/instance: RELEASE-NAME
|
||||
app.kubernetes.io/name: common-test
|
||||
|
||||
@@ -10,6 +10,7 @@ tests:
|
||||
primary: true
|
||||
type: CronJob
|
||||
schedule: "* * * * *"
|
||||
podSpec: {}
|
||||
asserts:
|
||||
- documentIndex: &cronJobDoc 0
|
||||
isKind:
|
||||
@@ -58,6 +59,7 @@ tests:
|
||||
parallelism: 5
|
||||
ttlSecondsAfterFinished: 100
|
||||
activeDeadlineSeconds: 100
|
||||
podSpec: {}
|
||||
asserts:
|
||||
- documentIndex: *cronJobDoc
|
||||
isSubset:
|
||||
|
||||
@@ -10,6 +10,7 @@ tests:
|
||||
primary: true
|
||||
type: CronJob
|
||||
concurrencyPolicy: not-a-policy
|
||||
podSpec: {}
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
errorMessage: CronJob - Expected <concurrencyPolicy> to be one of [Allow, Forbid, Replace], but got [not-a-policy]
|
||||
@@ -22,6 +23,7 @@ tests:
|
||||
primary: true
|
||||
type: CronJob
|
||||
schedule:
|
||||
podSpec: {}
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
errorMessage: CronJob - Expected non-empty <schedule>
|
||||
@@ -35,6 +37,7 @@ tests:
|
||||
type: CronJob
|
||||
schedule: "* * * * *"
|
||||
completionMode: not-a-mode
|
||||
podSpec: {}
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
errorMessage: Job - Expected <completionMode> to be one of [Indexed, NonIndexed], but got [not-a-mode]
|
||||
|
||||
@@ -28,6 +28,13 @@ tests:
|
||||
annotations:
|
||||
annotation1: "{{ .Values.annotation1 }}"
|
||||
annotation2: annotation2
|
||||
podSpec:
|
||||
labels:
|
||||
pod-label1: pod-label1
|
||||
pod-label2: "{{ .Values.label2 }}"
|
||||
annotations:
|
||||
pod-annotation1: pod-annotation1
|
||||
pod-annotation2: "{{ .Values.annotation2 }}"
|
||||
asserts:
|
||||
- documentIndex: &jobDoc 0
|
||||
isKind:
|
||||
@@ -54,3 +61,59 @@ tests:
|
||||
g_label2: global_label2
|
||||
label1: label1
|
||||
label2: label2
|
||||
- documentIndex: *jobDoc
|
||||
equal:
|
||||
path: spec.template.metadata.labels
|
||||
value:
|
||||
pod.name: release-name-common-test
|
||||
app: common-test-1.0.0
|
||||
release: release-name
|
||||
app.kubernetes.io/instance: RELEASE-NAME
|
||||
app.kubernetes.io/managed-by: Helm
|
||||
app.kubernetes.io/name: common-test
|
||||
app.kubernetes.io/version: v9.9.9
|
||||
helm-revision: 0
|
||||
helm.sh/chart: common-test-1.0.0
|
||||
g_label1: global_label1
|
||||
g_label2: global_label2
|
||||
pod-label1: pod-label1
|
||||
pod-label2: global_label2
|
||||
- documentIndex: *jobDoc
|
||||
matchRegex:
|
||||
path: spec.template.metadata.annotations.rollme
|
||||
pattern: '^[0-9a-zA-Z]{5}$'
|
||||
|
||||
- it: should pass with 2 job created with correct selector labels
|
||||
set:
|
||||
controllers:
|
||||
controller-name:
|
||||
enabled: true
|
||||
primary: true
|
||||
type: Job
|
||||
podSpec: {}
|
||||
other-controller-name:
|
||||
enabled: true
|
||||
primary: false
|
||||
type: Job
|
||||
podSpec: {}
|
||||
asserts:
|
||||
- documentIndex: *jobDoc
|
||||
isKind:
|
||||
of: Job
|
||||
- documentIndex: *jobDoc
|
||||
isSubset:
|
||||
path: spec.template.metadata.labels
|
||||
content:
|
||||
pod.name: release-name-common-test
|
||||
app.kubernetes.io/instance: RELEASE-NAME
|
||||
app.kubernetes.io/name: common-test
|
||||
- documentIndex: &otherJobDoc 1
|
||||
isKind:
|
||||
of: Job
|
||||
- documentIndex: *otherJobDoc
|
||||
isSubset:
|
||||
path: spec.template.metadata.labels
|
||||
content:
|
||||
pod.name: release-name-common-test-other-controller-name
|
||||
app.kubernetes.io/instance: RELEASE-NAME
|
||||
app.kubernetes.io/name: common-test
|
||||
|
||||
@@ -9,6 +9,7 @@ tests:
|
||||
enabled: true
|
||||
primary: true
|
||||
type: Job
|
||||
podSpec: {}
|
||||
asserts:
|
||||
- documentIndex: &jobDoc 0
|
||||
isKind:
|
||||
@@ -39,6 +40,7 @@ tests:
|
||||
parallelism: 5
|
||||
ttlSecondsAfterFinished: 100
|
||||
activeDeadlineSeconds: 100
|
||||
podSpec: {}
|
||||
asserts:
|
||||
- documentIndex: *jobDoc
|
||||
isSubset:
|
||||
|
||||
@@ -10,6 +10,7 @@ tests:
|
||||
primary: true
|
||||
type: Job
|
||||
completionMode: not-a-mode
|
||||
podSpec: {}
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
errorMessage: Job - Expected <completionMode> to be one of [Indexed, NonIndexed], but got [not-a-mode]
|
||||
@@ -23,6 +24,7 @@ tests:
|
||||
type: Job
|
||||
completionMode: Indexed
|
||||
completions:
|
||||
podSpec: {}
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
errorMessage: Job - Expected <completions> to be set when <completionMode> is set to [Indexed]
|
||||
@@ -37,6 +39,7 @@ tests:
|
||||
completionMode: Indexed
|
||||
completions: 5
|
||||
parallelism:
|
||||
podSpec: {}
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
errorMessage: Job - Expected <parallelism> to be set when <completionMode> is set to [Indexed]
|
||||
|
||||
@@ -28,5 +28,23 @@ metadata:
|
||||
{{- end }}
|
||||
spec:
|
||||
{{- include "ix.v1.common.lib.controller.cronjobSpec" (dict "rootCtx" $rootCtx "objectData" $objectData) | nindent 2 }}
|
||||
|
||||
template:
|
||||
metadata:
|
||||
{{- $labels := (mustMerge ($objectData.podSpec.labels | default dict)
|
||||
(include "ix.v1.common.lib.metadata.allLabels" $rootCtx | fromYaml)
|
||||
(include "ix.v1.common.lib.metadata.podLabels" $rootCtx | fromYaml)
|
||||
(include "ix.v1.common.lib.metadata.selectorLabels" (dict "rootCtx" $rootCtx "podName" $objectData.name) | fromYaml)) -}}
|
||||
{{- with (include "ix.v1.common.lib.metadata.render" (dict "rootCtx" $rootCtx "labels" $labels) | trim) }}
|
||||
labels:
|
||||
{{- . | nindent 12 }}
|
||||
{{- end -}}
|
||||
{{- $annotations := (mustMerge ($objectData.podSpec.annotations | default dict)
|
||||
(include "ix.v1.common.lib.metadata.allAnnotations" $rootCtx | fromYaml)
|
||||
(include "ix.v1.common.lib.metadata.podAnnotations" $rootCtx | fromYaml)) -}}
|
||||
{{- with (include "ix.v1.common.lib.metadata.render" (dict "rootCtx" $rootCtx "annotations" $annotations) | trim) }}
|
||||
annotations:
|
||||
{{- . | nindent 12 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
{{/* pod */}}
|
||||
{{- end -}}
|
||||
|
||||
@@ -28,5 +28,23 @@ metadata:
|
||||
{{- end }}
|
||||
spec:
|
||||
{{- include "ix.v1.common.lib.controller.jobSpec" (dict "rootCtx" $rootCtx "objectData" $objectData) | nindent 2 }}
|
||||
|
||||
template:
|
||||
metadata:
|
||||
{{- $labels := (mustMerge ($objectData.podSpec.labels | default dict)
|
||||
(include "ix.v1.common.lib.metadata.allLabels" $rootCtx | fromYaml)
|
||||
(include "ix.v1.common.lib.metadata.podLabels" $rootCtx | fromYaml)
|
||||
(include "ix.v1.common.lib.metadata.selectorLabels" (dict "rootCtx" $rootCtx "podName" $objectData.name) | fromYaml)) -}}
|
||||
{{- with (include "ix.v1.common.lib.metadata.render" (dict "rootCtx" $rootCtx "labels" $labels) | trim) }}
|
||||
labels:
|
||||
{{- . | nindent 8 }}
|
||||
{{- end -}}
|
||||
{{- $annotations := (mustMerge ($objectData.podSpec.annotations | default dict)
|
||||
(include "ix.v1.common.lib.metadata.allAnnotations" $rootCtx | fromYaml)
|
||||
(include "ix.v1.common.lib.metadata.podAnnotations" $rootCtx | fromYaml)) -}}
|
||||
{{- with (include "ix.v1.common.lib.metadata.render" (dict "rootCtx" $rootCtx "annotations" $annotations) | trim) }}
|
||||
annotations:
|
||||
{{- . | nindent 8 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
{{/* pod */}}
|
||||
{{- end -}}
|
||||
|
||||
Reference in New Issue
Block a user