MCPcopy Create free account
hub / github.com/crossplane-contrib/function-patch-and-transform / getBaseConnectionSecretRef

Function getBaseConnectionSecretRef

connection.go:152–170  ·  view source on GitHub ↗

getBaseConnectionSecretRef determines the base connection secret reference without any patches. This reference is generated with the following precedence: 1. xr.spec.writeConnectionSecretToRef - this is no longer automatically added to v2 XR schemas, but the community has been adding it manually, so

(xr *resource.Composite, input *v1beta1.WriteConnectionSecretToRef)

Source from the content-addressed store, hash-verified

150// then the whole ref will be used
151// 3. generate the reference from scratch, based on the XR name and namespace
152func getBaseConnectionSecretRef(xr *resource.Composite, input *v1beta1.WriteConnectionSecretToRef) xpv1.SecretReference {
153 // Check if XR author manually added writeConnectionSecretToRef to the XR's
154 // schema and just use that if it exists
155 xrRef := xr.Resource.GetWriteConnectionSecretToReference()
156 if xrRef != nil {
157 return *xrRef
158 }
159
160 // Use the input values if at least one of name or namespace has been provided
161 if input != nil && (input.Name != "" || input.Namespace != "") {
162 return xpv1.SecretReference{Name: input.Name, Namespace: input.Namespace}
163 }
164
165 // Nothing has been provided, so generate a default name using the name of the XR
166 return xpv1.SecretReference{
167 Name: xr.Resource.GetName() + "-connection",
168 Namespace: xr.Resource.GetNamespace(),
169 }
170}
171
172// applyConnectionSecretPatches applies all patches provided on the input to the
173// connection secret reference.

Callers 1

getConnectionSecretRefFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected