Skip to content

Commit

Permalink
Fix could not find WorkloadDefinition
Browse files Browse the repository at this point in the history
When WorkloadDefinition doesn't follow the pattern
<puraral-kind>.<resource-group> or there are different
workloadDefinitions pointing to the same workload Schema,
it will hit the issue of could not finding workloaddefinition.
Fix issue crossplane#207, feature crossplane#195.

Signed-off-by: zzxwill <[email protected]>
  • Loading branch information
zzxwill committed Sep 16, 2020
1 parent a760d93 commit e237e4d
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/oam/util/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ var (
const (
// TraitPrefixKey is prefix of trait name
TraitPrefixKey = "trait"
DefinitionAnnotation = "definition.oam.dev/name"
)

const (
Expand Down Expand Up @@ -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 <kind purals>.<group>
// 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 != "" {
Expand Down

0 comments on commit e237e4d

Please sign in to comment.