crossplane / crossplane/crossplane-tools

Support generating reference resolvers targeting multiple types

Open
#38 4 comments 1 reaction 0 assignees View on GitHub
enhancement wontfix
Dominant language
Go
Stars
37
Forks
38
PR merge metrics
No merged PRs in 30d

Description

### What problem are you facing?

It is currently not possible to generate `ResolveReferences` methods that target multiple suitable types even though there are cases in which this would be desirable.

A good example for this are references to [KMS CMKs](https://doc.crds.dev/github.com/crossplane/provider-aws/kms.aws.crossplane.io/Key/v1alpha1@v0.24.1) and [Aliases](https://doc.crds.dev/github.com/crossplane/provider-aws/kms.aws.crossplane.io/Alias/v1alpha1@v0.24.1) in AWS.

Either can be used as reference in a [SQS Queue's](https://doc.crds.dev/github.com/crossplane/provider-aws/sqs.aws.crossplane.io/Queue/v1beta1@v0.24.1) `kmsMasterKeyId` and Crossplane should support both.

### How could Crossplane help solve your problem?

Resolving of references to KMS Keys for Queues [has been implemented](https://github.com/crossplane/provider-aws/blob/master/apis/sqs/v1beta1/queue_types.go) in the following way:

```
// KMSMasterKeyID - The ID of an AWS-managed customer master key (CMK)
// ...
// +crossplane:generate:reference:type=github.com/crossplane/provider-aws/apis/kms/v1alpha1.Key
KMSMasterKeyID *string `json:"kmsMasterKeyId,omitempty"`
KMSMasterKeyIDRef *xpv1.Reference `json:"kmsMasterKeyIdRef,omitempty"`
KMSMasterKeyIDSelector *xpv1.Selector `json:"kmsMasterKeyIdSelector,omitempty"`
```

It would be absolutely fantastic if crossplane-tools would support listing multiple suitable types here, similar to:

```
// KMSMasterKeyID - The ID of an AWS-managed customer master key (CMK)
// ...
// +crossplane:generate:reference:type=github.com/crossplane/provider-aws/apis/kms/v1alpha1.Key
// +crossplane:generate:reference:type=github.com/crossplane/provider-aws/apis/kms/v1alpha1.Alias
KMSMasterKeyID *string `json:"kmsMasterKeyId,omitempty"`
KMSMasterKeyIDRef *xpv1.Reference `json:"kmsMasterKeyIdRef,omitempty"`
KMSMasterKeyIDSelector *xpv1.Selector `json:"kmsMasterKeyIdSelector,omitempty"`
```

If there are multiple suitable candidates users would use `matchLabels` and suitable matches to differentiate between these resources.

Thank you!

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.