crossplane-runtime icon indicating copy to clipboard operation
crossplane-runtime copied to clipboard

Have ExternalConnector accept a smaller interface than resource.Managed

Open negz opened this issue 6 years ago • 1 comments

What problem are you facing?

The Generic Managed Resource Reconciler (GMRR) deals primarily with the resource.Managed interface, which is fairly large. Ideally it would use smaller interfaces, where possible.

type ExternalConnecter interface {
	Connect(ctx context.Context, mg Managed) (ExternalClient, error)
}

The Connect method above is one place we could easily use a smaller interface. All current Connect implementations don't actually use any of the methods of resource.Managed; they simply assert the resource.Managed to the concrete managed resource type they expect, get the provider it references and its secret, and return a client.

How could Crossplane help solve your problem?

func (f *Foo) GetProviderReference() *corev1.ObjectReference { return f.Spec.ProviderReference }
func (f *Foo) SetProviderReference(r *corev1.ObjectReference) { f.Spec.ProviderReference = r }

type ProviderReferencer interface {
    GetProviderReference() *corev1.ObjectReference
    SetProviderReference(r *corev1.ObjectReference)
}

type ExternalConnecter interface {
	Connect(ctx context.Context, pr ProviderReferencer) (ExternalClient, error)
}

Adding the above getters and setters to all managed resources would allow us to update the Connect methods to accept the above, much smaller interface.

negz avatar Sep 01 '19 07:09 negz

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Aug 13 '22 08:08 stale[bot]

Crossplane does not currently have enough maintainers to address every issue and pull request. This issue has been automatically marked as stale because it has had no activity in the last 90 days. It will be closed in 14 days if no further activity occurs. Leaving a comment starting with /fresh will mark this issue as not stale.

github-actions[bot] avatar Sep 05 '24 01:09 github-actions[bot]