Skip to content

feat(runtime): Add --enable-cross-namespace flag#248

Merged
ack-prow[bot] merged 2 commits into
aws-controllers-k8s:mainfrom
kprahulraj:feat/enable-cross-namespace
May 27, 2026
Merged

feat(runtime): Add --enable-cross-namespace flag#248
ack-prow[bot] merged 2 commits into
aws-controllers-k8s:mainfrom
kprahulraj:feat/enable-cross-namespace

Conversation

@kprahulraj
Copy link
Copy Markdown
Contributor

@kprahulraj kprahulraj commented May 22, 2026

Issue #, if available:

Description of changes:

Introduce a single CLI flag that controls all three categories of cross-namespace behavior: resource references, secret references, and field exports. It defaults to true with deprecation warnings to start with. It will default to false later in order to follow best security practice.

Changes:

  • Add --enable-cross-namespace CLI flag with default value true
  • Update ValidateCrossNamespaceReference to return (string, bool, error)
  • Add ValidateCrossNamespaceReferenceString convenience wrapper
  • Add ACK.CrossNamespaceOptInRequired condition type
  • Integrate cross-namespace check into field export reconciler
  • Refactor SecretValueFromReference to extract ownerNamespace (cross-namespace validation for secrets is handled by generated code in feat: Add cross-namespace reference validation to generated code code-generator#699)
  • Add table-driven unit tests for both helper functions
  • Update error messages to reference new flag name

Note: This PR builds on @sapphirew work in #239 and addresses review feedback from @cheeseandcereal :

  • Use nil-safe targetName in field export log line
  • Use lookup-or-create pattern in setCrossNsOptInRequiredCondition to avoid duplicate conditions
  • Return ownerNamespace (not empty string) on error for defensive fail-closed behavior

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Introduce a single CLI flag that controls all three categories of
cross-namespace behavior: resource references, secret references,
and field exports. Phase 1 defaults to true with deprecation warnings.

Changes:
- Rename --enable-cross-namespace-references to --enable-cross-namespace
- Change default from false to true (Phase 1 warning behavior)
- Update ValidateCrossNamespaceReference to return (string, bool, error)
- Add ValidateCrossNamespaceReferenceString convenience wrapper
- Add ACK.CrossNamespaceDeprecation condition type
- Integrate cross-namespace check into SecretValueFromReference
- Integrate cross-namespace check into field export reconciler
- Add table-driven unit tests for both helper functions
- Update error messages to reference new flag name
- Use nil-safe targetName variable in field export log line (comment aws-controllers-k8s#2)
- Use lookup-or-create pattern in setCrossNsOptInRequiredCondition to
  avoid duplicate conditions (comment aws-controllers-k8s#3)
- Return ownerNamespace instead of empty string on error in
  ValidateCrossNamespaceReference for defensive fail-closed behavior (comment aws-controllers-k8s#4)
- Update tests to match new return value on error path
@kprahulraj kprahulraj force-pushed the feat/enable-cross-namespace branch from b8985c1 to 9e63b3e Compare May 22, 2026 07:49
Copy link
Copy Markdown
Contributor

@knottnt knottnt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Runtime changes look good.

@ack-prow ack-prow Bot added the approved label May 22, 2026
Copy link
Copy Markdown
Contributor

@sapphirew sapphirew left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@ack-prow ack-prow Bot added the lgtm Indicates that a PR is ready to be merged. label May 27, 2026
@ack-prow
Copy link
Copy Markdown

ack-prow Bot commented May 27, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: knottnt, kprahulraj, sapphirew

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ack-prow ack-prow Bot merged commit 0e3ba69 into aws-controllers-k8s:main May 27, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved lgtm Indicates that a PR is ready to be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants