use client.Patch for suspend/resume operations
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
This commit is contained in:
@@ -48,6 +48,7 @@ func init() {
|
||||
|
||||
type resumable interface {
|
||||
adapter
|
||||
copyable
|
||||
statusable
|
||||
setUnsuspended()
|
||||
successMessage() string
|
||||
@@ -97,10 +98,13 @@ func (resume resumeCommand) run(cmd *cobra.Command, args []string) error {
|
||||
|
||||
for i := 0; i < resume.list.len(); i++ {
|
||||
logger.Actionf("resuming %s %s in %s namespace", resume.humanKind, resume.list.resumeItem(i).asClientObject().GetName(), *kubeconfigArgs.Namespace)
|
||||
resume.list.resumeItem(i).setUnsuspended()
|
||||
if err := kubeClient.Update(ctx, resume.list.resumeItem(i).asClientObject()); err != nil {
|
||||
obj := resume.list.resumeItem(i)
|
||||
patch := client.MergeFrom(obj.deepCopyClientObject())
|
||||
obj.setUnsuspended()
|
||||
if err := kubeClient.Patch(ctx, obj.asClientObject(), patch); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
logger.Successf("%s resumed", resume.humanKind)
|
||||
|
||||
namespacedName := types.NamespacedName{
|
||||
|
||||
@@ -46,6 +46,7 @@ func init() {
|
||||
|
||||
type suspendable interface {
|
||||
adapter
|
||||
copyable
|
||||
isSuspended() bool
|
||||
setSuspended()
|
||||
}
|
||||
@@ -94,8 +95,11 @@ func (suspend suspendCommand) run(cmd *cobra.Command, args []string) error {
|
||||
|
||||
for i := 0; i < suspend.list.len(); i++ {
|
||||
logger.Actionf("suspending %s %s in %s namespace", suspend.humanKind, suspend.list.item(i).asClientObject().GetName(), *kubeconfigArgs.Namespace)
|
||||
suspend.list.item(i).setSuspended()
|
||||
if err := kubeClient.Update(ctx, suspend.list.item(i).asClientObject()); err != nil {
|
||||
|
||||
obj := suspend.list.item(i)
|
||||
patch := client.MergeFrom(obj.deepCopyClientObject())
|
||||
obj.setSuspended()
|
||||
if err := kubeClient.Patch(ctx, obj.asClientObject(), patch); err != nil {
|
||||
return err
|
||||
}
|
||||
logger.Successf("%s suspended", suspend.humanKind)
|
||||
|
||||
Reference in New Issue
Block a user