diff --git a/pkg/oam/util/helper.go b/pkg/oam/util/helper.go index 3238a853..88f669fb 100644 --- a/pkg/oam/util/helper.go +++ b/pkg/oam/util/helper.go @@ -39,6 +39,7 @@ var ( const ( // TraitPrefixKey is prefix of trait name TraitPrefixKey = "trait" + DefinitionAnnotation = "definition.oam.dev/name" ) const ( @@ -226,7 +227,11 @@ func PassLabelAndAnnotation(parentObj oam.Object, childObj labelAnnotationObject // GetCRDName return the CRD name of any resources // the format of the CRD of a resource is . +// Now the CRD name of a resource could also be defined as `metadata.annotations.definition.oam.dev/name` func GetCRDName(u *unstructured.Unstructured) string { + if crdName, ok := u.GetAnnotations()[DefinitionAnnotation]; ok { + return crdName + } group, _ := APIVersion2GroupVersion(u.GetAPIVersion()) resources := []string{Kind2Resource(u.GetKind())} if group != "" {