diff --git a/cronjob/templates/_argo_cron_workflow.tpl b/cronjob/templates/_argo_cron_workflow.tpl index 8db9d12..be14d21 100644 --- a/cronjob/templates/_argo_cron_workflow.tpl +++ b/cronjob/templates/_argo_cron_workflow.tpl @@ -126,12 +126,12 @@ {{- if .Values.containers }} {{- range .Values.containers }} - {{ $value := list . $.Release.Namespace $.Values.name }} + {{ $value := list . $.Release.Namespace $.Values.name $.Values.businessid }} - {{- include "cronjob.argo_cron_workflow.container_template" $value | nindent 8}} {{- end }} {{- else }} {{- $defaultValue := merge (fromJson "{\"name\":\"template\"}") $.Values }} - {{- $value := list $defaultValue $.Release.Namespace $.Values.name }} + {{- $value := list $defaultValue $.Release.Namespace $.Values.name $.Values.businessid}} - {{- include "cronjob.argo_cron_workflow.container_template" $value | nindent 8 }} {{- end }} diff --git a/cronjob/templates/_argo_cron_workflow_container_template.tpl b/cronjob/templates/_argo_cron_workflow_container_template.tpl index 8c79c41..8e1a8fe 100644 --- a/cronjob/templates/_argo_cron_workflow_container_template.tpl +++ b/cronjob/templates/_argo_cron_workflow_container_template.tpl @@ -2,11 +2,12 @@ {{- $input := index . 0 -}} {{- $namespace := index . 1 -}} {{- $workflowName := index . 2 -}} +{{- $businessid := index . 3 -}} name: {{ $input.name }} metadata: namespace: {{ $namespace }} labels: - businessid: {{ $input.businessid | quote }} + businessid: {{ $businessid | quote }} {{- with $input.podSpecPatch }} podSpecPatch: {{ quote . }} {{- end }} diff --git a/cronjob/tests/cronjob_test.yaml b/cronjob/tests/cronjob_test.yaml index 1831b73..6fb73d1 100644 --- a/cronjob/tests/cronjob_test.yaml +++ b/cronjob/tests/cronjob_test.yaml @@ -248,4 +248,13 @@ tests: businessid: ~ asserts: - failedTemplate: - errorMessage: businessid must be provided \ No newline at end of file + errorMessage: businessid must be provided + - it: should render an multi-container argo cron workflow + values: + - ./values/cronjob/argo_multi_container.yaml + asserts: + - hasDocuments: + count: 1 + - equal: + path: spec.workflowSpec.templates[1].metadata.labels.businessid + value: "some-business-id" diff --git a/cronjob/tests/values/cronjob/argo_multi_container.yaml b/cronjob/tests/values/cronjob/argo_multi_container.yaml new file mode 100644 index 0000000..e9fa286 --- /dev/null +++ b/cronjob/tests/values/cronjob/argo_multi_container.yaml @@ -0,0 +1,102 @@ +name: simple-cron-workflow +schedule: 1 * * * * +kind: CronWorkflow +businessid: "some-business-id" +startingDeadlineSeconds: {} +job: + retries: 1 + timeout: 1800 + retryPolicy: OnFailure +ttlStrategy: + secondsAfterCompletion: 600 +podGC: + strategy: OnPodCompletion +annotations: {} +image: + repository: test/testImage + tag: latest +command: + - bundle + - exec + - rails + - test +args: + - abc +resources: + requests: + cpu: 300m + memory: 2Gi +exitNotifications: + slackApp: + portalDomain: https://argo.com + webhookUrl: https://webhook/service/test + mention: + onFailure: + - U0123ABC123 + - S0345DEF345 + onSuccess: + - U0123ABC123 + - S0345DEF345 + newRelic: + image: + repository: test/test-newrelic-agent + tag: latest + licenseKey: 12345testtest1234test + appName: Test App + healthcheckIo: + uuid: arf21-323s-232d-23dasd +env: + RAILS_ENV: staging +envSecrets: + MONGODB_USER: mongodb +envFrom: + configMapRef: + - test-1-env + - test-2-env + secretRef: + - test-1-secret + - test-2-secret +serviceaccount: + annotations: + eks.amazonaws.com/role-arn: arn:aws:iam::123456789012:role/my-service-account + name: my-service-account +pdb: + enable: true + minAvailable: 9999 +securityContextForPod: + runAsUser: 1000 + runAsGroup: 1000 + fsGroup: 1000 +nodeSelector: + nodegroup: ec-eks-db-cpu-node-autoscaling-group +tolerations: + - key: shop-callback-node + operator: Equal + value: "true" + effect: NoSchedule +dnsConfig: + options: + - name: ndots + value: "5" +affinity: + nodeAffinity: + requiredDuringSchedulingIgnoredDuringExecution: + nodeSelectorTerms: + - matchExpressions: + - key: node.kubernetes.io/instance-type + operator: In + values: + - m6i.2xlarge + podAffinity: + requiredDuringSchedulingIgnoredDuringExecution: + - labelSelector: + matchLabels: + a: 1 + topologyKey: topology.kubernetes.io/zone +containers: + - name: multi-step-test-container + image: + repository: test/testImage + tag: latest + args: + - echo "Hello, World!"