Skip to content
This repository has been archived by the owner on Jun 8, 2022. It is now read-only.

get CRD by discovery mechanism instead of get plural #261

Merged
merged 4 commits into from
Oct 25, 2020

Conversation

wonderflow
Copy link
Member

@wonderflow wonderflow commented Oct 22, 2020

  1. use discovery mechanism to discovery definition name by using CRD name fix [Feature] Using K8s Discovery mechanism to get resource from GVK #202
  2. refactor the test, it's mass and I fixed them by refactoring.

@ryanzhang-oss
Copy link
Collaborator

Why is the build module changed? Is that even supposed to be checked-in?

@@ -230,35 +238,23 @@ func PassLabelAndAnnotation(parentObj oam.Object, childObj labelAnnotationObject
// the format of the definition of a resource is <kind plurals>.<group>
// Now the definition name of a resource could also be defined as `definition.oam.dev/name` in `metadata.annotations`
// typeLabel specified which Definition it is, if specified, will directly get definition from label.
func GetDefinitionName(u *unstructured.Unstructured, typeLabel string) string {
func GetDefinitionName(dm discoverymapper.DiscoveryMapper, u *unstructured.Unstructured, typeLabel string) (string, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know it's kinda late to change but it seems that it is better to make the dm a public variable in the package inside the init() function? In this way, we don't need to pass this around, all the caller of the utility functions shouldn't need to create a DiscoveryMapper. This is a pubic utility function that is actually used by other repros, this can break cross repo dependency.

@ryanzhang-oss ryanzhang-oss merged commit ae19408 into crossplane:master Oct 25, 2020
@wonderflow wonderflow deleted the fix-d branch October 25, 2020 02:21
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature] Using K8s Discovery mechanism to get resource from GVK
2 participants