Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add business id to cronjob chart #156

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cronjob/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v1
description: Helm chart with simple cronjob template
name: cronjob
version: 0.11.0
version: 1.0.0
appVersion: 1.0.0
tillerVersion: ">=2.14.3"
2 changes: 2 additions & 0 deletions cronjob/templates/_argo_cron_workflow.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
podMetadata:
labels:
name: {{ .Values.name }}
businessid: {{ .Values.businessid | quote }}
annotations:
{{- range $key, $value := .Values.annotations }}
{{ $key | quote }} : {{ $value | quote }}
{{- end }}
workflowMetadata:
labels:
name: {{ .Values.name }}
businessid: {{ .Values.businessid | quote }}
annotations:
{{- range $key, $value := .Values.annotations }}
{{ $key | quote }} : {{ $value | quote }}
Expand Down
2 changes: 2 additions & 0 deletions cronjob/templates/_argo_cron_workflow_container_template.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
name: {{ $input.name }}
metadata:
namespace: {{ $namespace }}
labels:
businessid: {{ $input.businessid | quote }}
{{- with $input.podSpecPatch }}
podSpecPatch: {{ quote . }}
{{- end }}
Expand Down
4 changes: 4 additions & 0 deletions cronjob/templates/cronjob.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ kind: CronJob
metadata:
name: {{ .Values.name }}
namespace: {{ .Release.Namespace }}
labels:
{{- if and (.Values.kind ) (eq .Values.kind "CronWorkflow") }}
businessid: {{ required "businessid must be provided" .Values.businessid | quote }}
Copy link
Contributor

@ThomasKwan-shopline ThomasKwan-shopline Jul 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why add required here, should add required in all businessid field?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the entry point, so I believe checking here would be enough.

{{- end }}
spec:
schedule: {{ .Values.schedule | quote }}
# If "kind" eq to "CronWorkflow", timezone can be set. If "kind" eq to "CronWorkflow" and timezone are not set, "Asia/Taipei" will be used
Expand Down
11 changes: 10 additions & 1 deletion cronjob/tests/cronjob_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -239,4 +239,13 @@ tests:
- hasDocuments:
count: 1
- isKind:
of: CronWorkflow
of: CronWorkflow

- it: should not render an argo cron workflow when businessid is null
values:
- ./values/cronjob/argo_minimal.yaml
set:
businessid: ~
asserts:
- failedTemplate:
errorMessage: businessid must be provided
1 change: 1 addition & 0 deletions cronjob/tests/values/cronjob/argo.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: simple-cron-workflow
schedule: 1 * * * *
kind: CronWorkflow
businessid: "some-business-id"
startingDeadlineSeconds: {}
job:
retries: 1
Expand Down
1 change: 1 addition & 0 deletions cronjob/tests/values/cronjob/argo_minimal.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: simple-cron-workflow
schedule: 1 * * * *
kind: CronWorkflow
businessid: "some-business-id"
image:
repository: test/testImage
tag: latest
Expand Down
3 changes: 3 additions & 0 deletions cronjob/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ kind: "CronJob"
# example
# kind: CronWorkflow

# Required: please quote the businessid as string
# businessid: "xxxxxxxxxxxxxxxxxx"

# Starting Deadline Seconds of cron job. Will be assign to spec.startingDeadlineSeconds.
startingDeadlineSeconds: {}

Expand Down