generated from falcosecurity/template-repository
-
Notifications
You must be signed in to change notification settings - Fork 295
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(falco): reintroduce service account
Signed-off-by: Aldo Lacuku <[email protected]>
- Loading branch information
Showing
6 changed files
with
88 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
apiVersion: v2 | ||
name: falco | ||
version: 4.0.0 | ||
version: 4.1.0 | ||
appVersion: "0.37.0" | ||
description: Falco | ||
keywords: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
|
||
{{- if .Values.serviceAccount.create -}} | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: {{ include "falco.serviceAccountName" . }} | ||
namespace: {{ include "falco.namespace" . }} | ||
labels: | ||
{{- include "falco.labels" . | nindent 4 }} | ||
{{- with .Values.serviceAccount.annotations }} | ||
annotations: | ||
{{- toYaml . | nindent 4 }} | ||
{{- end }} | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package unit | ||
|
||
import ( | ||
"github.com/gruntwork-io/terratest/modules/helm" | ||
"github.com/stretchr/testify/require" | ||
corev1 "k8s.io/api/core/v1" | ||
"path/filepath" | ||
"strings" | ||
"testing" | ||
) | ||
|
||
func TestServiceAccount(t *testing.T) { | ||
t.Parallel() | ||
|
||
helmChartPath, err := filepath.Abs(chartPath) | ||
require.NoError(t, err) | ||
|
||
testCases := []struct { | ||
name string | ||
values map[string]string | ||
expected func(t *testing.T, sa *corev1.ServiceAccount) | ||
}{ | ||
{ | ||
"defaultValues", | ||
nil, | ||
func(t *testing.T, sa *corev1.ServiceAccount) { | ||
require.Equal(t, sa.Name, "") | ||
}, | ||
}, | ||
{ | ||
"kind=kmod", | ||
map[string]string{ | ||
"serviceAccount.create": "true", | ||
}, | ||
func(t *testing.T, sa *corev1.ServiceAccount) { | ||
require.Equal(t, sa.Name, "rendered-resources-falco") | ||
}, | ||
}, | ||
} | ||
|
||
for _, testCase := range testCases { | ||
testCase := testCase | ||
|
||
t.Run(testCase.name, func(t *testing.T) { | ||
t.Parallel() | ||
|
||
options := &helm.Options{SetValues: testCase.values} | ||
output, err := helm.RenderTemplateE(t, options, helmChartPath, releaseName, []string{"templates/serviceaccount.yaml"}) | ||
if err != nil { | ||
require.True(t, strings.Contains(err.Error(), "Error: could not find template templates/serviceaccount.yaml in chart")) | ||
} | ||
|
||
var sa corev1.ServiceAccount | ||
helm.UnmarshalK8SYaml(t, output, &sa) | ||
|
||
testCase.expected(t, &sa) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters