-
Notifications
You must be signed in to change notification settings - Fork 0
/
profile_remove.go
49 lines (37 loc) · 1.04 KB
/
profile_remove.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
package main
import (
"fmt"
"os"
"github.com/cipherboy/devbao/pkg/bao"
"github.com/urfave/cli/v2"
)
func BuildProfileRemoveCommand() *cli.Command {
c := &cli.Command{
Name: "remove",
Aliases: []string{"r"},
ArgsUsage: "<name> <profile>",
Usage: "remove a profile from the given instance",
Action: RunProfileRemoveCommand,
}
return c
}
func RunProfileRemoveCommand(cCtx *cli.Context) error {
if len(cCtx.Args().Slice()) != 2 {
return fmt.Errorf("missing required positional argument: instance name and profile\nUsage: devbao profile remove <name> <profile>")
}
name := cCtx.Args().First()
profile := cCtx.Args().Get(1)
node, err := bao.LoadNode(name)
if err != nil {
return fmt.Errorf("failed to load node: %w", err)
}
client, err := node.GetClient()
if err != nil {
return fmt.Errorf("failed to get client for node %v: %w", name, err)
}
warnings, err := bao.ProfileRemove(client, profile)
for index, warning := range warnings {
fmt.Fprintf(os.Stderr, " - [warning %d]: %v\n", index, warning)
}
return err
}