Skip to content

Commit

Permalink
Merge pull request #516 from kubernetes-sigs/revert-488-prefix
Browse files Browse the repository at this point in the history
Revert "Skip adding nameprefix to namespace"
  • Loading branch information
k8s-ci-robot authored Oct 26, 2018
2 parents 3c242f5 + 1020167 commit 383b3e7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 21 deletions.
4 changes: 2 additions & 2 deletions pkg/target/kusttarget_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,12 +204,12 @@ func TestResources1(t *testing.T) {
"DB_PASSWORD": base64.StdEncoding.EncodeToString([]byte("somepw")),
},
}).SetBehavior(ifc.BehaviorCreate),
resid.NewResIdWithPrefixNamespace(ns, "ns1", "", ""): rf.RF().FromMap(
resid.NewResIdWithPrefixNamespace(ns, "ns1", "foo-", ""): rf.RF().FromMap(
map[string]interface{}{
"apiVersion": "v1",
"kind": "Namespace",
"metadata": map[string]interface{}{
"name": "ns1",
"name": "foo-ns1",
"labels": map[string]interface{}{
"app": "nginx",
},
Expand Down
12 changes: 9 additions & 3 deletions pkg/transformers/prefixname.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package transformers
import (
"errors"
"fmt"
"log"

"sigs.k8s.io/kustomize/pkg/gvk"
"sigs.k8s.io/kustomize/pkg/resmap"
Expand All @@ -39,9 +40,11 @@ var prefixFieldSpecsToSkip = []config.FieldSpec{
{
Gvk: gvk.Gvk{Kind: "CustomResourceDefinition"},
},
{
Gvk: gvk.Gvk{Kind: "Namespace"},
},
}

// deprecateNamePrefixFieldSpec will be moved into prefixFieldSpecsToSkip in next release
var deprecateNamePrefixFieldSpec = config.FieldSpec{
Gvk: gvk.Gvk{Kind: "Namespace"},
}

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

for id := range mf {
if id.Gvk().IsSelected(&deprecateNamePrefixFieldSpec.Gvk) {
log.Println("Adding nameprefix to Namespace resource will be deprecated in next release.")
}
objMap := mf[id].Map()
for _, path := range o.fieldSpecsToUse {
if !id.Gvk().IsSelected(&path.Gvk) {
Expand Down
16 changes: 0 additions & 16 deletions pkg/transformers/prefixname_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,6 @@ func TestPrefixNameRun(t *testing.T) {
"name": "crd",
},
}),
resid.NewResId(ns, "ns"): rf.FromMap(
map[string]interface{}{
"apiVersion": "v1",
"kind": "Namespace",
"metadata": map[string]interface{}{
"name": "ns",
},
}),
}
expected := resmap.ResMap{
resid.NewResIdWithPrefix(cmap, "cm1", "someprefix-"): rf.FromMap(
Expand All @@ -88,14 +80,6 @@ func TestPrefixNameRun(t *testing.T) {
"name": "crd",
},
}),
resid.NewResId(ns, "ns"): rf.FromMap(
map[string]interface{}{
"apiVersion": "v1",
"kind": "Namespace",
"metadata": map[string]interface{}{
"name": "ns",
},
}),
}

npt, err := NewNamePrefixTransformer(
Expand Down

0 comments on commit 383b3e7

Please sign in to comment.