mirror of
https://github.com/helm/helm.git
synced 2026-05-28 04:35:48 -04:00
Merge pull request #12581 from Nordix/considerAllGroupVersionKind
Consider full GroupVersionKind when matching resources
This commit is contained in:
commit
de745ea34b
2 changed files with 40 additions and 1 deletions
|
|
@ -81,5 +81,5 @@ func (r ResourceList) Intersect(rs ResourceList) ResourceList {
|
|||
|
||||
// isMatchingInfo returns true if infos match on Name and GroupVersionKind.
|
||||
func isMatchingInfo(a, b *resource.Info) bool {
|
||||
return a.Name == b.Name && a.Namespace == b.Namespace && a.Mapping.GroupVersionKind.Kind == b.Mapping.GroupVersionKind.Kind && a.Mapping.GroupVersionKind.Group == b.Mapping.GroupVersionKind.Group
|
||||
return a.Name == b.Name && a.Namespace == b.Namespace && a.Mapping.GroupVersionKind == b.Mapping.GroupVersionKind
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,3 +59,42 @@ func TestResourceList(t *testing.T) {
|
|||
t.Error("expected intersect to return bar")
|
||||
}
|
||||
}
|
||||
|
||||
func TestIsMatchingInfo(t *testing.T) {
|
||||
gvk := schema.GroupVersionKind{Group: "group1", Version: "version1", Kind: "pod"}
|
||||
resourceInfo := resource.Info{Name: "name1", Namespace: "namespace1", Mapping: &meta.RESTMapping{GroupVersionKind: gvk}}
|
||||
|
||||
gvkDiffGroup := schema.GroupVersionKind{Group: "diff", Version: "version1", Kind: "pod"}
|
||||
resourceInfoDiffGroup := resource.Info{Name: "name1", Namespace: "namespace1", Mapping: &meta.RESTMapping{GroupVersionKind: gvkDiffGroup}}
|
||||
if isMatchingInfo(&resourceInfo, &resourceInfoDiffGroup) {
|
||||
t.Error("expected resources not equal")
|
||||
}
|
||||
|
||||
gvkDiffVersion := schema.GroupVersionKind{Group: "group1", Version: "diff", Kind: "pod"}
|
||||
resourceInfoDiffVersion := resource.Info{Name: "name1", Namespace: "namespace1", Mapping: &meta.RESTMapping{GroupVersionKind: gvkDiffVersion}}
|
||||
if isMatchingInfo(&resourceInfo, &resourceInfoDiffVersion) {
|
||||
t.Error("expected resources not equal")
|
||||
}
|
||||
|
||||
gvkDiffKind := schema.GroupVersionKind{Group: "group1", Version: "version1", Kind: "deployment"}
|
||||
resourceInfoDiffKind := resource.Info{Name: "name1", Namespace: "namespace1", Mapping: &meta.RESTMapping{GroupVersionKind: gvkDiffKind}}
|
||||
if isMatchingInfo(&resourceInfo, &resourceInfoDiffKind) {
|
||||
t.Error("expected resources not equal")
|
||||
}
|
||||
|
||||
resourceInfoDiffName := resource.Info{Name: "diff", Namespace: "namespace1", Mapping: &meta.RESTMapping{GroupVersionKind: gvk}}
|
||||
if isMatchingInfo(&resourceInfo, &resourceInfoDiffName) {
|
||||
t.Error("expected resources not equal")
|
||||
}
|
||||
|
||||
resourceInfoDiffNamespace := resource.Info{Name: "name1", Namespace: "diff", Mapping: &meta.RESTMapping{GroupVersionKind: gvk}}
|
||||
if isMatchingInfo(&resourceInfo, &resourceInfoDiffNamespace) {
|
||||
t.Error("expected resources not equal")
|
||||
}
|
||||
|
||||
gvkEqual := schema.GroupVersionKind{Group: "group1", Version: "version1", Kind: "pod"}
|
||||
resourceInfoEqual := resource.Info{Name: "name1", Namespace: "namespace1", Mapping: &meta.RESTMapping{GroupVersionKind: gvkEqual}}
|
||||
if !isMatchingInfo(&resourceInfo, &resourceInfoEqual) {
|
||||
t.Error("expected resources to be equal")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue