replace commands/envcommand by DataSource in SecretGenerator

This commit is contained in:
Jingfang Liu
2019-01-15 15:03:45 -08:00
parent a5c6938c65
commit 2fa4a34589
11 changed files with 166 additions and 296 deletions

View File

@@ -181,9 +181,9 @@ configMapGenerator:
- foo=bar
secretGenerator:
- name: secret-in-base
commands:
username: "printf admin"
password: "printf somepw"
literals:
- username=admin
- password=somepw
`)
th.writeF("/app/deployment.yaml", `
apiVersion: apps/v1beta2
@@ -362,8 +362,8 @@ configMapGenerator:
secretGenerator:
- name: secret-in-base
behavior: merge
commands:
proxy: "printf haproxy"
literals:
- proxy=haproxy
`)
m, err := th.makeKustTarget().MakeCustomizedResMap()
if err != nil {

View File

@@ -52,9 +52,9 @@ configMapGenerator:
- DB_PASSWORD=somepw
secretGenerator:
- name: secret
commands:
DB_USERNAME: "printf admin"
DB_PASSWORD: "printf somepw"
literals:
- DB_USERNAME=admin
- DB_PASSWORD=somepw
type: Opaque
patchesJson6902:
- target:
@@ -63,16 +63,6 @@ patchesJson6902:
kind: Deployment
name: dply1
path: jsonpatch.json
`
kustomizationContent2 = `
apiVersion: v1beta1
kind: Kustomization
secretGenerator:
- name: secret
timeoutSeconds: 1
commands:
USER: "sleep 2"
type: Opaque
`
deploymentContent = `
apiVersion: apps/v1
@@ -217,18 +207,6 @@ func TestResourceNotFound(t *testing.T) {
}
}
func TestSecretTimeout(t *testing.T) {
th := NewKustTestHarness(t, "/whatever")
th.writeK("/whatever", kustomizationContent2)
_, err := th.makeKustTarget().MakeCustomizedResMap()
if err == nil {
t.Fatalf("Didn't get the expected error for an unknown resource")
}
if !strings.Contains(err.Error(), "killed") {
t.Fatalf("unexpected error: %q", err)
}
}
func findSecret(m resmap.ResMap) *resource.Resource {
for id, res := range m {
if id.Gvk().Kind == "Secret" {

View File

@@ -39,11 +39,11 @@ configMapGenerator:
secretGenerator:
- name: the-non-default-namespace-secret
namespace: non-default
commands:
password.txt: "echo verySecret"
literals:
- password.txt=verySecret
- name: the-secret
commands:
password.txt: "echo anotherSecret"
literals:
- password.txt=anotherSecret
`)
m, err := th.makeKustTarget().MakeCustomizedResMap()
if err != nil {
@@ -69,19 +69,19 @@ metadata:
---
apiVersion: v1
data:
password.txt: dmVyeVNlY3JldAo=
password.txt: dmVyeVNlY3JldA==
kind: Secret
metadata:
name: the-non-default-namespace-secret-9fgdmbbk5c
name: the-non-default-namespace-secret-h8d9hkgtb9
namespace: non-default
type: Opaque
---
apiVersion: v1
data:
password.txt: YW5vdGhlclNlY3JldAo=
password.txt: YW5vdGhlclNlY3JldA==
kind: Secret
metadata:
name: the-secret-7dd8hcgfhk
name: the-secret-fgb45h45bh
type: Opaque
`)
}