Skip to content

Commit 0097d21

Browse files
[helm] add lint checks for renderExamples (#6060)
* fix: add lint checks for renderExamples * fix: helm linting errors
1 parent 2a46509 commit 0097d21

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
@@ -3446,6 +3446,12 @@ func (Helm) RenderExamples() error {
34463446
maps.Copy(helmValues, data)
34473447
}
34483448

3449+
lintAction := action.NewLint()
3450+
lintResult := lintAction.Run([]string{helmChartPath}, helmValues)
3451+
if len(lintResult.Errors) > 0 {
3452+
return fmt.Errorf("failed to lint helm chart for example %s: %w", exampleFullPath, errors.Join(lintResult.Errors...))
3453+
}
3454+
34493455
installAction := action.NewInstall(actionConfig)
34503456
installAction.Namespace = "default"
34513457
installAction.ReleaseName = "example"

0 commit comments

Comments
 (0)