From 81682200fc38dabf389adf4366e41ccca972eda2 Mon Sep 17 00:00:00 2001 From: Jonas Wielage Date: Thu, 5 Dec 2024 17:33:34 +0100 Subject: [PATCH] Modify rule S117: Add exception to kubernetes language --- rules/S117/kubernetes/rule.adoc | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/rules/S117/kubernetes/rule.adoc b/rules/S117/kubernetes/rule.adoc index ef29d9a8dbe..308bbcb1d22 100644 --- a/rules/S117/kubernetes/rule.adoc +++ b/rules/S117/kubernetes/rule.adoc @@ -2,12 +2,24 @@ :identifier: local variable and function parameter :identifier_plural: local variables and function parameters :identifier_or: local variable or function parameter -:regex: ^[a-z][a-zA-Z0-9]*$ +:regex: ^\$[a-z][a-zA-Z0-9]*$ -include::../rule.adoc[] + +include::../introduction.adoc[] + +include::../why-is-this-an-issue.adoc[] + +=== Exceptions + +The rule does not raise an issue on the usages of the blank identifier `$_` or the root context `$`. + +include::../what-is-the-potential-impact.adoc[] + +include::../how-to-fix-it.adoc[] As a default, we suggest using the camelCase naming convention, as this is widely adopted for variables in Helm. + === Code examples ==== Noncompliant code example @@ -51,11 +63,20 @@ data: {{ $keyC }}: {{ $valC | quote }} {{- end }} ---- + +[source,text] +---- +# Usage of blank identifier +{{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className -}} + +# Usage of root context +{{- $ := . -}} +---- == Resources === Documentation - +* Helm documentation - https://helm.sh/docs/chart_template_guide/variables/[Helm - Variables] * Go documentation - https://go.dev/doc/effective_go#names[Effective Go - Names] * Wikipedia - https://en.wikipedia.org/wiki/Naming_convention_(programming)[Naming Convention (programming)]