Skip to content

Commit

Permalink
Merge pull request #37 from turkenh/secrets
Browse files Browse the repository at this point in the history
Handle secrets properly
  • Loading branch information
turkenh authored Oct 26, 2022
2 parents 7cde003 + 50e64e0 commit e6cc8b6
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 5 deletions.
3 changes: 3 additions & 0 deletions internal/templates/00-assert.yaml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ timeout: {{ .TestCase.Timeout }}
commands:
- command: ${KUBECTL} annotate managed --all upjet.upbound.io/test=true --overwrite
{{- range $resource := .Resources }}
{{- if eq $resource.KindGroup "secret." -}}
{{continue}}
{{- end -}}
{{- if $resource.PreAssertScriptPath }}
- command: {{ $resource.PreAssertScriptPath }}
{{- end }}
Expand Down
3 changes: 3 additions & 0 deletions internal/templates/01-assert.yaml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ kind: TestAssert
timeout: {{ .TestCase.Timeout }}
commands:
{{- range $resource := .Resources }}
{{- if eq $resource.KindGroup "secret." -}}
{{continue}}
{{- end -}}
{{- if $resource.Namespace }}
- command: ${KUBECTL} wait {{ $resource.KindGroup }}/{{ $resource.Name }} --for=delete --timeout 10s --namespace {{ $resource.Namespace }}
{{- else }}
Expand Down
3 changes: 3 additions & 0 deletions internal/templates/01-delete.yaml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ apiVersion: kuttl.dev/v1beta1
kind: TestStep
commands:
{{- range $resource := .Resources }}
{{- if eq $resource.KindGroup "secret." -}}
{{continue}}
{{- end -}}
{{- if $resource.PreDeleteScriptPath }}
- command: {{ $resource.PreDeleteScriptPath }}
{{- end }}
Expand Down
18 changes: 17 additions & 1 deletion internal/templates/renderer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@ spec:
count: 1
size: small
`

secretManifest = `apiVersion: v1
kind: Secret
metadata:
name: test-secret
namespace: upbound-system
type: Opaque
data:
key: dmFsdWU=
`
)

func TestRender(t *testing.T) {
Expand Down Expand Up @@ -108,6 +118,12 @@ commands:
PreDeleteScriptPath: "/tmp/claim/pre-delete.sh",
Conditions: []string{"Ready", "Synced"},
},
{
YAML: secretManifest,
Name: "test-secret",
KindGroup: "secret.",
Namespace: "upbound-system",
},
},
},
want: want{
Expand All @@ -116,7 +132,7 @@ commands:
kind: TestStep
commands:
- command: /tmp/setup.sh
` + "---\n" + bucketManifest + "---\n" + claimManifest,
` + "---\n" + bucketManifest + "---\n" + claimManifest + "---\n" + secretManifest,
"00-assert.yaml": `apiVersion: kuttl.dev/v1beta1
kind: TestAssert
timeout: 10
Expand Down
4 changes: 0 additions & 4 deletions internal/tester.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,6 @@ func (t *Tester) prepareConfig() (*config.TestCase, []config.Resource, error) {

for _, m := range t.manifests {
obj := m.Object
if obj.GroupVersionKind().String() == "/v1, Kind=Secret" {
continue
}

kg := strings.ToLower(obj.GroupVersionKind().Kind + "." + obj.GroupVersionKind().Group)

example := config.Resource{
Expand Down

0 comments on commit e6cc8b6

Please sign in to comment.