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

Function composeConnectionSecret

connection.go:96–124  ·  view source on GitHub ↗

composeConnectionSecret creates a Secret composed resource containing the provided connection details.

(xr *resource.Composite, details resource.ConnectionDetails, ref *v1beta1.WriteConnectionSecretToRef)

Source from the content-addressed store, hash-verified

94// composeConnectionSecret creates a Secret composed resource containing the
95// provided connection details.
96func composeConnectionSecret(xr *resource.Composite, details resource.ConnectionDetails, ref *v1beta1.WriteConnectionSecretToRef) (*resource.DesiredComposed, error) {
97 if len(details) == 0 {
98 return nil, nil
99 }
100
101 secret := composed.New()
102 secret.SetAPIVersion("v1")
103 secret.SetKind("Secret")
104
105 secretRef, err := getConnectionSecretRef(xr, ref)
106 if err != nil {
107 return nil, errors.Wrap(err, "cannot generate connection secret reference")
108 }
109 secret.SetName(secretRef.Name)
110 secret.SetNamespace(secretRef.Namespace)
111
112 if err := secret.SetValue("data", details); err != nil {
113 return nil, errors.Wrap(err, "cannot set connection secret data")
114 }
115
116 if err := secret.SetValue("type", xpresource.SecretTypeConnection); err != nil {
117 return nil, errors.Wrap(err, "cannot set connection secret type")
118 }
119
120 return &resource.DesiredComposed{
121 Resource: secret,
122 Ready: resource.ReadyTrue,
123 }, nil
124}
125
126// getConnectionSecretRef creates a connection secret reference from the given
127// XR and input. The patches for the reference will be applied before the

Callers 1

RunFunctionMethod · 0.85

Calls 1

getConnectionSecretRefFunction · 0.85

Tested by

no test coverage detected