Skip to content

Commit 90d03b0

Browse files
committed
Skip adding nameprefix to namespace
1 parent 16add04 commit 90d03b0

File tree

3 files changed

+21
-11
lines changed

3 files changed

+21
-11
lines changed

pkg/target/kusttarget_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,12 +203,12 @@ func TestResources1(t *testing.T) {
203203
"DB_PASSWORD": base64.StdEncoding.EncodeToString([]byte("somepw")),
204204
},
205205
}).SetBehavior(ifc.BehaviorCreate),
206-
resid.NewResIdWithPrefixNamespace(ns, "ns1", "foo-", ""): rf.RF().FromMap(
206+
resid.NewResIdWithPrefixNamespace(ns, "ns1", "", ""): rf.RF().FromMap(
207207
map[string]interface{}{
208208
"apiVersion": "v1",
209209
"kind": "Namespace",
210210
"metadata": map[string]interface{}{
211-
"name": "foo-ns1",
211+
"name": "ns1",
212212
"labels": map[string]interface{}{
213213
"app": "nginx",
214214
},

pkg/transformers/prefixname.go

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ package transformers
1919
import (
2020
"errors"
2121
"fmt"
22-
"log"
2322

2423
"sigs.k8s.io/kustomize/pkg/gvk"
2524
"sigs.k8s.io/kustomize/pkg/resmap"
@@ -40,11 +39,9 @@ var prefixFieldSpecsToSkip = []config.FieldSpec{
4039
{
4140
Gvk: gvk.Gvk{Kind: "CustomResourceDefinition"},
4241
},
43-
}
44-
45-
// deprecateNamePrefixFieldSpec will be moved into prefixFieldSpecsToSkip in next release
46-
var deprecateNamePrefixFieldSpec = config.FieldSpec{
47-
Gvk: gvk.Gvk{Kind: "Namespace"},
42+
{
43+
Gvk: gvk.Gvk{Kind: "Namespace"},
44+
},
4845
}
4946

5047
// NewNamePrefixTransformer construct a namePrefixTransformer.
@@ -77,9 +74,6 @@ func (o *namePrefixTransformer) Transform(m resmap.ResMap) error {
7774
}
7875

7976
for id := range mf {
80-
if id.Gvk().IsSelected(&deprecateNamePrefixFieldSpec.Gvk) {
81-
log.Println("Adding nameprefix to Namespace resource will be deprecated in next release.")
82-
}
8377
objMap := mf[id].Map()
8478
for _, path := range o.fieldSpecsToUse {
8579
if !id.Gvk().IsSelected(&path.Gvk) {

pkg/transformers/prefixname_test.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,14 @@ func TestPrefixNameRun(t *testing.T) {
5454
"name": "crd",
5555
},
5656
}),
57+
resid.NewResId(ns, "ns"): rf.FromMap(
58+
map[string]interface{}{
59+
"apiVersion": "v1",
60+
"kind": "Namespace",
61+
"metadata": map[string]interface{}{
62+
"name": "ns",
63+
},
64+
}),
5765
}
5866
expected := resmap.ResMap{
5967
resid.NewResIdWithPrefix(cmap, "cm1", "someprefix-"): rf.FromMap(
@@ -80,6 +88,14 @@ func TestPrefixNameRun(t *testing.T) {
8088
"name": "crd",
8189
},
8290
}),
91+
resid.NewResId(ns, "ns"): rf.FromMap(
92+
map[string]interface{}{
93+
"apiVersion": "v1",
94+
"kind": "Namespace",
95+
"metadata": map[string]interface{}{
96+
"name": "ns",
97+
},
98+
}),
8399
}
84100

85101
npt, err := NewNamePrefixTransformer(

0 commit comments

Comments
 (0)