mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-07-16 17:33:14 +00:00
add namespace.yaml
This commit is contained in:
@@ -34,13 +34,14 @@ import (
|
|||||||
func setupTest(t *testing.T) loader.Loader {
|
func setupTest(t *testing.T) loader.Loader {
|
||||||
kustomizationContent := []byte(`
|
kustomizationContent := []byte(`
|
||||||
namePrefix: foo-
|
namePrefix: foo-
|
||||||
namespace: foo
|
namespace: ns1
|
||||||
commonLabels:
|
commonLabels:
|
||||||
app: nginx
|
app: nginx
|
||||||
commonAnnotations:
|
commonAnnotations:
|
||||||
note: This is a test annotation
|
note: This is a test annotation
|
||||||
resources:
|
resources:
|
||||||
- deployment.yaml
|
- deployment.yaml
|
||||||
|
- namespace.yaml
|
||||||
configMapGenerator:
|
configMapGenerator:
|
||||||
- name: literalConfigMap
|
- name: literalConfigMap
|
||||||
literals:
|
literals:
|
||||||
@@ -58,6 +59,11 @@ kind: Deployment
|
|||||||
metadata:
|
metadata:
|
||||||
name: dply1
|
name: dply1
|
||||||
`)
|
`)
|
||||||
|
namespaceContent := []byte(`apiVersion: v1
|
||||||
|
kind: Namespace
|
||||||
|
metadata:
|
||||||
|
name: ns1
|
||||||
|
`)
|
||||||
|
|
||||||
loader := loadertest.NewFakeLoader("/testpath")
|
loader := loadertest.NewFakeLoader("/testpath")
|
||||||
err := loader.AddFile("/testpath/"+constants.KustomizationFileName, kustomizationContent)
|
err := loader.AddFile("/testpath/"+constants.KustomizationFileName, kustomizationContent)
|
||||||
@@ -68,12 +74,17 @@ metadata:
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Failed to setup fake loader.")
|
t.Fatalf("Failed to setup fake loader.")
|
||||||
}
|
}
|
||||||
|
err = loader.AddFile("/testpath/namespace.yaml", namespaceContent)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Failed to setup fake loader.")
|
||||||
|
}
|
||||||
return loader
|
return loader
|
||||||
}
|
}
|
||||||
|
|
||||||
var deploy = schema.GroupVersionKind{Group: "apps", Version: "v1", Kind: "Deployment"}
|
var deploy = schema.GroupVersionKind{Group: "apps", Version: "v1", Kind: "Deployment"}
|
||||||
var cmap = schema.GroupVersionKind{Version: "v1", Kind: "ConfigMap"}
|
var cmap = schema.GroupVersionKind{Version: "v1", Kind: "ConfigMap"}
|
||||||
var secret = schema.GroupVersionKind{Version: "v1", Kind: "Secret"}
|
var secret = schema.GroupVersionKind{Version: "v1", Kind: "Secret"}
|
||||||
|
var ns = schema.GroupVersionKind{Version: "v1", Kind: "Namespace"}
|
||||||
|
|
||||||
func TestResources(t *testing.T) {
|
func TestResources(t *testing.T) {
|
||||||
expected := resmap.ResMap{
|
expected := resmap.ResMap{
|
||||||
@@ -84,7 +95,7 @@ func TestResources(t *testing.T) {
|
|||||||
"kind": "Deployment",
|
"kind": "Deployment",
|
||||||
"metadata": map[string]interface{}{
|
"metadata": map[string]interface{}{
|
||||||
"name": "foo-dply1",
|
"name": "foo-dply1",
|
||||||
"namespace": "foo",
|
"namespace": "ns1",
|
||||||
"labels": map[string]interface{}{
|
"labels": map[string]interface{}{
|
||||||
"app": "nginx",
|
"app": "nginx",
|
||||||
},
|
},
|
||||||
@@ -118,7 +129,7 @@ func TestResources(t *testing.T) {
|
|||||||
"kind": "ConfigMap",
|
"kind": "ConfigMap",
|
||||||
"metadata": map[string]interface{}{
|
"metadata": map[string]interface{}{
|
||||||
"name": "foo-literalConfigMap-mc92bgcbh5",
|
"name": "foo-literalConfigMap-mc92bgcbh5",
|
||||||
"namespace": "foo",
|
"namespace": "ns1",
|
||||||
"labels": map[string]interface{}{
|
"labels": map[string]interface{}{
|
||||||
"app": "nginx",
|
"app": "nginx",
|
||||||
},
|
},
|
||||||
@@ -140,7 +151,7 @@ func TestResources(t *testing.T) {
|
|||||||
"kind": "Secret",
|
"kind": "Secret",
|
||||||
"metadata": map[string]interface{}{
|
"metadata": map[string]interface{}{
|
||||||
"name": "foo-secret-877fcfhgt5",
|
"name": "foo-secret-877fcfhgt5",
|
||||||
"namespace": "foo",
|
"namespace": "ns1",
|
||||||
"labels": map[string]interface{}{
|
"labels": map[string]interface{}{
|
||||||
"app": "nginx",
|
"app": "nginx",
|
||||||
},
|
},
|
||||||
@@ -156,6 +167,23 @@ func TestResources(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
resource.NewResId(ns, "ns1"): resource.NewBehaviorlessResource(
|
||||||
|
&unstructured.Unstructured{
|
||||||
|
Object: map[string]interface{}{
|
||||||
|
"apiVersion": "v1",
|
||||||
|
"kind": "Namespace",
|
||||||
|
"metadata": map[string]interface{}{
|
||||||
|
"name": "foo-ns1",
|
||||||
|
"namespace": "ns1",
|
||||||
|
"labels": map[string]interface{}{
|
||||||
|
"app": "nginx",
|
||||||
|
},
|
||||||
|
"annotations": map[string]interface{}{
|
||||||
|
"note": "This is a test annotation",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}),
|
||||||
}
|
}
|
||||||
l := setupTest(t)
|
l := setupTest(t)
|
||||||
app, err := New(l)
|
app, err := New(l)
|
||||||
@@ -185,6 +213,16 @@ func TestRawResources(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
resource.NewResId(ns, "ns1"): resource.NewBehaviorlessResource(
|
||||||
|
&unstructured.Unstructured{
|
||||||
|
Object: map[string]interface{}{
|
||||||
|
"apiVersion": "v1",
|
||||||
|
"kind": "Namespace",
|
||||||
|
"metadata": map[string]interface{}{
|
||||||
|
"name": "ns1",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}),
|
||||||
}
|
}
|
||||||
l := setupTest(t)
|
l := setupTest(t)
|
||||||
app, err := New(l)
|
app, err := New(l)
|
||||||
|
|||||||
Reference in New Issue
Block a user