mirror of
https://github.com/truecharts/library-charts.git
synced 2026-07-04 18:11:22 -03:00
updates
This commit is contained in:
25
library/common-test/ci/extra-containers-values.yaml
Normal file
25
library/common-test/ci/extra-containers-values.yaml
Normal file
@@ -0,0 +1,25 @@
|
||||
image:
|
||||
repository: traefik/whoami
|
||||
pullPolicy: IfNotPresent
|
||||
tag: latest
|
||||
|
||||
service:
|
||||
main:
|
||||
ports:
|
||||
main:
|
||||
protocol: HTTP
|
||||
port: 8080
|
||||
|
||||
args:
|
||||
- --port
|
||||
- "8080"
|
||||
|
||||
# TODO: Add extra containers
|
||||
|
||||
probes:
|
||||
liveness:
|
||||
enabled: true
|
||||
readiness:
|
||||
enabled: true
|
||||
startup:
|
||||
enabled: true
|
||||
@@ -69,7 +69,7 @@ tests:
|
||||
type: not_valid_controller
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
errorMessage: Not a valid controller.type (not_valid_controller). Valid options are Deployment, DaemonSet, StatefulSet
|
||||
errorMessage: Not a valid controller.type (not_valid_controller). Valid options are Deployment, DaemonSet, StatefulSet, Job
|
||||
|
||||
- it: should fail with wrong strategy
|
||||
set:
|
||||
|
||||
@@ -76,6 +76,36 @@ tests:
|
||||
image: some-repo-additional2:some-tag-additional2
|
||||
imagePullPolicy: IfNotPresent
|
||||
|
||||
- it: should pass with enabled false from tpl defined in additional container
|
||||
documentIndex: *deploymentDoc
|
||||
set:
|
||||
flag: false
|
||||
additionalContainers:
|
||||
some-name:
|
||||
enabled: "{{ .Values.flag }}"
|
||||
tty: true
|
||||
stdin: true
|
||||
asserts:
|
||||
- isNotNull:
|
||||
path: spec.template.spec.containers[0]
|
||||
- isNull:
|
||||
path: spec.template.spec.containers[1]
|
||||
|
||||
- it: should pass with enabled true from tpl defined in additional container
|
||||
documentIndex: *deploymentDoc
|
||||
set:
|
||||
flag: true
|
||||
additionalContainers:
|
||||
some-name:
|
||||
enabled: "{{ .Values.flag }}"
|
||||
tty: true
|
||||
stdin: true
|
||||
asserts:
|
||||
- isNotNull:
|
||||
path: spec.template.spec.containers[0]
|
||||
- isNotNull:
|
||||
path: spec.template.spec.containers[1]
|
||||
|
||||
- it: should pass with tty and stdin defined in additional container
|
||||
documentIndex: *deploymentDoc
|
||||
set:
|
||||
|
||||
@@ -95,6 +95,36 @@ tests:
|
||||
tty: true
|
||||
stdin: true
|
||||
|
||||
- it: should pass with enabled false from tpl defined in init container
|
||||
documentIndex: *deploymentDoc
|
||||
set:
|
||||
flag: false
|
||||
initContainers:
|
||||
some-name:
|
||||
enabled: "{{ .Values.flag }}"
|
||||
tty: true
|
||||
stdin: true
|
||||
asserts:
|
||||
- isNotNull:
|
||||
path: spec.template.spec.containers[0]
|
||||
- isNull:
|
||||
path: spec.template.spec.initContainers
|
||||
|
||||
- it: should pass with enabled true from tpl defined in init container
|
||||
documentIndex: *deploymentDoc
|
||||
set:
|
||||
flag: true
|
||||
initContainers:
|
||||
some-name:
|
||||
enabled: "{{ .Values.flag }}"
|
||||
tty: true
|
||||
stdin: true
|
||||
asserts:
|
||||
- isNotNull:
|
||||
path: spec.template.spec.containers[0]
|
||||
- isNotNull:
|
||||
path: spec.template.spec.initContainers
|
||||
|
||||
- it: should pass with command and args defined in init container
|
||||
documentIndex: *deploymentDoc
|
||||
set:
|
||||
|
||||
@@ -78,6 +78,36 @@ tests:
|
||||
image: some-repo-init2:some-tag-init2
|
||||
imagePullPolicy: IfNotPresent
|
||||
|
||||
- it: should pass with enabled false from tpl defined in init container
|
||||
documentIndex: *deploymentDoc
|
||||
set:
|
||||
flag: false
|
||||
initContainers:
|
||||
some-name:
|
||||
enabled: "{{ .Values.flag }}"
|
||||
tty: true
|
||||
stdin: true
|
||||
asserts:
|
||||
- isNotNull:
|
||||
path: spec.template.spec.containers[0]
|
||||
- isNull:
|
||||
path: spec.template.spec.initContainers
|
||||
|
||||
- it: should pass with enabled true from tpl defined in init container
|
||||
documentIndex: *deploymentDoc
|
||||
set:
|
||||
flag: true
|
||||
initContainers:
|
||||
some-name:
|
||||
enabled: "{{ .Values.flag }}"
|
||||
tty: true
|
||||
stdin: true
|
||||
asserts:
|
||||
- isNotNull:
|
||||
path: spec.template.spec.containers[0]
|
||||
- isNotNull:
|
||||
path: spec.template.spec.initContainers
|
||||
|
||||
- it: should pass with tty and stdin defined in init container
|
||||
documentIndex: *deploymentDoc
|
||||
set:
|
||||
|
||||
@@ -90,6 +90,36 @@ tests:
|
||||
image: some-repo-init:some-tag-init
|
||||
imagePullPolicy: Never
|
||||
|
||||
- it: should pass with enabled false from tpl defined in install container
|
||||
documentIndex: *deploymentDoc
|
||||
set:
|
||||
flag: false
|
||||
installContainers:
|
||||
some-name:
|
||||
enabled: "{{ .Values.flag }}"
|
||||
tty: true
|
||||
stdin: true
|
||||
asserts:
|
||||
- isNotNull:
|
||||
path: spec.template.spec.containers[0]
|
||||
- isNull:
|
||||
path: spec.template.spec.initContainers
|
||||
|
||||
- it: should pass with enabled true from tpl defined in install container
|
||||
documentIndex: *deploymentDoc
|
||||
set:
|
||||
flag: true
|
||||
installContainers:
|
||||
some-name:
|
||||
enabled: "{{ .Values.flag }}"
|
||||
tty: true
|
||||
stdin: true
|
||||
asserts:
|
||||
- isNotNull:
|
||||
path: spec.template.spec.containers[0]
|
||||
- isNotNull:
|
||||
path: spec.template.spec.initContainers
|
||||
|
||||
- it: should pass with tty and stdin defined in install container
|
||||
documentIndex: *deploymentDoc
|
||||
set:
|
||||
|
||||
@@ -76,6 +76,36 @@ tests:
|
||||
image: some-repo-system2:some-tag-system2
|
||||
imagePullPolicy: IfNotPresent
|
||||
|
||||
- it: should pass with enabled false from tpl defined in system container
|
||||
documentIndex: *deploymentDoc
|
||||
set:
|
||||
flag: false
|
||||
systemContainers:
|
||||
some-name:
|
||||
enabled: "{{ .Values.flag }}"
|
||||
tty: true
|
||||
stdin: true
|
||||
asserts:
|
||||
- isNotNull:
|
||||
path: spec.template.spec.containers[0]
|
||||
- isNull:
|
||||
path: spec.template.spec.initContainers
|
||||
|
||||
- it: should pass with enabled true from tpl defined in system container
|
||||
documentIndex: *deploymentDoc
|
||||
set:
|
||||
flag: true
|
||||
systemContainers:
|
||||
some-name:
|
||||
enabled: "{{ .Values.flag }}"
|
||||
tty: true
|
||||
stdin: true
|
||||
asserts:
|
||||
- isNotNull:
|
||||
path: spec.template.spec.containers[0]
|
||||
- isNotNull:
|
||||
path: spec.template.spec.initContainers
|
||||
|
||||
- it: should pass with tty and stdin defined in system container
|
||||
documentIndex: *deploymentDoc
|
||||
set:
|
||||
|
||||
@@ -92,6 +92,36 @@ tests:
|
||||
image: some-repo-init:some-tag-init
|
||||
imagePullPolicy: Never
|
||||
|
||||
- it: should pass with enabled false from tpl defined in upgrade container
|
||||
documentIndex: *deploymentDoc
|
||||
set:
|
||||
flag: false
|
||||
upgradeContainers:
|
||||
some-name:
|
||||
enabled: "{{ .Values.flag }}"
|
||||
tty: true
|
||||
stdin: true
|
||||
asserts:
|
||||
- isNotNull:
|
||||
path: spec.template.spec.containers[0]
|
||||
- isNull:
|
||||
path: spec.template.spec.initContainers
|
||||
|
||||
- it: should pass with enabled true from tpl defined in upgrade container
|
||||
documentIndex: *deploymentDoc
|
||||
set:
|
||||
flag: true
|
||||
upgradeContainers:
|
||||
some-name:
|
||||
enabled: "{{ .Values.flag }}"
|
||||
tty: true
|
||||
stdin: true
|
||||
asserts:
|
||||
- isNotNull:
|
||||
path: spec.template.spec.containers[0]
|
||||
- isNotNull:
|
||||
path: spec.template.spec.initContainers
|
||||
|
||||
- it: should pass with tty and stdin defined in upgrade container
|
||||
documentIndex: *deploymentDoc
|
||||
set:
|
||||
|
||||
@@ -474,6 +474,3 @@ tests:
|
||||
backoffLimit: 3
|
||||
activeDeadlineSeconds: 120
|
||||
ttlSecondsAfterFinished: 150
|
||||
|
||||
# TODO: add basic test to make sure jobTemplate spec (mostly containers part) is actually rendered
|
||||
# Most of the jobTemplate spec will be tested on another file
|
||||
|
||||
@@ -125,6 +125,3 @@ tests:
|
||||
a2: val2
|
||||
annotation1: val3
|
||||
annotation2: val4
|
||||
|
||||
# TODO: add basic test to make sure jobTemplate spec (mostly containers part) is actually rendered
|
||||
# Most of the jobTemplate spec will be tested on another file
|
||||
|
||||
@@ -3,3 +3,10 @@ service:
|
||||
ports:
|
||||
main:
|
||||
port: 65535
|
||||
|
||||
# controller:
|
||||
# type: Job
|
||||
|
||||
# cron:
|
||||
# enabled: true
|
||||
# schedule: "* * * * *"
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
{{- if not $item.noMount -}}
|
||||
{{- include "ix.v1.common.container.volumeMount" (dict "root" $root
|
||||
"item" $item
|
||||
"name" $name) | nindent 0 -}}
|
||||
"name" $name) | indent 0 -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
@@ -20,7 +20,7 @@
|
||||
{{- range $index, $vct := $root.Values.volumeClaimTemplates -}}
|
||||
{{- include "ix.v1.common.container.volumeMount" (dict "root" $root
|
||||
"item" $vct
|
||||
"name" (toString $index)) | nindent 0 -}}
|
||||
"name" (toString $index)) | indent 0 -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- else if not $isMainContainer -}}
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
{{- $enabled := true -}} {{/* Default to enable */}}
|
||||
|
||||
{{- if hasKey $container "enabled" -}} {{/* If has enabled key */}}
|
||||
{{- $flag := (tpl $container.enabled $root) -}}
|
||||
{{- $flag := (tpl (toString $container.enabled) $root) -}}
|
||||
{{- if eq "false" $flag -}} {{/* And its kind of bool */}}
|
||||
{{- $enabled = false -}} {{/* Disable the container */}}
|
||||
{{- end -}}
|
||||
|
||||
@@ -66,7 +66,9 @@ securityContext:
|
||||
{{- with (include "ix.v1.common.controller.mainContainer" (dict "values" $root.Values "root" $root) | trim) }}
|
||||
containers:
|
||||
{{- . | nindent 2 }}
|
||||
{{- (include "ix.v1.common.controller.extraContainers" (dict "root" $root "containerList" $root.Values.additionalContainers "type" "additional") | trim) | nindent 2 }}
|
||||
{{- with (include "ix.v1.common.controller.extraContainers" (dict "root" $root "containerList" $root.Values.additionalContainers "type" "additional") | trim) }}
|
||||
{{- . | nindent 2 }}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $installContainers := (include "ix.v1.common.controller.extraContainers" (dict "root" $root "containerList" $root.Values.installContainers "type" "install") | trim) -}}
|
||||
|
||||
@@ -19,8 +19,10 @@
|
||||
{{- include "ix.v1.common.daemonset" . | nindent 0 -}}
|
||||
{{- else if eq .Values.controller.type "StatefulSet" -}}
|
||||
{{- include "ix.v1.common.statefulset" . | nindent 0 -}}
|
||||
{{- else if eq .Values.controller.type "Job" -}}
|
||||
{{/* Pass, it will render from the spawner.jobAndCronJob bellow */}}
|
||||
{{- else -}}
|
||||
{{- fail (printf "Not a valid controller.type (%s). Valid options are Deployment, DaemonSet, StatefulSet" .Values.controller.type) -}}
|
||||
{{- fail (printf "Not a valid controller.type (%s). Valid options are Deployment, DaemonSet, StatefulSet, Job" .Values.controller.type) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
|
||||
@@ -1,5 +1,60 @@
|
||||
{{- define "ix.v1.common.spawner.jobAndCronJob" -}}
|
||||
{{- range $jobName, $job := .Values.jobs -}}
|
||||
{{- $jobs := dict -}}
|
||||
|
||||
{{- if mustHas .Values.controller.type (list "Job" "CronJob") -}}
|
||||
{{- $jobValues := dict -}}
|
||||
|
||||
{{/* Controller holds Job/CronJob Configuration */}}
|
||||
{{- $jobValues = $.Values.controller -}}
|
||||
|
||||
{{/* If it's CronJob prepare the cron dict with enabled forced */}}
|
||||
{{- if eq $.Values.controller.type "CronJob" -}}
|
||||
{{- $_ := set $jobValues "cron" dict -}}
|
||||
{{- $_ := set $jobValues.cron $.Values.controller -}}
|
||||
{{- $_ := set $jobValues.cron "enabled" true -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/* Enable the Job/CronJob and create a podSpec */}}
|
||||
{{- $_ := set $jobValues "enabled" true -}}
|
||||
{{- $_ := set $jobValues "podSpec" dict -}}
|
||||
|
||||
{{/* Add labels/annotations if any. */}}
|
||||
{{- range $key := (list "labels" "annotations") -}}
|
||||
{{- if hasKey $.Values $key -}}
|
||||
{{- $_ := set $jobValues $key (get $.Values $key) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/* Add the .Values as the main container */}}
|
||||
{{- $_ := set $jobValues.podSpec "containers" dict -}}
|
||||
{{- $_ := set $jobValues.podSpec.containers "main" .Values -}}
|
||||
{{- $_ := set $jobValues.podSpec.containers.main "enabled" "true" -}}
|
||||
|
||||
{{/* Add additional containers if any */}}
|
||||
{{- range $name, $container := .Values.additionalContainers -}}
|
||||
{{- if $container.enabled -}}
|
||||
{{- $_ := set $jobValues.podSpec.containers $name $container -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/* Remove probes and lifecycle as they are not supported on Jobs/Crons */}}
|
||||
{{- $_ := unset $jobValues.podSpec.containers.main "probes" -}}
|
||||
{{- $_ := unset $jobValues.podSpec.containers.main "lifecycle" -}}
|
||||
|
||||
{{- if not $jobValues.nameOverride -}}
|
||||
{{- $_ := set $jobValues "nameOverride" (include "ix.v1.common.names.fullname" $) -}}
|
||||
{{- end -}}
|
||||
{{/* Add $jobValues to a "main" $job, now the spawner has the "usual" format */}}
|
||||
{{- $_ := set $jobs "main" $jobValues -}}
|
||||
|
||||
{{- else -}}
|
||||
|
||||
{{/* If it's not "standalone" Use the jobs dict */}}
|
||||
{{- $jobs = .Values.jobs -}}
|
||||
|
||||
{{- end -}}
|
||||
|
||||
{{- range $jobName, $job := $jobs -}}
|
||||
{{- if $job.enabled -}}
|
||||
|
||||
{{- $jobValues := $job -}}
|
||||
|
||||
Reference in New Issue
Block a user