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)
| 150 | // then the whole ref will be used |
| 151 | // 3. generate the reference from scratch, based on the XR name and namespace |
| 152 | func 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. |
no outgoing calls
no test coverage detected