Skip to content

Preserve v2 connection Secret reference across pipeline steps#299

Open
fabioaraujopt wants to merge 1 commit intocrossplane-contrib:mainfrom
fabioaraujopt:fix/sticky-v2-connection-secret-ref
Open

Preserve v2 connection Secret reference across pipeline steps#299
fabioaraujopt wants to merge 1 commit intocrossplane-contrib:mainfrom
fabioaraujopt:fix/sticky-v2-connection-secret-ref

Conversation

@fabioaraujopt
Copy link

Summary

  • Reuse the previously desired v2 connection Secret reference as the base when composing connection details in RunFunction
  • Keep existing precedence (XR spec.writeConnectionSecretToRef first) and preserve current behavior when no prior secret exists
  • Add regression tests for both helper-level precedence and end-to-end multi-step behavior

Why

In multi-step patch-and-transform pipelines, later steps that omit writeConnectionSecretToRef can unintentionally clobber a previously established non-empty namespace, especially for cluster-scoped XRs.

Closes #298.

Test plan

  • go test ./...
  • go mod tidy && git diff --exit-code go.mod go.sum

Notes

  • Commit is DCO signed (Signed-off-by: fabioaraujopt <fabioaraujoorg@gmail.com>).

Reuse the previously desired connection Secret reference as the base when composing v2 XR connection details in subsequent patch-and-transform steps, preventing accidental namespace clobbering while keeping explicit input and patch overrides intact.

Signed-off-by: fabioaraujopt <fabioaraujoorg@gmail.com>
Comment on lines +276 to +281
if dcd, ok := desired[composedResourceName]; ok && dcd != nil && dcd.Resource != nil {
existingConnectionSecretRef = &xpv1.SecretReference{
Name: dcd.Resource.GetName(),
Namespace: dcd.Resource.GetNamespace(),
}
}
Copy link
Collaborator

@phisco phisco Mar 13, 2026

Choose a reason for hiding this comment

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

could we get an empty namespace by mistake by a previous step? should we guard here for name != "" && namespace != ""?

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.

Preserve v2 connection Secret ref across patch-and-transform pipeline steps

2 participants