Skip to content

Commit 4aa845f

Browse files
[helm] add lint checks for renderExamples (#6060) (#6092)
* fix: add lint checks for renderExamples * fix: helm linting errors (cherry picked from commit 0097d21) Co-authored-by: Panos Koutsovasilis <panos.koutsovasilis@elastic.co>
1 parent c5b20a3 commit 4aa845f

File tree

8 files changed

+13
-7
lines changed

8 files changed

+13
-7
lines changed

deploy/helm/elastic-agent/templates/agent/cluster-role-binding.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
{{- if or ($presetVal).clusterRole.create ($presetVal).clusterRole.name -}}
44
{{- if or ($presetVal).serviceAccount.create ($presetVal).serviceAccount.name -}}
55
{{/* cluster role binding is not namespace bound so let's try to give it a unique enough name */}}
6-
{{- $clusterRoleName := printf "agent-%s-%s-%s" $presetName $.Release.Name $.Release.Namespace -}}
6+
{{- $clusterRoleName := printf "agent-%s-%s-%s" $presetName $.Release.Name $.Release.Namespace }}
77
apiVersion: rbac.authorization.k8s.io/v1
88
kind: ClusterRoleBinding
99
metadata:

deploy/helm/elastic-agent/templates/agent/cluster-role.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
{{- range $presetName, $presetVal := $.Values.agent.presets -}}
33
{{- if eq $presetVal.clusterRole.create true -}}
44
{{/* cluster role binding is not namespace bound so let's try to give it a unique enough name */}}
5-
{{- $clusterRoleName := printf "agent-%s-%s-%s" $presetName $.Release.Name $.Release.Namespace -}}
5+
{{- $clusterRoleName := printf "agent-%s-%s-%s" $presetName $.Release.Name $.Release.Namespace }}
66
apiVersion: rbac.authorization.k8s.io/v1
77
kind: ClusterRole
88
metadata:

deploy/helm/elastic-agent/templates/agent/eck/daemonset.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
{{- range $presetName, $presetVal := $.Values.agent.presets -}}
33
{{- if and (eq ($presetVal).mode "daemonset") (eq $.Values.agent.engine "eck") -}}
44
{{- $agentName := include "elasticagent.preset.fullname" (list $ $presetName) -}}
5-
{{- $podTemplateResource := include "elasticagent.engine.eck.podTemplate" (list $ $presetVal $agentName) | fromYaml -}}
5+
{{- $podTemplateResource := include "elasticagent.engine.eck.podTemplate" (list $ $presetVal $agentName) | fromYaml }}
66
apiVersion: agent.k8s.elastic.co/v1alpha1
77
kind: Agent
88
metadata:

deploy/helm/elastic-agent/templates/agent/eck/secret.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{{- include "elasticagent.init" $ -}}
22
{{- range $presetName, $presetVal := $.Values.agent.presets }}
33
{{- if (eq $.Values.agent.engine "eck") -}}
4-
{{- $agentName := include "elasticagent.preset.fullname" (list $ $presetName) -}}
4+
{{- $agentName := include "elasticagent.preset.fullname" (list $ $presetName) }}
55
apiVersion: v1
66
kind: Secret
77
metadata:

deploy/helm/elastic-agent/templates/agent/k8s/_secret.tpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
{{- . | toYaml | nindent 6}}
1818
{{- end }}
1919
inputs:
20-
{{- with ($presetVal)._inputs -}}
20+
{{- with ($presetVal)._inputs }}
2121
{{- . | toYaml | nindent 6 }}
2222
{{- end }}
2323
{{- else }}

deploy/helm/elastic-agent/templates/agent/k8s/secret.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{{- include "elasticagent.init" $ -}}
22
{{- range $presetName, $presetVal := $.Values.agent.presets }}
33
{{- if (eq $.Values.agent.engine "k8s") -}}
4-
{{- $agentName := include "elasticagent.preset.fullname" (list $ $presetName) -}}
4+
{{- $agentName := include "elasticagent.preset.fullname" (list $ $presetName) }}
55
apiVersion: v1
66
kind: Secret
77
metadata:

deploy/helm/elastic-agent/templates/agent/service-account.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{{- include "elasticagent.init" $ -}}
22
{{- range $presetName, $presetVal := $.Values.agent.presets -}}
33
{{- if eq $presetVal.serviceAccount.create true -}}
4-
{{- $agentName := include "elasticagent.preset.fullname" (list $ $presetName) -}}
4+
{{- $agentName := include "elasticagent.preset.fullname" (list $ $presetName) }}
55
apiVersion: v1
66
kind: ServiceAccount
77
metadata:

magefile.go

+6
Original file line numberDiff line numberDiff line change
@@ -3429,6 +3429,12 @@ func (Helm) RenderExamples() error {
34293429
maps.Copy(helmValues, data)
34303430
}
34313431

3432+
lintAction := action.NewLint()
3433+
lintResult := lintAction.Run([]string{helmChartPath}, helmValues)
3434+
if len(lintResult.Errors) > 0 {
3435+
return fmt.Errorf("failed to lint helm chart for example %s: %w", exampleFullPath, errors.Join(lintResult.Errors...))
3436+
}
3437+
34323438
installAction := action.NewInstall(actionConfig)
34333439
installAction.Namespace = "default"
34343440
installAction.ReleaseName = "example"

0 commit comments

Comments
 (0)