Skip to content

Commit

Permalink
Address reviews
Browse files Browse the repository at this point in the history
  • Loading branch information
raminqaf committed Oct 29, 2024
1 parent fd59688 commit 5940d84
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 11 deletions.
21 changes: 16 additions & 5 deletions charts/streams-app/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,26 @@ Create chart name and version as used by the chart label.
{{- end -}}

{{/*
Helper function to add annotations to resources
Define default annotations from .Values.annotations.
This will be used across resources.
*/}}
{{- define "streams-app.annotations" -}}
{{- if or .Values.kafka.applicationId .Values.annotations }}
{{- define "streams-app.default-annotations" -}}
{{- if or .Values.annotations }}
annotations:
{{- range $key, $value := .Values.annotations }}
{{- range $key, $value := .Values.annotations }}
{{ $key | quote }}: {{ $value | quote }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Define annotations helper for Deployment.
Includes default annotations and conditionally adds consumerGroup.
Only includes annotations if there is content.
*/}}
{{- define "streams-app.deployment-annotations" -}}
{{- include "streams-app.default-annotations" . }}
{{- if .Values.kafka.applicationId }}
{{- if and .Values.kafka.applicationId (not .Values.annotations.consumerGroup) }}
consumerGroup: {{ .Values.kafka.applicationId | quote }}
{{- end }}
Expand Down
2 changes: 1 addition & 1 deletion charts/streams-app/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "streams-app.name" . }}
{{- include "streams-app.annotations" . | nindent 2 }}
{{- include "streams-app.default-annotations" . }}
data:
{{- range $key, $value := .Values.files }}
{{ $key }}: {{ $value.content | quote }}
Expand Down
2 changes: 1 addition & 1 deletion charts/streams-app/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ kind: Deployment
{{- end }}
metadata:
name: {{ template "streams-app.fullname" . }}
{{- include "streams-app.annotations" . | nindent 2 }}
{{- include "streams-app.deployment-annotations" . }}
labels:
app: {{ template "streams-app.name" . }}
chart: {{ template "streams-app.chart" . }}
Expand Down
2 changes: 1 addition & 1 deletion charts/streams-app/templates/jmx-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "streams-app.name" . }}-jmx-configmap
{{- include "streams-app.annotations" . | nindent 2 }}
{{- include "streams-app.default-annotations" . }}
labels:
app: {{ template "streams-app.name" . }}
chart: {{ template "streams-app.chart" . }}
Expand Down
2 changes: 1 addition & 1 deletion charts/streams-app/templates/scaled-object.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
name: {{ template "streams-app.fullname" . }}-so
{{- include "streams-app.annotations" . | nindent 2 }}
{{- include "streams-app.default-annotations" . }}
spec:
scaleTargetRef:
{{- if .Capabilities.APIVersions.Has "apps/v1" }}
Expand Down
2 changes: 1 addition & 1 deletion charts/streams-app/templates/secrets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apiVersion: v1
kind: Secret
metadata:
name: {{ template "streams-app.fullname" . }}
{{- include "streams-app.annotations" . | nindent 2 }}
{{- include "streams-app.default-annotations" . }}
type: Opaque
data:
{{- range $key, $value := .Values.secrets }}
Expand Down
2 changes: 1 addition & 1 deletion charts/streams-app/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apiVersion: v1
kind: Service
metadata:
name: {{ template "streams-app.fullname" . }}
{{- include "streams-app.annotations" . | nindent 2 }}
{{- include "streams-app.default-annotations" . }}
labels:
app: {{ template "streams-app.name" . }}
chart: {{ template "streams-app.chart" . }}
Expand Down

0 comments on commit 5940d84

Please sign in to comment.