Merge pull request #667 from monopole/convertGeneratorsNamespaceTest

Convert namespaced generators to in-memory.
This commit is contained in:
Jeff Regan
2018-12-29 15:08:02 -08:00
committed by GitHub
5 changed files with 87 additions and 59 deletions

View File

@@ -1,33 +0,0 @@
apiVersion: v1
data:
altGreeting: Good Morning from non-default namespace!
enableRisky: "false"
kind: ConfigMap
metadata:
name: the-non-default-namespace-map-b6h49k7mt8
namespace: non-default
---
apiVersion: v1
data:
altGreeting: Good Morning from default namespace!
enableRisky: "false"
kind: ConfigMap
metadata:
name: the-map-4959m5tm6c
---
apiVersion: v1
data:
password.txt: dmVyeSRlY3JldA==
kind: Secret
metadata:
name: the-non-default-namespace-secret-255294gd9d
namespace: non-default
type: Opaque
---
apiVersion: v1
data:
password.txt: dmVyeSRlY3JldA==
kind: Secret
metadata:
name: the-secret-cfbmct72tb
type: Opaque

View File

@@ -1,21 +0,0 @@
apiVersion: v1beta1
kind: Kustomization
configMapGenerator:
- name: the-non-default-namespace-map
namespace: non-default
literals:
- altGreeting=Good Morning from non-default namespace!
- enableRisky="false"
- name: the-map
literals:
- altGreeting=Good Morning from default namespace!
- enableRisky="false"
secretGenerator:
- name: the-non-default-namespace-secret
namespace: non-default
commands:
password.txt: "cat password.txt"
- name: the-secret
commands:
password.txt: "cat password.txt"

View File

@@ -1 +0,0 @@
very$ecret

View File

@@ -1,4 +0,0 @@
description: generators-namespace
args: []
filename: testdata/testcase-generators-namespace/in
expectedStdout: testdata/testcase-generators-namespace/expected.yaml

View File

@@ -0,0 +1,87 @@
/*
Copyright 2018 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package target
import (
"testing"
)
func TestNamespacedGenerator(t *testing.T) {
th := NewKustTestHarness(t, "/app")
th.writeK("/app", `
apiVersion: v1beta1
kind: Kustomization
configMapGenerator:
- name: the-non-default-namespace-map
namespace: non-default
literals:
- altGreeting=Good Morning from non-default namespace!
- enableRisky="false"
- name: the-map
literals:
- altGreeting=Good Morning from default namespace!
- enableRisky="false"
secretGenerator:
- name: the-non-default-namespace-secret
namespace: non-default
commands:
password.txt: "echo verySecret"
- name: the-secret
commands:
password.txt: "echo anotherSecret"
`)
m, err := th.makeKustTarget().MakeCustomizedResMap()
if err != nil {
t.Fatalf("Err: %v", err)
}
th.assertActualEqualsExpected(m, `
apiVersion: v1
data:
altGreeting: Good Morning from non-default namespace!
enableRisky: "false"
kind: ConfigMap
metadata:
name: the-non-default-namespace-map-b6h49k7mt8
namespace: non-default
---
apiVersion: v1
data:
altGreeting: Good Morning from default namespace!
enableRisky: "false"
kind: ConfigMap
metadata:
name: the-map-4959m5tm6c
---
apiVersion: v1
data:
password.txt: dmVyeVNlY3JldAo=
kind: Secret
metadata:
name: the-non-default-namespace-secret-9fgdmbbk5c
namespace: non-default
type: Opaque
---
apiVersion: v1
data:
password.txt: YW5vdGhlclNlY3JldAo=
kind: Secret
metadata:
name: the-secret-7dd8hcgfhk
type: Opaque
`)
}