2019-04-06 21:32:14 +02:00
|
|
|
package repo
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
2021-10-27 21:03:14 +02:00
|
|
|
"github.com/urfave/cli/v2"
|
2021-10-12 09:25:13 +02:00
|
|
|
|
2021-10-27 21:03:14 +02:00
|
|
|
"github.com/woodpecker-ci/woodpecker/cli/common"
|
2021-09-21 16:36:41 +02:00
|
|
|
"github.com/woodpecker-ci/woodpecker/cli/internal"
|
2019-04-06 21:32:14 +02:00
|
|
|
)
|
|
|
|
|
2021-10-27 21:03:14 +02:00
|
|
|
var repoChownCmd = &cli.Command{
|
2019-04-06 21:32:14 +02:00
|
|
|
Name: "chown",
|
|
|
|
Usage: "assume ownership of a repository",
|
2023-06-13 01:07:52 +02:00
|
|
|
ArgsUsage: "<repo-id|repo-full-name>",
|
2019-04-06 21:32:14 +02:00
|
|
|
Action: repoChown,
|
2021-10-27 21:03:14 +02:00
|
|
|
Flags: common.GlobalFlags,
|
2019-04-06 21:32:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func repoChown(c *cli.Context) error {
|
2023-06-13 01:07:52 +02:00
|
|
|
repoIDOrFullName := c.Args().First()
|
|
|
|
client, err := internal.NewClient(c)
|
2019-04-06 21:32:14 +02:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2023-06-13 01:07:52 +02:00
|
|
|
repoID, err := internal.ParseRepo(client, repoIDOrFullName)
|
2019-04-06 21:32:14 +02:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2023-06-13 01:07:52 +02:00
|
|
|
repo, err := client.RepoChown(repoID)
|
|
|
|
if err != nil {
|
2019-04-06 21:32:14 +02:00
|
|
|
return err
|
|
|
|
}
|
2023-06-13 01:07:52 +02:00
|
|
|
|
|
|
|
fmt.Printf("Successfully assumed ownership of repository %s\n", repo.FullName)
|
2019-04-06 21:32:14 +02:00
|
|
|
return nil
|
|
|
|
}
|