From aaa1db87603ff0d256fcdf883b613f53bb79b0be Mon Sep 17 00:00:00 2001 From: Tianxin Dong Date: Wed, 23 Mar 2022 17:16:39 +0800 Subject: [PATCH] Fix: fix workflow cli must have workflow in spec (#3469) Signed-off-by: FogDong --- references/cli/workflow.go | 12 ----------- references/cli/workflow_test.go | 36 --------------------------------- 2 files changed, 48 deletions(-) diff --git a/references/cli/workflow.go b/references/cli/workflow.go index 645044598..51e71deb2 100644 --- a/references/cli/workflow.go +++ b/references/cli/workflow.go @@ -70,9 +70,6 @@ func NewWorkflowSuspendCommand(c common.Args, ioStream cmdutil.IOStreams) *cobra if err != nil { return err } - if app.Spec.Workflow == nil { - return fmt.Errorf("the application must have workflow") - } if app.Status.Workflow == nil { return fmt.Errorf("the workflow in application is not running") } @@ -158,9 +155,6 @@ func NewWorkflowTerminateCommand(c common.Args, ioStream cmdutil.IOStreams) *cob if err != nil { return err } - if app.Spec.Workflow == nil { - return fmt.Errorf("the application must have workflow") - } if app.Status.Workflow == nil { return fmt.Errorf("the workflow in application is not running") } @@ -198,9 +192,6 @@ func NewWorkflowRestartCommand(c common.Args, ioStream cmdutil.IOStreams) *cobra if err != nil { return err } - if app.Spec.Workflow == nil { - return fmt.Errorf("the application must have workflow") - } if app.Status.Workflow == nil { return fmt.Errorf("the workflow in application is not running") } @@ -239,9 +230,6 @@ func NewWorkflowRollbackCommand(c common.Args, ioStream cmdutil.IOStreams) *cobr if err != nil { return err } - if app.Spec.Workflow == nil { - return fmt.Errorf("the application must have workflow") - } if app.Status.Workflow != nil && !app.Status.Workflow.Terminated && !app.Status.Workflow.Suspend && !app.Status.Workflow.Finished { return fmt.Errorf("can not rollback a running workflow") } diff --git a/references/cli/workflow_test.go b/references/cli/workflow_test.go index ff4bd3f4f..4500ac4dd 100644 --- a/references/cli/workflow_test.go +++ b/references/cli/workflow_test.go @@ -60,15 +60,6 @@ func TestWorkflowSuspend(t *testing.T) { "no app name specified": { expectedErr: fmt.Errorf("must specify application name"), }, - "no workflow in app": { - app: &v1beta1.Application{ - ObjectMeta: metav1.ObjectMeta{ - Name: "no-workflow", - Namespace: "default", - }, - }, - expectedErr: fmt.Errorf("the application must have workflow"), - }, "workflow not running": { app: &v1beta1.Application{ ObjectMeta: metav1.ObjectMeta{ @@ -260,15 +251,6 @@ func TestWorkflowTerminate(t *testing.T) { "no app name specified": { expectedErr: fmt.Errorf("must specify application name"), }, - "no workflow in app": { - app: &v1beta1.Application{ - ObjectMeta: metav1.ObjectMeta{ - Name: "no-workflow", - Namespace: "default", - }, - }, - expectedErr: fmt.Errorf("the application must have workflow"), - }, "workflow not running": { app: &v1beta1.Application{ ObjectMeta: metav1.ObjectMeta{ @@ -349,15 +331,6 @@ func TestWorkflowRestart(t *testing.T) { "no app name specified": { expectedErr: fmt.Errorf("must specify application name"), }, - "no workflow in app": { - app: &v1beta1.Application{ - ObjectMeta: metav1.ObjectMeta{ - Name: "no-workflow", - Namespace: "default", - }, - }, - expectedErr: fmt.Errorf("the application must have workflow"), - }, "workflow not running": { app: &v1beta1.Application{ ObjectMeta: metav1.ObjectMeta{ @@ -440,15 +413,6 @@ func TestWorkflowRollback(t *testing.T) { "no app name specified": { expectedErr: fmt.Errorf("must specify application name"), }, - "no workflow in app": { - app: &v1beta1.Application{ - ObjectMeta: metav1.ObjectMeta{ - Name: "no-workflow", - Namespace: "default", - }, - }, - expectedErr: fmt.Errorf("the application must have workflow"), - }, "workflow running": { app: &v1beta1.Application{ ObjectMeta: metav1.ObjectMeta{