mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-12 01:14:22 +00:00
Add namespace for config map and secret generators
This commit is contained in:
@@ -94,6 +94,13 @@ secretGenerator:
|
||||
tls.crt: "cat secret/tls.cert"
|
||||
tls.key: "cat secret/tls.key"
|
||||
type: "kubernetes.io/tls"
|
||||
- name: app-tls-namespaced
|
||||
# you can define a namespace to generate secret in, defaults to: "default"
|
||||
namspace: apps
|
||||
commands:
|
||||
tls.crt: "cat secret/tls.cert"
|
||||
tls.key: "cat secret/tls.key"
|
||||
type: "kubernetes.io/tls"
|
||||
- name: downloaded_secret
|
||||
# timeoutSeconds specifies the number of seconds to
|
||||
# wait for the commands below. It defaults to 5 seconds.
|
||||
|
||||
@@ -49,6 +49,7 @@ func (f *ConfigMapFactory) makeFreshConfigMap(
|
||||
cm.APIVersion = "v1"
|
||||
cm.Kind = "ConfigMap"
|
||||
cm.Name = args.Name
|
||||
cm.Namespace = args.Namespace
|
||||
cm.Data = map[string]string{}
|
||||
return cm
|
||||
}
|
||||
|
||||
@@ -52,6 +52,7 @@ func (f *SecretFactory) makeFreshSecret(args *types.SecretArgs) *corev1.Secret {
|
||||
s.APIVersion = "v1"
|
||||
s.Kind = "Secret"
|
||||
s.Name = args.Name
|
||||
s.Namespace = args.Namespace
|
||||
s.Type = corev1.SecretType(args.Type)
|
||||
if s.Type == "" {
|
||||
s.Type = corev1.SecretTypeOpaque
|
||||
|
||||
33
pkg/commands/build/testdata/testcase-generators-namespace/expected.yaml
vendored
Normal file
33
pkg/commands/build/testdata/testcase-generators-namespace/expected.yaml
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
apiVersion: v1
|
||||
data:
|
||||
altGreeting: Good Morning from default namespace!
|
||||
enableRisky: "false"
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: the-map-4959m5tm6c
|
||||
---
|
||||
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:
|
||||
password.txt: dmVyeSRlY3JldA==
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: the-secret-cfbmct72tb
|
||||
type: Opaque
|
||||
---
|
||||
apiVersion: v1
|
||||
data:
|
||||
password.txt: dmVyeSRlY3JldA==
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: the-non-default-namespace-secret-255294gd9d
|
||||
namespace: non-default
|
||||
type: Opaque
|
||||
19
pkg/commands/build/testdata/testcase-generators-namespace/in/kustomization.yaml
vendored
Normal file
19
pkg/commands/build/testdata/testcase-generators-namespace/in/kustomization.yaml
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
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"
|
||||
1
pkg/commands/build/testdata/testcase-generators-namespace/in/password.txt
vendored
Normal file
1
pkg/commands/build/testdata/testcase-generators-namespace/in/password.txt
vendored
Normal file
@@ -0,0 +1 @@
|
||||
very$ecret
|
||||
4
pkg/commands/build/testdata/testcase-generators-namespace/test.yaml
vendored
Normal file
4
pkg/commands/build/testdata/testcase-generators-namespace/test.yaml
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
description: generators-namespace
|
||||
args: []
|
||||
filename: testdata/testcase-generators-namespace/in
|
||||
expectedStdout: testdata/testcase-generators-namespace/expected.yaml
|
||||
@@ -153,6 +153,9 @@ type ConfigMapArgs struct {
|
||||
// hash(content of configmap).
|
||||
Name string `json:"name,omitempty" yaml:"name,omitempty"`
|
||||
|
||||
// Namespace for the configmap, optional
|
||||
Namespace string `json:"namespace,omitempty" yaml:"namespace,omitempty"`
|
||||
|
||||
// behavior of configmap, must be one of create, merge and replace
|
||||
// 'create': create a new one;
|
||||
// 'replace': replace the existing one;
|
||||
@@ -170,6 +173,9 @@ type SecretArgs struct {
|
||||
// hash(content of secret).
|
||||
Name string `json:"name,omitempty" yaml:"name,omitempty"`
|
||||
|
||||
// Namespace for the secret, optional
|
||||
Namespace string `json:"namespace,omitempty" yaml:"namespace,omitempty"`
|
||||
|
||||
// behavior of secretGenerator, must be one of create, merge and replace
|
||||
// 'create': create a new one;
|
||||
// 'replace': replace the existing one;
|
||||
|
||||
Reference in New Issue
Block a user