-
Notifications
You must be signed in to change notification settings - Fork 1
/
unpause.go
52 lines (43 loc) · 1.15 KB
/
unpause.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package pipelines
import (
"github.com/pkg/errors"
"github.com/spf13/cobra"
"github.com/cycloidio/cycloid-cli/cmd/cycloid/common"
"github.com/cycloidio/cycloid-cli/cmd/cycloid/internal"
"github.com/cycloidio/cycloid-cli/cmd/cycloid/middleware"
)
func NewUnpauseCommand() *cobra.Command {
var cmd = &cobra.Command{
Use: "unpause",
Short: "unpause a pipeline",
Example: `
# unpause pipeline my-project-env
cy --org my-org pipeline unpause --project my-project --env env
`,
RunE: unpause,
PreRunE: internal.CheckAPIAndCLIVersion,
}
common.RequiredPersistentFlag(common.WithFlagProject, cmd)
common.RequiredPersistentFlag(common.WithFlagEnv, cmd)
return cmd
}
func unpause(cmd *cobra.Command, args []string) error {
api := common.NewAPI()
m := middleware.NewMiddleware(api)
org, err := cmd.Flags().GetString("org")
if err != nil {
return err
}
project, err := cmd.Flags().GetString("project")
if err != nil {
return err
}
env, err := cmd.Flags().GetString("env")
if err != nil {
return err
}
if err := m.UnpausePipeline(org, project, env); err != nil {
return errors.Wrap(err, "unable to unpause pipeline")
}
return nil
}