2016-05-06 17:59:36 +00:00
|
|
|
package main
|
|
|
|
|
2017-03-16 10:14:02 +00:00
|
|
|
import "github.com/urfave/cli"
|
2016-05-06 17:59:36 +00:00
|
|
|
|
|
|
|
var secretAddCmd = cli.Command{
|
|
|
|
Name: "add",
|
|
|
|
Usage: "adds a secret",
|
|
|
|
ArgsUsage: "[repo] [key] [value]",
|
2017-03-16 10:14:02 +00:00
|
|
|
Action: secretAdd,
|
|
|
|
Flags: secretAddFlags(),
|
2016-05-06 17:59:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func secretAdd(c *cli.Context) error {
|
|
|
|
repo := c.Args().First()
|
|
|
|
owner, name, err := parseRepo(repo)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
tail := c.Args().Tail()
|
|
|
|
if len(tail) != 2 {
|
|
|
|
cli.ShowSubcommandHelp(c)
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2016-10-20 00:13:21 +00:00
|
|
|
secret, err := secretParseCmd(tail[0], tail[1], c)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
2016-05-06 17:59:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
client, err := newClient(c)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
return client.SecretPost(owner, name, secret)
|
|
|
|
}
|