Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃悰 Preserve unstructured object GVKs in cache.Options.ByObject #2246

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions pkg/cache/cache.go
Expand Up @@ -481,6 +481,7 @@ func convertToByObject(in map[schema.GroupVersionKind]internal.InformersOptsByGV
if !ok {
return nil, fmt.Errorf("object %T for GVK %q does not implement client.Object", obj, gvk)
}
cObj.GetObjectKind().SetGroupVersionKind(gvk)
out[cObj] = ByObject{
Field: opts.Selector.Field,
Label: opts.Selector.Label,
Expand Down
17 changes: 17 additions & 0 deletions pkg/cache/cache_unit_test.go
Expand Up @@ -126,6 +126,23 @@ var _ = Describe("cache.inheritFrom", func() {
Expect(checkError(specified.inheritFrom(inherited)).Namespaces).To(Equal(specified.Namespaces))
})
})
Context("ByObject", func() {
It("maintains GVKs of unstructured ByObject keys", func() {
gvk := gv.WithKind("Unstructured")
obj := &unstructured.Unstructured{}
obj.SetGroupVersionKind(gvk)
specified.Scheme = coreScheme
specified.Scheme.AddKnownTypeWithName(gvk, obj)
specified.ByObject = map[client.Object]ByObject{
obj: {},
}
byObject := checkError(specified.inheritFrom(inherited)).ByObject
Expect(byObject).To(HaveLen(1))
for obj := range byObject {
Expect(obj.GetObjectKind().GroupVersionKind()).To(Equal(gvk))
}
})
})
Context("SelectorsByObject", func() {
It("is unchanged when specified and inherited are unset", func() {
Expect(checkError(specified.inheritFrom(inherited)).ByObject).To(HaveLen(0))
Expand Down