harness-drone/drone/global_secret_add.go

34 lines
577 B
Go
Raw Normal View History

2016-10-20 00:13:21 +00:00
package main
2017-03-16 10:14:02 +00:00
import "github.com/urfave/cli"
2016-10-20 00:13:21 +00:00
var globalSecretAddCmd = cli.Command{
Name: "add",
Usage: "adds a secret",
ArgsUsage: "[key] [value]",
2017-03-16 10:14:02 +00:00
Action: globalSecretAdd,
Flags: secretAddFlags(),
2016-10-20 00:13:21 +00:00
}
func globalSecretAdd(c *cli.Context) error {
if len(c.Args()) != 2 {
cli.ShowSubcommandHelp(c)
return nil
}
name := c.Args().First()
value := c.Args().Get(1)
secret, err := secretParseCmd(name, value, c)
if err != nil {
return err
}
client, err := newClient(c)
if err != nil {
return err
}
return client.GlobalSecretPost(secret)
}