@@ -885,11 +885,34 @@ func toggleFeatureGates(deployment *appsv1.Deployment, toToggle ...featuregate.F
885
885
awaitPredicates (deadline , w , deploymentReplicas (2 ), deploymentAvailable , deploymentReplicas (1 ))
886
886
}
887
887
888
+ var gvks = map [reflect.Type ]schema.GroupVersionKind {
889
+ reflect .TypeOf (& v1alpha1.ClusterServiceVersion {}): schema.GroupVersionKind {
890
+ Group : v1alpha1 .GroupName ,
891
+ Version : v1alpha1 .GroupVersion ,
892
+ Kind : v1alpha1 .ClusterServiceVersionKind ,
893
+ },
894
+ reflect .TypeOf (& v1alpha1.InstallPlan {}): schema.GroupVersionKind {
895
+ Group : v1alpha1 .GroupName ,
896
+ Version : v1alpha1 .GroupVersion ,
897
+ Kind : v1alpha1 .InstallPlanKind ,
898
+ },
899
+ }
900
+
888
901
type Object interface {
889
902
runtime.Object
890
903
metav1.Object
891
904
}
892
905
906
+ func SetDefaultGroupVersionKind (o Object ) {
907
+ gvk := o .GetObjectKind ().GroupVersionKind ()
908
+ if ! gvk .Empty () {
909
+ return
910
+ }
911
+ if gvk , ok := gvks [reflect .TypeOf (o )]; ok {
912
+ o .GetObjectKind ().SetGroupVersionKind (gvk )
913
+ }
914
+ }
915
+
893
916
// Apply returns a function that invokes a change func on an object and performs a server-side apply patch with the result and its status subresource.
894
917
// The given resource must be a pointer to a struct that specifies its Name, Namespace, APIVersion, and Kind at minimum.
895
918
// The given change function must be aunary, matching the signature: "func(<obj type>) error".
@@ -948,7 +971,7 @@ func Apply(obj Object, changeFunc interface{}) func() error {
948
971
if err := client .Get (bg , key , cp ); err != nil {
949
972
return err
950
973
}
951
- cp . GetObjectKind (). SetGroupVersionKind ( obj . GetObjectKind (). GroupVersionKind () )
974
+ SetDefaultGroupVersionKind ( cp )
952
975
cp .SetManagedFields (nil )
953
976
954
977
var (
@@ -970,7 +993,7 @@ func Apply(obj Object, changeFunc interface{}) func() error {
970
993
if err := client .Get (bg , key , cp ); err != nil {
971
994
return err
972
995
}
973
- cp . GetObjectKind (). SetGroupVersionKind ( obj . GetObjectKind (). GroupVersionKind () )
996
+ SetDefaultGroupVersionKind ( cp )
974
997
cp .SetManagedFields (nil )
975
998
976
999
if len (out ) != 1 {
0 commit comments