mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-14 10:30:59 +00:00
Update Namespace and Name simultaneously (1/2)
- Removed RoleBinding and Webhook specific code in the namespacetransformer. That code was attempting to perform the task of the namereference - Updated namereference transformer configuration to suppport the Webhooks. - Prevent the namereference from wiping out the namespace value if no referral candidate was selected - Added unit tests.
This commit is contained in:
@@ -520,7 +520,7 @@ func TestNameReferenceUnhappyRun(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}).ResMap(),
|
||||
expectedErr: "is expected to be"},
|
||||
expectedErr: "is expected to contain a name field"},
|
||||
}
|
||||
|
||||
nrt := NewNameReferenceTransformer(defaultTransformerConfig.NameReference)
|
||||
@@ -652,6 +652,7 @@ const (
|
||||
ns1 = "ns1"
|
||||
ns2 = "ns2"
|
||||
ns3 = "ns3"
|
||||
ns4 = "ns4"
|
||||
|
||||
orgname = "uniquename"
|
||||
prefixedname = "prefix-uniquename"
|
||||
@@ -808,6 +809,11 @@ func TestNameReferenceClusterWide(t *testing.T) {
|
||||
"name": orgname,
|
||||
"namespace": ns2,
|
||||
},
|
||||
map[string]interface{}{
|
||||
"kind": "ServiceAccount",
|
||||
"name": orgname,
|
||||
"namespace": "random",
|
||||
},
|
||||
}}).ResMap()
|
||||
|
||||
expected := resmaptest_test.NewSeededRmBuilder(t, rf, m.ShallowCopy()).
|
||||
@@ -862,6 +868,11 @@ func TestNameReferenceClusterWide(t *testing.T) {
|
||||
"name": suffixedname,
|
||||
"namespace": ns2,
|
||||
},
|
||||
map[string]interface{}{
|
||||
"kind": "ServiceAccount",
|
||||
"name": orgname,
|
||||
"namespace": "random",
|
||||
},
|
||||
},
|
||||
}).ResMap()
|
||||
|
||||
@@ -890,6 +901,13 @@ func TestNameReferenceNamespaceTransformation(t *testing.T) {
|
||||
rf := resource.NewFactory(
|
||||
kunstruct.NewKunstructuredFactoryImpl())
|
||||
m := resmaptest_test.NewRmBuilder(t, rf).
|
||||
AddWithNsAndName(ns4, orgname, map[string]interface{}{
|
||||
"apiVersion": "v1",
|
||||
"kind": "Secret",
|
||||
"metadata": map[string]interface{}{
|
||||
"name": orgname,
|
||||
"namespace": ns4,
|
||||
}}).
|
||||
// Add ServiceAccount with the same org name in "ns1" namespaces
|
||||
AddWithNsAndName(ns1, orgname, map[string]interface{}{
|
||||
"apiVersion": "v1",
|
||||
@@ -934,6 +952,16 @@ func TestNameReferenceNamespaceTransformation(t *testing.T) {
|
||||
"name": orgname,
|
||||
"namespace": ns3,
|
||||
},
|
||||
map[string]interface{}{
|
||||
"kind": "ServiceAccount",
|
||||
"name": orgname,
|
||||
"namespace": "random",
|
||||
},
|
||||
map[string]interface{}{
|
||||
"kind": "ServiceAccount",
|
||||
"name": orgname,
|
||||
"namespace": ns4,
|
||||
},
|
||||
}}).ResMap()
|
||||
|
||||
expected := resmaptest_test.NewSeededRmBuilder(t, rf, m.ShallowCopy()).
|
||||
@@ -963,6 +991,16 @@ func TestNameReferenceNamespaceTransformation(t *testing.T) {
|
||||
"name": suffixedname,
|
||||
"namespace": ns2,
|
||||
},
|
||||
map[string]interface{}{
|
||||
"kind": "ServiceAccount",
|
||||
"name": orgname,
|
||||
"namespace": "random",
|
||||
},
|
||||
map[string]interface{}{
|
||||
"kind": "ServiceAccount",
|
||||
"name": orgname,
|
||||
"namespace": ns4,
|
||||
},
|
||||
},
|
||||
}).ResMap()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user