@@ -289,40 +289,45 @@ func (c *client) List(ctx context.Context, obj ObjectList, opts ...ListOption) e
289289}
290290
291291// Status implements client.StatusClient.
292- func (c * client ) Status () StatusWriter {
293- return & statusWriter {client : c }
292+ func (c * client ) Status () SubResourceWriter {
293+ return & subResourceWriter {client : c , subResource : "status" }
294294}
295295
296- // statusWriter is client.StatusWriter that writes status subresource.
297- type statusWriter struct {
298- client * client
296+ func (c * client ) SubResource (subResource string ) SubResourceWriter {
297+ return & subResourceWriter {client : c , subResource : subResource }
299298}
300299
301- // ensure statusWriter implements client.StatusWriter.
302- var _ StatusWriter = & statusWriter {}
300+ // subResourceWriter is client.SubResourceWriter that writes to subresources.
301+ type subResourceWriter struct {
302+ client * client
303+ subResource string
304+ }
305+
306+ // ensure subResourceWriter implements client.SubResourceWriter.
307+ var _ SubResourceWriter = & subResourceWriter {}
303308
304- // Update implements client.StatusWriter .
305- func (sw * statusWriter ) Update (ctx context.Context , obj Object , opts ... UpdateOption ) error {
309+ // Update implements client.SubResourceWriter .
310+ func (sw * subResourceWriter ) Update (ctx context.Context , obj Object , opts ... UpdateOption ) error {
306311 defer sw .client .resetGroupVersionKind (obj , obj .GetObjectKind ().GroupVersionKind ())
307312 switch obj .(type ) {
308313 case * unstructured.Unstructured :
309- return sw .client .unstructuredClient .UpdateStatus (ctx , obj , opts ... )
314+ return sw .client .unstructuredClient .UpdateSubResource (ctx , obj , sw . subResource , opts ... )
310315 case * metav1.PartialObjectMetadata :
311316 return fmt .Errorf ("cannot update status using only metadata -- did you mean to patch?" )
312317 default :
313- return sw .client .typedClient .UpdateStatus (ctx , obj , opts ... )
318+ return sw .client .typedClient .UpdateSubResource (ctx , obj , sw . subResource , opts ... )
314319 }
315320}
316321
317- // Patch implements client.Client .
318- func (sw * statusWriter ) Patch (ctx context.Context , obj Object , patch Patch , opts ... PatchOption ) error {
322+ // Patch implements client.SubResourceWriter .
323+ func (sw * subResourceWriter ) Patch (ctx context.Context , obj Object , patch Patch , opts ... PatchOption ) error {
319324 defer sw .client .resetGroupVersionKind (obj , obj .GetObjectKind ().GroupVersionKind ())
320325 switch obj .(type ) {
321326 case * unstructured.Unstructured :
322- return sw .client .unstructuredClient .PatchStatus (ctx , obj , patch , opts ... )
327+ return sw .client .unstructuredClient .PatchSubResource (ctx , obj , sw . subResource , patch , opts ... )
323328 case * metav1.PartialObjectMetadata :
324- return sw .client .metadataClient .PatchStatus (ctx , obj , patch , opts ... )
329+ return sw .client .metadataClient .PatchSubResource (ctx , obj , sw . subResource , patch , opts ... )
325330 default :
326- return sw .client .typedClient .PatchStatus (ctx , obj , patch , opts ... )
331+ return sw .client .typedClient .PatchSubResource (ctx , obj , sw . subResource , patch , opts ... )
327332 }
328333}
0 commit comments