Skip to content

fix(renaming): namespace renames from nested kustomizations#31

Merged
andyyu2004 merged 4 commits intomasterfrom
bug-validating-webhook-namespace
Feb 7, 2026
Merged

fix(renaming): namespace renames from nested kustomizations#31
andyyu2004 merged 4 commits intomasterfrom
bug-validating-webhook-namespace

Conversation

@andyyu2004
Copy link
Owner

No description provided.

…n clientConfig

TestValidatingWebhookCombinedNamespaces from validatingwebhook_test.go

The namespace transformer should update the clientConfig.service.namespace
in ValidatingWebhookConfiguration to match the overlay namespace but it doesn't.

Expected: namespace: merge-namespace
Actual: namespace: base-namespace
Adds namespace field spec support to transform service namespace
references in ValidatingWebhookConfiguration and MutatingWebhookConfiguration
when a namespace transformer is applied.

Changes:
- Created namespace.yaml field spec with paths for:
  - webhooks[]/clientConfig/service/namespace (ValidatingWebhook & MutatingWebhook)
  - spec/conversion/webhook/clientConfig/service/namespace (CustomResourceDefinition)
  - spec/service/namespace (APIService)
- Updated Builtin struct to load namespace field specs
- Modified NamespaceTransformer to apply namespace field specs

This fixes the common case where a kustomization sets a namespace and
includes webhook configurations. The webhook's clientConfig.service.namespace
is now correctly updated to match the kustomization's namespace.

Verified working with simple test case where namespace is set directly.

Note: The combined test case (validating-webhook-combined) still fails.
This appears to be related to how resources are merged from nested
kustomizations and may require additional investigation into the
interaction between NamespaceTransformer and RenameTransformer.

Related issue: Namespace transformer should update ValidatingWebhookConfiguration
clientConfig.service.namespace field when overlay sets different namespace.
When a nested kustomization changes a resource's namespace, those renames
now propagate upward to update references in the parent's resources. This
fixes the bug where webhooks wouldn't be updated when services were moved
to different namespaces in nested overlays.

The fix only propagates namespace-only renames (not name changes from
namePrefix/nameSuffix) to avoid cross-tree pollution where renames from
one subtree incorrectly affect resources from sibling subtrees.

Fixes validating-webhook-combined test. All 234 tests pass.
@andyyu2004 andyyu2004 enabled auto-merge (squash) February 7, 2026 03:10
@andyyu2004 andyyu2004 merged commit dc0f0d3 into master Feb 7, 2026
1 check passed
@andyyu2004 andyyu2004 deleted the bug-validating-webhook-namespace branch February 7, 2026 03:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments