Skip to content

Commit

Permalink
add(helm): use commonLabels in chart (#34)
Browse files Browse the repository at this point in the history
* add(helm): use commonLabels in chart

* Add new test file and fix `_helpers.tpl`

* Bump minor number

Co-authored-by: Heitor Ricardino Barros <heitorrbarros@gmail.com>

* Add comment in commonLabels on values

* Describe commonLabels

Co-authored-by: Heitor Ricardino Barros <heitorrbarros@gmail.com>

---------

Co-authored-by: Heitor Ricardino Barros <heitorrbarros@gmail.com>
  • Loading branch information
VitoriaOrtega and heitorrbarros authored Aug 12, 2024
1 parent e23eef5 commit 8774ff6
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion deploy/helm/charts/loki-rule-operator/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: "0.8.0"
version: "0.9.0"

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
Expand Down
3 changes: 3 additions & 0 deletions deploy/helm/charts/loki-rule-operator/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ helm.sh/chart: {{ include "loki-rule-operator.chart" . }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- with .Values.commonLabels }}
{{ toYaml . }}
{{- end }}
{{- end }}

{{/*
Expand Down
23 changes: 23 additions & 0 deletions deploy/helm/charts/loki-rule-operator/tests/global_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
suite: Resources contains commonLabels
templates:
- deployment.yaml
- serviceaccount.yaml
- crd/quero.com_lokirules.yaml
- rbac/cluster_role.yaml
- rbac/leader_election_role.yaml
- rbac/role_bindings.yaml
- rbac/lokirule_viewer_role.yaml
- rbac/lokirule_editor_role.yaml
tests:
- it: should set commonLabels in all resources
values:
- ./minimal_values.yaml
set:
release:
name: my-release
commonLabels:
global.label/name: my-global-label
asserts:
- equal:
path: metadata.labels["global.label/name"]
value: "my-global-label"
3 changes: 3 additions & 0 deletions deploy/helm/charts/loki-rule-operator/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ serviceAccount:

podAnnotations: {}

# -- Add additional labels that will be append in all resources.
commonLabels: {}

resources:
limits:
cpu: 200m
Expand Down

0 comments on commit 8774ff6

Please sign in to comment.