mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-12-24 09:20:31 +00:00
e5d5ec8b47
closes #1743 fixes: setting secrets for own user namespace - create org in database - use orgID for org related APIs Co-authored-by: 6543 <6543@obermui.de>
49 lines
949 B
Go
49 lines
949 B
Go
package secret
|
|
|
|
import (
|
|
"github.com/urfave/cli/v2"
|
|
|
|
"github.com/woodpecker-ci/woodpecker/cli/common"
|
|
"github.com/woodpecker-ci/woodpecker/cli/internal"
|
|
)
|
|
|
|
var secretDeleteCmd = &cli.Command{
|
|
Name: "rm",
|
|
Usage: "remove a secret",
|
|
ArgsUsage: "[repo-id|repo-full-name]",
|
|
Action: secretDelete,
|
|
Flags: append(common.GlobalFlags,
|
|
&cli.BoolFlag{
|
|
Name: "global",
|
|
Usage: "global secret",
|
|
},
|
|
common.OrgFlag,
|
|
common.RepoFlag,
|
|
&cli.StringFlag{
|
|
Name: "name",
|
|
Usage: "secret name",
|
|
},
|
|
),
|
|
}
|
|
|
|
func secretDelete(c *cli.Context) error {
|
|
secretName := c.String("name")
|
|
|
|
client, err := internal.NewClient(c)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
global, orgID, repoID, err := parseTargetArgs(client, c)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
if global {
|
|
return client.GlobalSecretDelete(secretName)
|
|
}
|
|
if orgID != -1 {
|
|
return client.OrgSecretDelete(orgID, secretName)
|
|
}
|
|
return client.SecretDelete(repoID, secretName)
|
|
}
|