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

Use args for CLI parameters #244

Draft
wants to merge 3 commits into
base: v3
Choose a base branch
from
Draft
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
51 changes: 27 additions & 24 deletions charts/producer-app-cleanup-job/templates/job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,33 @@ spec:
resources:
{{ toYaml .Values.resources | indent 12 }}
args:
{{- if hasKey .Values.streams "brokers" }}
- --brokers
- {{ .Values.streams.brokers | quote }}
{{- end }}
{{- if hasKey .Values.streams "schemaRegistryUrl" }}
- --schema-registry-url
- {{ .Values.streams.schemaRegistryUrl | quote }}
{{- end }}
{{- if hasKey .Values "debug" }}
- --debug
- {{ .Values.debug | quote }}
{{- end }}
{{- if hasKey .Values.streams "outputTopic" }}
- --output-topic
- {{ .Values.streams.outputTopic | quote }}
{{- end }}
{{- range $key, $value := .Values.streams.extraOutputTopics }}
- --extra-output-topics
- {{ $key }}={{ $value }}
{{- end }}
{{- range $key, $value := .Values.commandLine }}
- {{ $key | quote }}
- {{ $value | quote }}
{{- end }}
{{- range .Values.commandLineList }}
- {{ . | quote }}
{{- end }}
- clean
env:
- name: ENV_PREFIX
Expand All @@ -64,26 +91,6 @@ spec:
- name: {{ printf "STREAMS_%s" $key | replace "." "_" | upper | quote }}
value: {{ $value | quote }}
{{- end }}
{{- if hasKey .Values.streams "brokers" }}
- name: "{{ .Values.configurationEnvPrefix }}_BROKERS"
value: {{ .Values.streams.brokers | quote }}
{{- end }}
{{- if hasKey .Values.streams "schemaRegistryUrl" }}
- name: "{{ .Values.configurationEnvPrefix }}_SCHEMA_REGISTRY_URL"
value: {{ .Values.streams.schemaRegistryUrl | quote }}
{{- end }}
{{- if hasKey .Values "debug" }}
- name: "{{ .Values.configurationEnvPrefix }}_DEBUG"
value: {{ .Values.debug | quote }}
{{- end }}
{{- if hasKey .Values.streams "outputTopic" }}
- name: "{{ .Values.configurationEnvPrefix }}_OUTPUT_TOPIC"
value: {{ .Values.streams.outputTopic | quote }}
{{- end }}
{{- if and (hasKey .Values.streams "extraOutputTopics") (.Values.streams.extraOutputTopics) }}
- name: "{{ .Values.configurationEnvPrefix }}_EXTRA_OUTPUT_TOPICS"
value: "{{- range $key, $value := .Values.streams.extraOutputTopics }}{{ $key }}={{ $value }},{{- end }}"
{{- end }}
{{- range $key, $value := .Values.secrets }}
- name: "{{ $key }}"
valueFrom:
Expand All @@ -98,10 +105,6 @@ spec:
name: {{ $value.name }}
key: "{{ $value.key }}"
{{- end }}
{{- range $key, $value := .Values.commandLine }}
- name: "{{ $root.Values.configurationEnvPrefix }}_{{ $key }}"
value: {{ $value | quote }}
{{- end }}
{{- range $key, $value := .Values.env }}
- name: {{ $key | quote }}
value: {{ $value | quote }}
Expand Down
5 changes: 4 additions & 1 deletion charts/producer-app-cleanup-job/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ streams:
# role: output

commandLine: {}
# MY_CLI_PARAM: "foo-bar"
# --my-cli-param: "foo-bar"
commandLineList: []
Copy link
Member Author

Choose a reason for hiding this comment

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

I added this in order to also pass parameters that are not just key-value pairs (e.g. flags like --large-messages). However, the map config is more suitable if one needs to merge multiple value files because maps do get merged and params can be overriden while lists are fully replaced. Should we rename the configs maybe? args.map and args.list?

# - --my-cli-param
# - foo-bar

debug: false

Expand Down
52 changes: 28 additions & 24 deletions charts/producer-app/templates/pod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,33 +41,41 @@ spec:
imagePullPolicy: "{{ .Values.imagePullPolicy }}"
resources:
{{ toYaml .Values.resources | indent 6 }}
args:
{{- if hasKey .Values.streams "brokers" }}
- --brokers
- {{ .Values.streams.brokers | quote }}
{{- end }}
{{- if hasKey .Values.streams "schemaRegistryUrl" }}
- --schema-registry-url
- {{ .Values.streams.schemaRegistryUrl | quote }}
{{- end }}
{{- if hasKey .Values "debug" }}
- --debug
- {{ .Values.debug | quote }}
{{- end }}
{{- if hasKey .Values.streams "outputTopic" }}
- --output-topic
- {{ .Values.streams.outputTopic | quote }}
{{- end }}
{{- range $key, $value := .Values.streams.extraOutputTopics }}
- --extra-output-topics
- {{ $key }}={{ $value }}
{{- end }}
{{- range $key, $value := .Values.commandLine }}
- {{ $key | quote }}
- {{ $value | quote }}
{{- end }}
{{- range .Values.commandLineList }}
- {{ . | quote }}
{{- end }}
env:
- name: ENV_PREFIX
value: {{ .Values.configurationEnvPrefix }}_
{{- range $key, $value := .Values.streams.config }}
- name: {{ printf "STREAMS_%s" $key | replace "." "_" | upper | quote }}
value: {{ $value | quote }}
{{- end }}
{{- if hasKey .Values.streams "brokers" }}
- name: "{{ .Values.configurationEnvPrefix }}_BROKERS"
value: {{ .Values.streams.brokers | quote }}
{{- end }}
{{- if hasKey .Values.streams "schemaRegistryUrl" }}
- name: "{{ .Values.configurationEnvPrefix }}_SCHEMA_REGISTRY_URL"
value: {{ .Values.streams.schemaRegistryUrl | quote }}
{{- end }}
{{- if hasKey .Values "debug" }}
- name: "{{ .Values.configurationEnvPrefix }}_DEBUG"
value: {{ .Values.debug | quote }}
{{- end }}
{{- if hasKey .Values.streams "outputTopic" }}
- name: "{{ .Values.configurationEnvPrefix }}_OUTPUT_TOPIC"
value: {{ .Values.streams.outputTopic | quote }}
{{- end }}
{{- if and (hasKey .Values.streams "extraOutputTopics") (.Values.streams.extraOutputTopics) }}
- name: "{{ .Values.configurationEnvPrefix }}_EXTRA_OUTPUT_TOPICS"
value: "{{- range $key, $value := .Values.streams.extraOutputTopics }}{{ $key }}={{ $value }},{{- end }}"
{{- end }}
{{- range $key, $value := .Values.secrets }}
- name: "{{ $key }}"
valueFrom:
Expand All @@ -82,10 +90,6 @@ spec:
name: {{ $value.name }}
key: "{{ $value.key }}"
{{- end }}
{{- range $key, $value := .Values.commandLine }}
- name: "{{ $root.Values.configurationEnvPrefix }}_{{ $key }}"
value: {{ $value | quote }}
{{- end }}
{{- range $key, $value := .Values.env }}
- name: {{ $key | quote }}
value: {{ $value | quote }}
Expand Down
5 changes: 4 additions & 1 deletion charts/producer-app/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ streams:
# role: output

commandLine: {}
# MY_CLI_PARAM: "foo-bar"
# --my-cli-param: "foo-bar"
commandLineList: []
# - --my-cli-param
# - foo-bar

debug: false

Expand Down
98 changes: 50 additions & 48 deletions charts/streams-app-cleanup-job/templates/job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,59 +56,65 @@ spec:
resources:
{{ toYaml .Values.resources | indent 12 }}
args:
{{- if .Values.streams.deleteOutput }}
{{- if hasKey .Values.streams "brokers" }}
- --brokers
- {{ .Values.streams.brokers | quote }}
{{- end }}
{{- if hasKey .Values.streams "schemaRegistryUrl" }}
- --schema-registry-url
- {{ .Values.streams.schemaRegistryUrl | quote }}
{{- end }}
{{- if hasKey .Values "debug" }}
- --debug
- {{ .Values.debug | quote }}
{{- end }}
{{- range .Values.streams.inputTopics }}
- --input-topics
- {{ . | quote }}
{{- end }}
{{- if hasKey .Values.streams "inputPattern" }}
- --input-pattern
- {{ .Values.streams.inputPattern | quote }}
{{- end }}
{{- if hasKey .Values.streams "outputTopic" }}
- --output-topic
- {{ .Values.streams.outputTopic | quote }}
{{- end }}
{{- if hasKey .Values.streams "errorTopic" }}
- --error-topic
- {{ .Values.streams.errorTopic | quote }}
{{- end }}
{{- range $key, $value := .Values.streams.extraOutputTopics }}
- --extra-output-topics
- {{ $key }}={{ $value }}
{{- end }}
{{- range $key, $value := .Values.streams.extraInputTopics }}
- --extra-input-topics
- {{ $key }}={{ $value | join ";" }}
{{- end }}
{{- range $key, $value := .Values.streams.extraInputPatterns }}
- --extra-input-patterns
- {{ $key }}={{ $value }}
{{- end }}
{{- range $key, $value := .Values.commandLine }}
- {{ $key | quote }}
- {{ $value | quote }}
{{- end }}
{{- range .Values.commandLineList }}
- {{ . | quote }}
{{- end }}
{{- if .Values.streams.deleteOutput }}
- clean
{{- else }}
{{- else }}
- reset
{{- end }}
{{- end }}
env:
- name: ENV_PREFIX
value: {{ .Values.configurationEnvPrefix }}_
{{- range $key, $value := .Values.streams.config }}
- name: {{ printf "STREAMS_%s" $key | replace "." "_" | upper | quote }}
value: {{ $value | quote }}
{{- end }}
{{- if hasKey .Values.streams "brokers" }}
- name: "{{ .Values.configurationEnvPrefix }}_BROKERS"
value: {{ .Values.streams.brokers | quote }}
{{- end }}
{{- if hasKey .Values.streams "schemaRegistryUrl" }}
- name: "{{ .Values.configurationEnvPrefix }}_SCHEMA_REGISTRY_URL"
value: {{ .Values.streams.schemaRegistryUrl | quote }}
{{- end }}
{{- if hasKey .Values "debug" }}
- name: "{{ .Values.configurationEnvPrefix }}_DEBUG"
value: {{ .Values.debug | quote }}
{{- end }}
{{- if and (hasKey .Values.streams "inputTopics") (.Values.streams.inputTopics) }}
- name: "{{ .Values.configurationEnvPrefix }}_INPUT_TOPICS"
value: {{ .Values.streams.inputTopics | join "," | quote }}
{{- end }}
{{- if hasKey .Values.streams "inputPattern" }}
- name: "{{ .Values.configurationEnvPrefix }}_INPUT_PATTERN"
value: {{ .Values.streams.inputPattern | join "," | quote }}
{{- end }}
{{- if hasKey .Values.streams "outputTopic" }}
- name: "{{ .Values.configurationEnvPrefix }}_OUTPUT_TOPIC"
value: {{ .Values.streams.outputTopic | quote }}
{{- end }}
{{- if hasKey .Values.streams "errorTopic" }}
- name: "{{ .Values.configurationEnvPrefix }}_ERROR_TOPIC"
value: {{ .Values.streams.errorTopic | quote }}
{{- end }}
{{- if and (hasKey .Values.streams "extraOutputTopics") (.Values.streams.extraOutputTopics) }}
- name: "{{ .Values.configurationEnvPrefix }}_EXTRA_OUTPUT_TOPICS"
value: "{{- range $key, $value := .Values.streams.extraOutputTopics }}{{ $key }}={{ $value }},{{- end }}"
{{- end }}
{{- $delimiter := ";" }}
{{- if and (hasKey .Values.streams "extraInputTopics") (.Values.streams.extraInputTopics) }}
- name: "{{ .Values.configurationEnvPrefix }}_EXTRA_INPUT_TOPICS"
value: "{{- range $key, $value := .Values.streams.extraInputTopics }}{{ $key }}={{ $value | join $delimiter }},{{- end }}"
{{- end }}
{{- if and (hasKey .Values.streams "extraInputPatterns") (.Values.streams.extraInputPatterns) }}
- name: "{{ .Values.configurationEnvPrefix }}_EXTRA_INPUT_PATTERNS"
value: "{{- range $key, $value := .Values.streams.extraInputPatterns }}{{ $key }}={{ $value }},{{- end }}"
{{- end }}
{{- range $key, $value := .Values.secrets }}
- name: "{{ $key }}"
valueFrom:
Expand All @@ -123,10 +129,6 @@ spec:
name: {{ $value.name }}
key: "{{ $value.key }}"
{{- end }}
{{- range $key, $value := .Values.commandLine }}
- name: "{{ $root.Values.configurationEnvPrefix }}_{{ $key }}"
value: {{ $value | quote }}
{{- end }}
{{- range $key, $value := .Values.env }}
- name: {{ $key | quote }}
value: {{ $value | quote }}
Expand Down
5 changes: 4 additions & 1 deletion charts/streams-app-cleanup-job/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ streams:
deleteOutput: false

commandLine: {}
# MY_CLI_PARAM: "foo-bar"
# --my-cli-param: "foo-bar"
commandLineList: []
# - --my-cli-param
# - foo-bar

debug: false

Expand Down
Loading
Loading