mirror of
https://github.com/truenas/charts.git
synced 2024-04-21 15:21:45 +00:00
first targetSelector
This commit is contained in:
@@ -0,0 +1,155 @@
|
||||
suite: pod imagePullSecret test
|
||||
templates:
|
||||
- common.yaml
|
||||
tests:
|
||||
- it: should assign multiple imagePullSecrets to primary pod
|
||||
set:
|
||||
controllers:
|
||||
controller-name1:
|
||||
enabled: true
|
||||
primary: true
|
||||
type: CronJob
|
||||
schedule: "* * * * *"
|
||||
podSpec: {}
|
||||
controller-name2:
|
||||
enabled: true
|
||||
primary: false
|
||||
type: Deployment
|
||||
podSpec: {}
|
||||
imagePullSecrets:
|
||||
pull-secret1:
|
||||
enabled: true
|
||||
data:
|
||||
registry: reg
|
||||
username: user
|
||||
password: pass
|
||||
email: mail
|
||||
pull-secret2:
|
||||
enabled: true
|
||||
data:
|
||||
registry: reg
|
||||
username: user
|
||||
password: pass
|
||||
email: mail
|
||||
asserts:
|
||||
- documentIndex: &cronJobDoc 2
|
||||
isKind:
|
||||
of: CronJob
|
||||
- documentIndex: *cronJobDoc
|
||||
equal:
|
||||
path: metadata.name
|
||||
value: release-name-common-test
|
||||
- documentIndex: *cronJobDoc
|
||||
equal:
|
||||
path: spec.jobTemplate.spec.template.spec.imagePullSecrets
|
||||
value:
|
||||
- release-name-common-test-pull-secret1
|
||||
- release-name-common-test-pull-secret2
|
||||
- documentIndex: &otherDeploymentDoc 3
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: *otherDeploymentDoc
|
||||
isNull:
|
||||
path: spec.template.spec.imagePullSecrets
|
||||
|
||||
- it: should assign multiple imagePullSecrets to all pods
|
||||
set:
|
||||
controllers:
|
||||
controller-name1:
|
||||
enabled: true
|
||||
primary: true
|
||||
type: Deployment
|
||||
podSpec: {}
|
||||
controller-name2:
|
||||
enabled: true
|
||||
primary: false
|
||||
type: Deployment
|
||||
podSpec: {}
|
||||
imagePullSecrets:
|
||||
pull-secret1:
|
||||
enabled: true
|
||||
data:
|
||||
registry: reg
|
||||
username: user
|
||||
password: pass
|
||||
email: mail
|
||||
targetSelector: all
|
||||
pull-secret2:
|
||||
enabled: true
|
||||
data:
|
||||
registry: reg
|
||||
username: user
|
||||
password: pass
|
||||
email: mail
|
||||
targetSelector: all
|
||||
asserts:
|
||||
- documentIndex: &deploymentDoc 2
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: *deploymentDoc
|
||||
equal:
|
||||
path: spec.template.spec.imagePullSecrets
|
||||
value:
|
||||
- release-name-common-test-pull-secret1
|
||||
- release-name-common-test-pull-secret2
|
||||
- documentIndex: &otherDeploymentDoc 3
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: *otherDeploymentDoc
|
||||
equal:
|
||||
path: spec.template.spec.imagePullSecrets
|
||||
value:
|
||||
- release-name-common-test-pull-secret1
|
||||
- release-name-common-test-pull-secret2
|
||||
|
||||
- it: should assign imagePullSecrets to selected pods
|
||||
set:
|
||||
controllers:
|
||||
controller-name1:
|
||||
enabled: true
|
||||
primary: true
|
||||
type: DaemonSet
|
||||
podSpec: {}
|
||||
controller-name2:
|
||||
enabled: true
|
||||
primary: false
|
||||
type: Deployment
|
||||
podSpec: {}
|
||||
imagePullSecrets:
|
||||
pull-secret1:
|
||||
enabled: true
|
||||
data:
|
||||
registry: reg
|
||||
username: user
|
||||
password: pass
|
||||
email: mail
|
||||
targetSelector:
|
||||
- controller-name1
|
||||
- controller-name2
|
||||
pull-secret2:
|
||||
enabled: true
|
||||
data:
|
||||
registry: reg
|
||||
username: user
|
||||
password: pass
|
||||
email: mail
|
||||
targetSelector:
|
||||
- controller-name1
|
||||
asserts:
|
||||
- documentIndex: &daemonSetDoc 2
|
||||
isKind:
|
||||
of: DaemonSet
|
||||
- documentIndex: *daemonSetDoc
|
||||
equal:
|
||||
path: spec.template.spec.imagePullSecrets
|
||||
value:
|
||||
- release-name-common-test-pull-secret1
|
||||
- release-name-common-test-pull-secret2
|
||||
- documentIndex: &otherDeploymentDoc 3
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: *otherDeploymentDoc
|
||||
equal:
|
||||
path: spec.template.spec.imagePullSecrets
|
||||
value:
|
||||
- release-name-common-test-pull-secret1
|
||||
@@ -4,4 +4,4 @@
|
||||
# controllers (Tests use a different named controller)
|
||||
controllers:
|
||||
main:
|
||||
enabled: true
|
||||
enabled: false
|
||||
|
||||
@@ -46,5 +46,5 @@ spec:
|
||||
{{- . | nindent 12 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
{{- include "ix.v1.common.lib.controller.pod" (dict "rootCtx" $rootCtx "objectData" $objectData) | nindent 10 }}
|
||||
{{- include "ix.v1.common.lib.controller.pod" (dict "rootCtx" $rootCtx "objectData" $objectData) | trim | nindent 10 }}
|
||||
{{- end -}}
|
||||
|
||||
@@ -49,5 +49,5 @@ spec:
|
||||
{{- . | nindent 8 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
{{- include "ix.v1.common.lib.controller.pod" (dict "rootCtx" $rootCtx "objectData" $objectData) | nindent 6 }}
|
||||
{{- include "ix.v1.common.lib.controller.pod" (dict "rootCtx" $rootCtx "objectData" $objectData) | trim | nindent 6 }}
|
||||
{{- end -}}
|
||||
|
||||
@@ -49,5 +49,5 @@ spec:
|
||||
{{- . | nindent 8 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
{{- include "ix.v1.common.lib.controller.pod" (dict "rootCtx" $rootCtx "objectData" $objectData) | nindent 6 }}
|
||||
{{- include "ix.v1.common.lib.controller.pod" (dict "rootCtx" $rootCtx "objectData" $objectData) | trim | nindent 6 }}
|
||||
{{- end -}}
|
||||
|
||||
@@ -46,5 +46,5 @@ spec:
|
||||
{{- . | nindent 8 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
{{- include "ix.v1.common.lib.controller.pod" (dict "rootCtx" $rootCtx "objectData" $objectData) | nindent 6 }}
|
||||
{{- include "ix.v1.common.lib.controller.pod" (dict "rootCtx" $rootCtx "objectData" $objectData) | trim | nindent 6 }}
|
||||
{{- end -}}
|
||||
|
||||
@@ -49,5 +49,5 @@ spec:
|
||||
{{- . | nindent 8 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
{{- include "ix.v1.common.lib.controller.pod" (dict "rootCtx" $rootCtx "objectData" $objectData) | nindent 6 }}
|
||||
{{- include "ix.v1.common.lib.controller.pod" (dict "rootCtx" $rootCtx "objectData" $objectData) | trim | nindent 6 }}
|
||||
{{- end -}}
|
||||
|
||||
@@ -7,5 +7,10 @@ objectData: The object data to be used to render the Pod.
|
||||
{{- define "ix.v1.common.lib.controller.pod" -}}
|
||||
{{- $rootCtx := .rootCtx -}}
|
||||
{{- $objectData := .objectData -}}
|
||||
{{- with (include "ix.v1.common.lib.pod.imagePullSecrets" (dict "rootCtx" $rootCtx "objectData" $objectData) | trim) }}
|
||||
imagePullSecrets:
|
||||
{{- . | nindent 2 }}
|
||||
{{- end }}
|
||||
hostNetwork: false
|
||||
|
||||
{{- end -}}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
{{/* Returns Image Pull Secret List */}}
|
||||
{{/* Call this template:
|
||||
{{ include "ix.v1.common.lib.pod.imagePullSecrets" (dict "rootCtx" $ "objectData" $objectData) }}
|
||||
rootCtx: The root context of the template. It is used to access the global context.
|
||||
objectData: The object data to be used to render the Pod.
|
||||
*/}}
|
||||
{{- define "ix.v1.common.lib.pod.imagePullSecrets" -}}
|
||||
{{- $rootCtx := .rootCtx -}}
|
||||
{{- $objectData := .objectData -}}
|
||||
|
||||
{{- $imgPullSecrets := list -}}
|
||||
{{- $podSelected := true -}}
|
||||
|
||||
{{- range $name, $imgPull := $rootCtx.Values.imagePullSecrets -}}
|
||||
{{- $pullName := (printf "%s-%s" (include "ix.v1.common.lib.chart.names.fullname" $rootCtx) $name) -}}
|
||||
|
||||
{{- if $imgPull.enabled -}}
|
||||
{{- if $imgPull.targetSelector -}}
|
||||
|
||||
{{- if and (kindIs "string" $imgPull.targetSelector) (eq $imgPull.targetSelector "all") -}}
|
||||
{{- $imgPullSecrets = mustAppend $imgPullSecrets $pullName -}}
|
||||
{{- else -}}
|
||||
{{- if (mustHas $objectData.shortName $imgPull.targetSelector) -}}
|
||||
{{- $imgPullSecrets = mustAppend $imgPullSecrets $pullName -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/* If not targetSelector, but is the primary pod */}}
|
||||
{{- else if $objectData.primary -}}
|
||||
{{- $imgPullSecrets = mustAppend $imgPullSecrets $pullName -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- range $imgPullSecrets }}
|
||||
- {{ . }}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{/* TODO: tests */}}
|
||||
@@ -28,6 +28,9 @@
|
||||
{{/* Set the name of the controller */}}
|
||||
{{- $_ := set $objectData "name" $objectName -}}
|
||||
|
||||
{{/* Short name is the one that defined on the chart, used on selectors */}}
|
||||
{{- $_ := set $objectData "shortName" $name -}}
|
||||
|
||||
{{/* Call class to create the object */}}
|
||||
{{- if eq $objectData.type "Deployment" -}}
|
||||
{{- include "ix.v1.common.class.deployment" (dict "objectData" $objectData "rootCtx" $) -}}
|
||||
|
||||
@@ -549,7 +549,6 @@ portal: {}
|
||||
# password: ""
|
||||
# # -- Email
|
||||
# email: ""
|
||||
# # TODO: Add support for targetSelector
|
||||
# # targetSelector: all
|
||||
# targetSelector:
|
||||
# - pod-name
|
||||
|
||||
Reference in New Issue
Block a user