mirror of
https://github.com/storytold/irsa-manager.git
synced 2026-10-19 07:43:17 +00:00
manage status
This commit is contained in:
@@ -6,32 +6,18 @@ import (
|
||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||
)
|
||||
|
||||
func (h KubernetesClient) Apply(ctx context.Context, obj client.Object) error {
|
||||
func (c KubernetesClient) Apply(ctx context.Context, obj client.Object) error {
|
||||
opts := []client.PatchOption{
|
||||
client.ForceOwnership,
|
||||
client.FieldOwner(h.owner.Field),
|
||||
client.FieldOwner(c.owner.Field),
|
||||
}
|
||||
u, err := h.toUnstructured(obj)
|
||||
u, err := c.toUnstructured(obj)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = h.client.Patch(ctx, u, client.Apply, opts...)
|
||||
err = c.client.Patch(ctx, u, client.Apply, opts...)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (h KubernetesClient) PatchStatus(ctx context.Context, obj client.Object) error {
|
||||
opts := &client.SubResourcePatchOptions{
|
||||
PatchOptions: client.PatchOptions{
|
||||
FieldManager: h.owner.Field,
|
||||
},
|
||||
}
|
||||
u, err := h.toUnstructured(obj)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return h.client.Status().Patch(ctx, u, client.Apply, opts)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user