Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Skip adding nameprefix to namespace" #516

Merged
merged 1 commit into from
Oct 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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