woodpecker/drone/org_secret_add.go

43 lines
693 B
Go
Raw Normal View History

2016-07-31 20:09:55 +00:00
package main
import (
"log"
"github.com/codegangsta/cli"
)
var orgSecretAddCmd = cli.Command{
Name: "add",
Usage: "adds a secret",
ArgsUsage: "[org] [key] [value]",
Action: func(c *cli.Context) {
if err := orgSecretAdd(c); err != nil {
log.Fatalln(err)
}
},
2016-10-20 00:13:21 +00:00
Flags: secretAddFlags(),
2016-07-31 20:09:55 +00:00
}
func orgSecretAdd(c *cli.Context) error {
2016-08-14 22:02:11 +00:00
if len(c.Args()) != 3 {
2016-07-31 20:09:55 +00:00
cli.ShowSubcommandHelp(c)
return nil
}
team := c.Args().First()
name := c.Args().Get(1)
value := c.Args().Get(2)
2016-10-20 00:13:21 +00:00
secret, err := secretParseCmd(name, value, c)
if err != nil {
return err
2016-07-31 20:09:55 +00:00
}
client, err := newClient(c)
if err != nil {
return err
}
return client.TeamSecretPost(team, secret)
}