You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
GVKForObject should handle multiple GVKs in Scheme gracefully
- If the user sets the GVK, make sure that's in the list of the GVK
returned from the Scheme.
- Always print out the multiple GVKs when erroring out
- Add more comments on where to find more information about this issue
Signed-off-by: Vince Prignano <[email protected]>
// If the base object has a GVK, check if it's in the list of GVKs before using it.
154
+
for_, gvk:=rangegvks {
155
+
ifgvk==currentGVK {
156
+
returngvk, nil
157
+
}
158
+
}
159
+
}
160
+
161
+
// This should only trigger for things like metav1.XYZ --
162
+
// normal versioned types should be fine.
163
+
//
164
+
// See https://github.com/kubernetes-sigs/controller-runtime/issues/362
165
+
// for more information.
149
166
return schema.GroupVersionKind{}, fmt.Errorf(
150
-
"multiple group-version-kinds associated with type %T, refusing to guess at one", obj)
167
+
"multiple GroupVersionKinds associated with type %T within the Scheme: this can happen when a type is registered for multiple GVKs at the same time, callers can either fix their type registration to only register it once, or specify the GroupVersionKind to use for object passed in; refusing to guess at one: %q", obj, gvks)
168
+
default:
169
+
// In any other case, we've found a single GVK for the object.
170
+
returngvks[0], nil
151
171
}
152
-
returngvks[0], nil
153
172
}
154
173
155
174
// RESTClientForGVK constructs a new rest.Interface capable of accessing the resource associated
0 commit comments