2019-04-06 19:32:14 +00:00
|
|
|
package repo
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
2021-10-27 19:03:14 +00:00
|
|
|
"github.com/urfave/cli/v2"
|
2021-10-12 07:25:13 +00:00
|
|
|
|
2021-10-27 19:03:14 +00:00
|
|
|
"github.com/woodpecker-ci/woodpecker/cli/common"
|
2021-10-12 07:25:13 +00:00
|
|
|
"github.com/woodpecker-ci/woodpecker/cli/internal"
|
2019-04-06 19:32:14 +00:00
|
|
|
)
|
|
|
|
|
2021-10-27 19:03:14 +00:00
|
|
|
var repoRemoveCmd = &cli.Command{
|
2019-04-06 19:32:14 +00:00
|
|
|
Name: "rm",
|
|
|
|
Usage: "remove a repository",
|
2023-06-12 23:07:52 +00:00
|
|
|
ArgsUsage: "<repo-id|repo-full-name>",
|
2019-04-06 19:32:14 +00:00
|
|
|
Action: repoRemove,
|
2021-10-27 19:03:14 +00:00
|
|
|
Flags: common.GlobalFlags,
|
2019-04-06 19:32:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func repoRemove(c *cli.Context) error {
|
2023-06-12 23:07:52 +00:00
|
|
|
repoIDOrFullName := c.Args().First()
|
|
|
|
client, err := internal.NewClient(c)
|
2019-04-06 19:32:14 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2023-06-12 23:07:52 +00:00
|
|
|
repoID, err := internal.ParseRepo(client, repoIDOrFullName)
|
2019-04-06 19:32:14 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2023-06-12 23:07:52 +00:00
|
|
|
if err := client.RepoDel(repoID); err != nil {
|
2019-04-06 19:32:14 +00:00
|
|
|
return err
|
|
|
|
}
|
2023-06-12 23:07:52 +00:00
|
|
|
fmt.Printf("Successfully removed repository %s\n", repoIDOrFullName)
|
2019-04-06 19:32:14 +00:00
|
|
|
return nil
|
|
|
|
}
|