mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-12-25 01:40:30 +00:00
33 lines
577 B
Go
33 lines
577 B
Go
package main
|
|
|
|
import "github.com/urfave/cli"
|
|
|
|
var globalSecretAddCmd = cli.Command{
|
|
Name: "add",
|
|
Usage: "adds a secret",
|
|
ArgsUsage: "[key] [value]",
|
|
Action: globalSecretAdd,
|
|
Flags: secretAddFlags(),
|
|
}
|
|
|
|
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)
|
|
}
|