Make writeConnectionSecretToRef optional
https://github.com/crossplaneio/crossplane/issues/719 The resource claim reconciler (and API definitions) consider writeConnectionSecretToRef to be optional, but the managed resource reconciler fails if it is not specified. This change aligns the codebase on the reference being optional. Managed resources that do not specify a secret reference will provision successfully without publishing their connection details to a secret. Signed-off-by: Nic Cope <negz@rk0n.org>
This commit is contained in:
parent
e4d61ee280
commit
06b6b7dd87
|
@ -88,7 +88,7 @@ func NewAPIManagedConnectionPropagator(c client.Client, t runtime.ObjectTyper) *
|
|||
|
||||
// PropagateConnection details from the supplied resource to the supplied claim.
|
||||
func (a *APIManagedConnectionPropagator) PropagateConnection(ctx context.Context, cm Claim, mg Managed) error {
|
||||
// Either this resourace does not expose a connection secret, or this claim
|
||||
// Either this resource does not expose a connection secret, or this claim
|
||||
// does not want one.
|
||||
if mg.GetWriteConnectionSecretToReference().Name == "" || cm.GetWriteConnectionSecretToReference().Name == "" {
|
||||
return nil
|
||||
|
|
|
@ -68,6 +68,11 @@ func NewAPISecretPublisher(c client.Client, ot runtime.ObjectTyper) *APISecretPu
|
|||
// the supplied Managed resource. Applying is a no-op if the secret already
|
||||
// exists with the supplied ConnectionDetails.
|
||||
func (a *APISecretPublisher) PublishConnection(ctx context.Context, mg Managed, c ConnectionDetails) error {
|
||||
// This resource does not want to expose a connection secret.
|
||||
if mg.GetWriteConnectionSecretToReference().Name == "" {
|
||||
return nil
|
||||
}
|
||||
|
||||
s := ConnectionSecretFor(mg, MustGetKind(mg, a.typer))
|
||||
|
||||
err := util.CreateOrUpdate(ctx, a.client, s, func() error {
|
||||
|
|
|
@ -138,6 +138,12 @@ func TestAPISecretPublisher(t *testing.T) {
|
|||
args args
|
||||
want error
|
||||
}{
|
||||
"ResourceDoesNotPublishSecret": {
|
||||
args: args{
|
||||
ctx: context.Background(),
|
||||
mg: &MockManaged{},
|
||||
},
|
||||
},
|
||||
"ManagedSecretConflictError": {
|
||||
fields: fields{
|
||||
client: &test.MockClient{
|
||||
|
|
Loading…
Reference in New Issue