@@ -1108,12 +1108,30 @@ func (sw *fakeSubResourceClient) Create(ctx context.Context, obj client.Object,
1108
1108
func (sw * fakeSubResourceClient ) Update (ctx context.Context , obj client.Object , opts ... client.SubResourceUpdateOption ) error {
1109
1109
updateOptions := client.SubResourceUpdateOptions {}
1110
1110
updateOptions .ApplyOptions (opts )
1111
-
1112
- body := obj
1113
- if updateOptions .SubResourceBody != nil {
1114
- body = updateOptions .SubResourceBody
1111
+ gvr , err := getGVRFromObject (obj , sw .client .scheme )
1112
+ if err != nil {
1113
+ return err
1114
+ }
1115
+ o , err := sw .client .tracker .Get (gvr , obj .GetNamespace (), obj .GetName ())
1116
+ if err != nil {
1117
+ return err
1118
+ }
1119
+ gvk , err := apiutil .GVKForObject (obj , sw .client .scheme )
1120
+ if err != nil {
1121
+ return err
1122
+ }
1123
+ body := o
1124
+ if sw .client .tracker .withStatusSubresource .Has (gvk ) {
1125
+ err := copyStatusFrom (obj , body )
1126
+ if err != nil {
1127
+ return err
1128
+ }
1129
+ }
1130
+ bodyObj := body .(client.Object )
1131
+ if bodyObj .GetResourceVersion () != obj .GetResourceVersion () {
1132
+ return apierrors .NewConflict (gvr .GroupResource (), obj .GetName (), fmt .Errorf ("resource version conflict" ))
1115
1133
}
1116
- return sw .client .update (body , true , & updateOptions .UpdateOptions )
1134
+ return sw .client .update (bodyObj , true , & updateOptions .UpdateOptions )
1117
1135
}
1118
1136
1119
1137
func (sw * fakeSubResourceClient ) Patch (ctx context.Context , obj client.Object , patch client.Patch , opts ... client.SubResourcePatchOption ) error {
0 commit comments