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:
Jerome Brette
2019-07-20 22:49:02 -05:00
parent 3a4d025b5c
commit f649b62629
6 changed files with 64 additions and 168 deletions

View File

@@ -99,6 +99,15 @@ metadata:
name: crd
`)
// Import note: The namespace transformer is in charge of
// the metadata.namespace field. The namespace transformer SHOULD
// NOT modify neither the "namespace" subfield within the
// ClusterRoleBinding.subjects field nor the "namespace"
// subfield in the ValidatingWebhookConfiguration.webhooks field.
// This is the role of the namereference Transformer to handle
// object reference changes (prefix/suffix and namespace).
// For use cases involving simultaneous change of name and namespace,
// refer to namespaces tests in pkg/target test suites.
th.AssertActualEqualsExpected(rm, `
apiVersion: v1
kind: ConfigMap
@@ -142,10 +151,10 @@ metadata:
subjects:
- kind: ServiceAccount
name: default
namespace: test
namespace: system
- kind: ServiceAccount
name: service-account
namespace: test
namespace: system
- kind: ServiceAccount
name: another
namespace: random
@@ -158,7 +167,7 @@ webhooks:
- clientConfig:
service:
name: svc1
namespace: test
namespace: system
name: example1
- clientConfig:
service: