Skip to content

Commit

Permalink
Patch status with duck client (#604)
Browse files Browse the repository at this point in the history
Signed-off-by: Arnob kumar saha <[email protected]>
  • Loading branch information
ArnobKumarSaha authored Oct 23, 2024
1 parent 4c772eb commit 44ddb16
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
7 changes: 6 additions & 1 deletion client/duck/typed_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,11 @@ func (sw *typedStatusWriter) Patch(ctx context.Context, obj client.Object, patch
return sw.client.c.Status().Patch(ctx, obj, patch, opts...)
}

rawPatch, err := NewRawPatch(obj, patch)
if err != nil {
return err
}

ll, err := sw.client.c.Scheme().New(sw.client.rawGVK)
if err != nil {
return err
Expand All @@ -271,7 +276,7 @@ func (sw *typedStatusWriter) Patch(ctx context.Context, obj client.Object, patch
llo.SetNamespace(obj.GetNamespace())
llo.SetName(obj.GetName())
llo.SetLabels(obj.GetLabels())
return sw.client.c.Status().Patch(ctx, llo, patch, opts...)
return sw.client.c.Status().Patch(ctx, llo, rawPatch, opts...)
}

func (d *typedClient) SubResource(subResource string) client.SubResourceClient {
Expand Down
7 changes: 6 additions & 1 deletion client/duck/unstructured_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,12 +258,17 @@ func (sw *unstructuredStatusWriter) Patch(ctx context.Context, obj client.Object
return sw.client.c.Status().Patch(ctx, obj, patch, opts...)
}

rawPatch, err := NewRawPatch(obj, patch)
if err != nil {
return err
}

var llo unstructured.Unstructured
llo.GetObjectKind().SetGroupVersionKind(sw.client.rawGVK)
llo.SetNamespace(obj.GetNamespace())
llo.SetName(obj.GetName())
llo.SetLabels(obj.GetLabels())
return sw.client.c.Status().Patch(ctx, &llo, patch, opts...)
return sw.client.c.Status().Patch(ctx, &llo, rawPatch, opts...)
}

func (d *unstructuredClient) SubResource(subResource string) client.SubResourceClient {
Expand Down

0 comments on commit 44ddb16

Please sign in to comment.