2019-04-06 19:32:14 +00:00
|
|
|
package secret
|
|
|
|
|
2021-10-27 19:03:14 +00:00
|
|
|
import (
|
2022-08-15 18:10:13 +00:00
|
|
|
"strings"
|
|
|
|
|
2021-10-27 19:03:14 +00:00
|
|
|
"github.com/urfave/cli/v2"
|
|
|
|
|
|
|
|
"github.com/woodpecker-ci/woodpecker/cli/common"
|
2022-08-15 18:10:13 +00:00
|
|
|
"github.com/woodpecker-ci/woodpecker/cli/internal"
|
2021-10-27 19:03:14 +00:00
|
|
|
)
|
2019-04-06 19:32:14 +00:00
|
|
|
|
|
|
|
// Command exports the secret command.
|
2021-10-27 19:03:14 +00:00
|
|
|
var Command = &cli.Command{
|
2019-04-06 19:32:14 +00:00
|
|
|
Name: "secret",
|
|
|
|
Usage: "manage secrets",
|
2021-10-27 19:03:14 +00:00
|
|
|
Flags: common.GlobalFlags,
|
|
|
|
Subcommands: []*cli.Command{
|
2019-04-06 19:32:14 +00:00
|
|
|
secretCreateCmd,
|
|
|
|
secretDeleteCmd,
|
|
|
|
secretUpdateCmd,
|
|
|
|
secretInfoCmd,
|
|
|
|
secretListCmd,
|
|
|
|
},
|
|
|
|
}
|
2022-08-15 18:10:13 +00:00
|
|
|
|
|
|
|
func parseTargetArgs(c *cli.Context) (global bool, owner, name string, err error) {
|
|
|
|
if c.Bool("global") {
|
|
|
|
return true, "", "", nil
|
|
|
|
}
|
|
|
|
orgName := c.String("organization")
|
|
|
|
repoName := c.String("repository")
|
|
|
|
if orgName == "" && repoName == "" {
|
|
|
|
repoName = c.Args().First()
|
|
|
|
}
|
|
|
|
if orgName == "" && !strings.Contains(repoName, "/") {
|
|
|
|
orgName = repoName
|
|
|
|
}
|
|
|
|
if orgName != "" {
|
|
|
|
return false, orgName, "", err
|
|
|
|
}
|
|
|
|
owner, name, err = internal.ParseRepo(repoName)
|
|
|
|
if err != nil {
|
|
|
|
return false, "", "", err
|
|
|
|
}
|
|
|
|
return false, owner, name, nil
|
|
|
|
}
|