-
Notifications
You must be signed in to change notification settings - Fork 1
/
pipelineEnable.go
58 lines (45 loc) · 1.24 KB
/
pipelineEnable.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
53
54
55
56
57
58
package pipeline
import (
"context"
"fmt"
"github.com/clintjedwards/gofer/internal/cli/cl"
proto "github.com/clintjedwards/gofer/proto/go"
"github.com/spf13/cobra"
"google.golang.org/grpc/metadata"
)
var cmdPipelineEnable = &cobra.Command{
Use: "enable <id>",
Short: "Enable pipeline",
Long: `Enable pipeline.
This restores a previously disabled pipeline.`,
Example: `$ gofer pipeline enable simple_test_pipeline`,
RunE: pipelineEnable,
Args: cobra.ExactArgs(1),
}
func init() {
CmdPipeline.AddCommand(cmdPipelineEnable)
}
func pipelineEnable(_ *cobra.Command, args []string) error {
id := args[0]
cl.State.Fmt.Print("Enabling pipeline")
conn, err := cl.State.Connect()
if err != nil {
cl.State.Fmt.PrintErr(err)
cl.State.Fmt.Finish()
return err
}
client := proto.NewGoferClient(conn)
md := metadata.Pairs("Authorization", "Bearer "+cl.State.Config.Token)
ctx := metadata.NewOutgoingContext(context.Background(), md)
_, err = client.EnablePipeline(ctx, &proto.EnablePipelineRequest{
NamespaceId: cl.State.Config.Namespace,
Id: id,
})
if err != nil {
cl.State.Fmt.PrintErr(fmt.Sprintf("could not enable pipeline: %v", err))
cl.State.Fmt.Finish()
return err
}
cl.State.Fmt.Finish()
return nil
}