Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
support duck create
Browse files Browse the repository at this point in the history
  • Loading branch information
Rasheed Abdul-Aziz committed Nov 2, 2023
1 parent 6077b10 commit 4131229
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion duck/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,12 @@ func (c *duckAwareClientWrapper) Create(ctx context.Context, obj client.Object,
return c.client.Create(ctx, obj, opts...)
}

return fmt.Errorf("Create is not supported for the duck typed objects")
uObj, err := runtime.DefaultUnstructuredConverter.ToUnstructured(obj)
if err != nil {
return err
}
u := &unstructured.Unstructured{Object: uObj}
return c.client.Create(ctx, u, opts...)
}

func (c *duckAwareClientWrapper) Update(ctx context.Context, obj client.Object, opts ...client.UpdateOption) error {
Expand Down

0 comments on commit 4131229

Please sign in to comment.