-
Notifications
You must be signed in to change notification settings - Fork 7
/
policy.go
35 lines (33 loc) · 1004 Bytes
/
policy.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
package command
import (
"github.com/lunarway/release-manager/cmd/hamctl/command/policy"
"github.com/lunarway/release-manager/internal/http"
"github.com/pkg/errors"
"github.com/spf13/cobra"
)
func NewPolicy(client *http.Client, service *string) *cobra.Command {
var command = &cobra.Command{
Use: "policy",
Short: "Manage release policies for services.",
// make sure that only valid args are applied and that at least one
// command is specified
Args: func(c *cobra.Command, args []string) error {
err := cobra.OnlyValidArgs(c, args)
if err != nil {
return err
}
if len(args) == 0 {
return errors.New("please specify a command.")
}
return nil
},
ValidArgs: []string{"apply", "list", "delete"},
Run: func(c *cobra.Command, args []string) {
c.HelpFunc()(c, args)
},
}
command.AddCommand(policy.NewApply(client, service))
command.AddCommand(policy.NewList(client, service))
command.AddCommand(policy.NewDelete(client, service))
return command
}