Skip to content

Adjust SecretGeneratorTest to pass with --enable_kyaml #3296

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions plugin/builtin/secretgenerator/SecretGenerator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
package main_test

import (
"fmt"
"testing"

"sigs.k8s.io/kustomize/api/konfig"
kusttest_test "sigs.k8s.io/kustomize/api/testutils/kusttest"
)

Expand Down Expand Up @@ -42,18 +44,26 @@ literals:
- VEGETABLE=carrot
`)

th.AssertActualEqualsExpected(rm, `
obscure := `obscure: CkxvcmVtIGlwc3VtIGRvbG9yIHNpdCBhbWV0LApjb25zZWN0ZXR1ciBhZGlwaXNjaW5nIGVsaXQuCg==`
if konfig.FlagEnableKyamlDefaultValue {
// The kyaml code does a better job of line wrapping.
obscure = `obscure: |
CkxvcmVtIGlwc3VtIGRvbG9yIHNpdCBhbWV0LApjb25zZWN0ZXR1ciBhZGlwaXNjaW5nIG
VsaXQuCg==`
}

th.AssertActualEqualsExpected(rm, fmt.Sprintf(`
apiVersion: v1
data:
DB_PASSWORD: aWxvdmV5b3U=
FRUIT: YXBwbGU=
ROUTER_PASSWORD: YWRtaW4=
VEGETABLE: Y2Fycm90
obscure: CkxvcmVtIGlwc3VtIGRvbG9yIHNpdCBhbWV0LApjb25zZWN0ZXR1ciBhZGlwaXNjaW5nIGVsaXQuCg==
%s
kind: Secret
metadata:
name: mySecret
namespace: whatever
type: Opaque
`)
`, obscure))
}