Skip to content

Commit

Permalink
Revert "fix: use resouce GVK and name instead of name"
Browse files Browse the repository at this point in the history
This reverts commit 8658d9e.
  • Loading branch information
Peefy committed May 6, 2024
1 parent a4a7089 commit 1faa314
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions pkg/resource/res.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,7 @@ func MatchResources(desired map[resource.Name]*resource.DesiredComposed, data []
// otherwise we lost something somewhere
for _, d := range data {
// PatchDesired
name := getName(&d)
if found, ok := desired[resource.Name(name)]; ok {
if found, ok := desired[resource.Name(d.GetName())]; ok {
if _, ok := matches[found]; !ok {
matches[found] = []map[string]interface{}{d.Object}
} else {
Expand Down Expand Up @@ -250,7 +249,7 @@ func AddResourcesTo(o any, opts *AddResourcesOptions) error {
// Resources
desired := val
for _, d := range opts.Data {
name := resource.Name(getName(&d))
name := resource.Name(d.GetName())
// If the value exists, merge its existing value with the patches
if v, ok := desired[name]; ok {
mergedData := merged(d.Object, v)
Expand Down Expand Up @@ -474,7 +473,10 @@ func ProcessResources(dxr *resource.Composite, oxr *resource.Composite, desired
meta.RemoveAnnotations(cd.Resource, AnnotationKeyReady)
}
// Patch desired with custom name from annotation or default to resource meta name.
name := getName(&cd.Resource.Unstructured)
name, found := cd.Resource.GetAnnotations()[AnnotationKeyCompositionResourceName]
if !found {
name = cd.Resource.GetName()
}
meta.RemoveAnnotations(cd.Resource, AnnotationKeyCompositionResourceName)
desired[resource.Name(name)] = cd
}
Expand All @@ -486,11 +488,3 @@ func ProcessResources(dxr *resource.Composite, oxr *resource.Composite, desired
result.setSuccessMsgs()
return result, nil
}

func getName(o *unstructured.Unstructured) string {
name, found := o.GetAnnotations()[AnnotationKeyCompositionResourceName]
if !found {
name = o.GetAPIVersion() + "-" + o.GetKind() + "-" + o.GetNamespace() + "-" + o.GetName()
}
return name
}

0 comments on commit 1faa314

Please sign in to comment.