Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 24 additions & 3 deletions cmd/garm-cli/cmd/enterprise.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,14 @@ var enterpriseShowCmd = &cobra.Command{
if len(args) > 1 {
return fmt.Errorf("too many arguments")
}

enterpriseID, err := resolveEnterprise(args[0], enterpriseEndpoint)
if err != nil {
return err
}

showEnterpriseReq := apiClientEnterprises.NewGetEnterpriseParams()
showEnterpriseReq.EnterpriseID = args[0]
showEnterpriseReq.EnterpriseID = enterpriseID
response, err := apiCli.Enterprises.GetEnterprise(showEnterpriseReq, authToken)
if err != nil {
return err
Expand All @@ -139,8 +145,14 @@ var enterpriseDeleteCmd = &cobra.Command{
if len(args) > 1 {
return fmt.Errorf("too many arguments")
}

enterpriseID, err := resolveEnterprise(args[0], enterpriseEndpoint)
if err != nil {
return err
}

deleteEnterpriseReq := apiClientEnterprises.NewDeleteEnterpriseParams()
deleteEnterpriseReq.EnterpriseID = args[0]
deleteEnterpriseReq.EnterpriseID = enterpriseID
if err := apiCli.Enterprises.DeleteEnterprise(deleteEnterpriseReq, authToken); err != nil {
return err
}
Expand All @@ -165,13 +177,18 @@ var enterpriseUpdateCmd = &cobra.Command{
if len(args) > 1 {
return fmt.Errorf("too many arguments")
}
enterpriseID, err := resolveEnterprise(args[0], enterpriseEndpoint)
if err != nil {
return err
}

updateEnterpriseReq := apiClientEnterprises.NewUpdateEnterpriseParams()
updateEnterpriseReq.Body = params.UpdateEntityParams{
WebhookSecret: repoWebhookSecret,
CredentialsName: repoCreds,
PoolBalancerType: params.PoolBalancerType(poolBalancerType),
}
updateEnterpriseReq.EnterpriseID = args[0]
updateEnterpriseReq.EnterpriseID = enterpriseID
response, err := apiCli.Enterprises.UpdateEnterprise(updateEnterpriseReq, authToken)
if err != nil {
return err
Expand All @@ -196,6 +213,10 @@ func init() {
enterpriseUpdateCmd.Flags().StringVar(&enterpriseWebhookSecret, "webhook-secret", "", "The webhook secret for this enterprise")
enterpriseUpdateCmd.Flags().StringVar(&enterpriseCreds, "credentials", "", "Credentials name. See credentials list.")
enterpriseUpdateCmd.Flags().StringVar(&poolBalancerType, "pool-balancer-type", "", "The balancing strategy to use when creating runners in pools matching requested labels.")
enterpriseUpdateCmd.Flags().StringVar(&enterpriseEndpoint, "endpoint", "", "When using the name of the enterprise, the endpoint must be specified when multiple enterprises with the same name exist.")

enterpriseDeleteCmd.Flags().StringVar(&enterpriseEndpoint, "endpoint", "", "When using the name of the enterprise, the endpoint must be specified when multiple enterprises with the same name exist.")
enterpriseShowCmd.Flags().StringVar(&enterpriseEndpoint, "endpoint", "", "When using the name of the enterprise, the endpoint must be specified when multiple enterprises with the same name exist.")

enterpriseCmd.AddCommand(
enterpriseListCmd,
Expand Down
57 changes: 49 additions & 8 deletions cmd/garm-cli/cmd/organization.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,13 @@ var orgWebhookInstallCmd = &cobra.Command{
return fmt.Errorf("too many arguments")
}

orgID, err := resolveOrganization(args[0], orgEndpoint)
if err != nil {
return err
}

installWebhookReq := apiClientOrgs.NewInstallOrgWebhookParams()
installWebhookReq.OrgID = args[0]
installWebhookReq.OrgID = orgID
installWebhookReq.Body.InsecureSSL = insecureOrgWebhook
installWebhookReq.Body.WebhookEndpointType = params.WebhookEndpointDirect

Expand Down Expand Up @@ -105,9 +110,12 @@ var orgHookInfoShowCmd = &cobra.Command{
if len(args) > 1 {
return fmt.Errorf("too many arguments")
}

orgID, err := resolveOrganization(args[0], orgEndpoint)
if err != nil {
return err
}
showWebhookInfoReq := apiClientOrgs.NewGetOrgWebhookInfoParams()
showWebhookInfoReq.OrgID = args[0]
showWebhookInfoReq.OrgID = orgID

response, err := apiCli.Organizations.GetOrgWebhookInfo(showWebhookInfoReq, authToken)
if err != nil {
Expand All @@ -134,10 +142,15 @@ var orgWebhookUninstallCmd = &cobra.Command{
return fmt.Errorf("too many arguments")
}

orgID, err := resolveOrganization(args[0], orgEndpoint)
if err != nil {
return err
}

uninstallWebhookReq := apiClientOrgs.NewUninstallOrgWebhookParams()
uninstallWebhookReq.OrgID = args[0]
uninstallWebhookReq.OrgID = orgID

err := apiCli.Organizations.UninstallOrgWebhook(uninstallWebhookReq, authToken)
err = apiCli.Organizations.UninstallOrgWebhook(uninstallWebhookReq, authToken)
if err != nil {
return err
}
Expand Down Expand Up @@ -216,13 +229,19 @@ var orgUpdateCmd = &cobra.Command{
if len(args) > 1 {
return fmt.Errorf("too many arguments")
}

orgID, err := resolveOrganization(args[0], orgEndpoint)
if err != nil {
return err
}

updateOrgReq := apiClientOrgs.NewUpdateOrgParams()
updateOrgReq.Body = params.UpdateEntityParams{
WebhookSecret: orgWebhookSecret,
CredentialsName: orgCreds,
PoolBalancerType: params.PoolBalancerType(poolBalancerType),
}
updateOrgReq.OrgID = args[0]
updateOrgReq.OrgID = orgID
response, err := apiCli.Organizations.UpdateOrg(updateOrgReq, authToken)
if err != nil {
return err
Expand Down Expand Up @@ -270,8 +289,14 @@ var orgShowCmd = &cobra.Command{
if len(args) > 1 {
return fmt.Errorf("too many arguments")
}

orgID, err := resolveOrganization(args[0], orgEndpoint)
if err != nil {
return err
}

showOrgReq := apiClientOrgs.NewGetOrgParams()
showOrgReq.OrgID = args[0]
showOrgReq.OrgID = orgID
response, err := apiCli.Organizations.GetOrg(showOrgReq, authToken)
if err != nil {
return err
Expand All @@ -297,8 +322,14 @@ var orgDeleteCmd = &cobra.Command{
if len(args) > 1 {
return fmt.Errorf("too many arguments")
}

orgID, err := resolveOrganization(args[0], orgEndpoint)
if err != nil {
return err
}

deleteOrgReq := apiClientOrgs.NewDeleteOrgParams()
deleteOrgReq.OrgID = args[0]
deleteOrgReq.OrgID = orgID
deleteOrgReq.KeepWebhook = &keepOrgWebhook
if err := apiCli.Organizations.DeleteOrg(deleteOrgReq, authToken); err != nil {
return err
Expand Down Expand Up @@ -326,12 +357,22 @@ func init() {
orgAddCmd.MarkFlagRequired("name") //nolint

orgDeleteCmd.Flags().BoolVar(&keepOrgWebhook, "keep-webhook", false, "Do not delete any existing webhook when removing the organization from GARM.")
orgDeleteCmd.Flags().StringVar(&orgEndpoint, "endpoint", "", "When using the name of the org, the endpoint must be specified when multiple organizations with the same name exist.")

orgShowCmd.Flags().StringVar(&orgEndpoint, "endpoint", "", "When using the name of the org, the endpoint must be specified when multiple organizations with the same name exist.")

orgUpdateCmd.Flags().StringVar(&orgWebhookSecret, "webhook-secret", "", "The webhook secret for this organization")
orgUpdateCmd.Flags().StringVar(&orgCreds, "credentials", "", "Credentials name. See credentials list.")
orgUpdateCmd.Flags().StringVar(&poolBalancerType, "pool-balancer-type", "", "The balancing strategy to use when creating runners in pools matching requested labels.")
orgUpdateCmd.Flags().StringVar(&orgEndpoint, "endpoint", "", "When using the name of the org, the endpoint must be specified when multiple organizations with the same name exist.")

orgWebhookInstallCmd.Flags().BoolVar(&insecureOrgWebhook, "insecure", false, "Ignore self signed certificate errors.")
orgWebhookInstallCmd.Flags().StringVar(&orgEndpoint, "endpoint", "", "When using the name of the org, the endpoint must be specified when multiple organizations with the same name exist.")

orgWebhookUninstallCmd.Flags().StringVar(&orgEndpoint, "endpoint", "", "When using the name of the org, the endpoint must be specified when multiple organizations with the same name exist.")

orgHookInfoShowCmd.Flags().StringVar(&orgEndpoint, "endpoint", "", "When using the name of the org, the endpoint must be specified when multiple organizations with the same name exist.")

orgWebhookCmd.AddCommand(
orgWebhookInstallCmd,
orgWebhookUninstallCmd,
Expand Down
28 changes: 28 additions & 0 deletions cmd/garm-cli/cmd/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,26 @@ Example:
switch len(args) {
case 0:
if cmd.Flags().Changed("repo") {
poolRepository, err = resolveRepository(poolRepository, endpointName)
if err != nil {
return err
}
listRepoPoolsReq := apiClientRepos.NewListRepoPoolsParams()
listRepoPoolsReq.RepoID = poolRepository
response, err = apiCli.Repositories.ListRepoPools(listRepoPoolsReq, authToken)
} else if cmd.Flags().Changed("org") {
poolOrganization, err = resolveOrganization(poolOrganization, endpointName)
if err != nil {
return err
}
listOrgPoolsReq := apiClientOrgs.NewListOrgPoolsParams()
listOrgPoolsReq.OrgID = poolOrganization
response, err = apiCli.Organizations.ListOrgPools(listOrgPoolsReq, authToken)
} else if cmd.Flags().Changed("enterprise") {
poolEnterprise, err = resolveEnterprise(poolEnterprise, endpointName)
if err != nil {
return err
}
listEnterprisePoolsReq := apiClientEnterprises.NewListEnterprisePoolsParams()
listEnterprisePoolsReq.EnterpriseID = poolEnterprise
response, err = apiCli.Enterprises.ListEnterprisePools(listEnterprisePoolsReq, authToken)
Expand Down Expand Up @@ -250,16 +262,28 @@ var poolAddCmd = &cobra.Command{
var err error
var response poolPayloadGetter
if cmd.Flags().Changed("repo") {
poolRepository, err = resolveRepository(poolRepository, endpointName)
if err != nil {
return err
}
newRepoPoolReq := apiClientRepos.NewCreateRepoPoolParams()
newRepoPoolReq.RepoID = poolRepository
newRepoPoolReq.Body = newPoolParams
response, err = apiCli.Repositories.CreateRepoPool(newRepoPoolReq, authToken)
} else if cmd.Flags().Changed("org") {
poolOrganization, err = resolveOrganization(poolOrganization, endpointName)
if err != nil {
return err
}
newOrgPoolReq := apiClientOrgs.NewCreateOrgPoolParams()
newOrgPoolReq.OrgID = poolOrganization
newOrgPoolReq.Body = newPoolParams
response, err = apiCli.Organizations.CreateOrgPool(newOrgPoolReq, authToken)
} else if cmd.Flags().Changed("enterprise") {
poolEnterprise, err = resolveEnterprise(poolEnterprise, endpointName)
if err != nil {
return err
}
newEnterprisePoolReq := apiClientEnterprises.NewCreateEnterprisePoolParams()
newEnterprisePoolReq.EnterpriseID = poolEnterprise
newEnterprisePoolReq.Body = newPoolParams
Expand Down Expand Up @@ -387,6 +411,8 @@ func init() {
poolListCmd.Flags().StringVarP(&poolEnterprise, "enterprise", "e", "", "List all pools within this enterprise.")
poolListCmd.Flags().BoolVarP(&poolAll, "all", "a", false, "List all pools, regardless of org or repo.")
poolListCmd.Flags().BoolVarP(&long, "long", "l", false, "Include additional info.")
poolListCmd.Flags().StringVar(&endpointName, "endpoint", "", "When using the name of an entity, the endpoint must be specified when multiple entities with the same name exist.")

poolListCmd.MarkFlagsMutuallyExclusive("repo", "org", "all", "enterprise")

poolUpdateCmd.Flags().StringVar(&poolImage, "image", "", "The provider-specific image name to use for runners in this pool.")
Expand Down Expand Up @@ -420,6 +446,8 @@ func init() {
poolAddCmd.Flags().UintVar(&poolRunnerBootstrapTimeout, "runner-bootstrap-timeout", 20, "Duration in minutes after which a runner is considered failed if it does not join Github.")
poolAddCmd.Flags().UintVar(&poolMinIdleRunners, "min-idle-runners", 1, "Attempt to maintain a minimum of idle self-hosted runners of this type.")
poolAddCmd.Flags().BoolVar(&poolEnabled, "enabled", false, "Enable this pool.")
poolAddCmd.Flags().StringVar(&endpointName, "endpoint", "", "When using the name of an entity, the endpoint must be specified when multiple entities with the same name exist.")

poolAddCmd.MarkFlagRequired("provider-name") //nolint
poolAddCmd.MarkFlagRequired("image") //nolint
poolAddCmd.MarkFlagRequired("flavor") //nolint
Expand Down
56 changes: 49 additions & 7 deletions cmd/garm-cli/cmd/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,13 @@ var repoWebhookInstallCmd = &cobra.Command{
return fmt.Errorf("too many arguments")
}

repoID, err := resolveRepository(args[0], repoEndpoint)
if err != nil {
return err
}

installWebhookReq := apiClientRepos.NewInstallRepoWebhookParams()
installWebhookReq.RepoID = args[0]
installWebhookReq.RepoID = repoID
installWebhookReq.Body.InsecureSSL = insecureRepoWebhook
installWebhookReq.Body.WebhookEndpointType = params.WebhookEndpointDirect

Expand Down Expand Up @@ -108,8 +113,13 @@ var repoHookInfoShowCmd = &cobra.Command{
return fmt.Errorf("too many arguments")
}

repoID, err := resolveRepository(args[0], repoEndpoint)
if err != nil {
return err
}

showWebhookInfoReq := apiClientRepos.NewGetRepoWebhookInfoParams()
showWebhookInfoReq.RepoID = args[0]
showWebhookInfoReq.RepoID = repoID

response, err := apiCli.Repositories.GetRepoWebhookInfo(showWebhookInfoReq, authToken)
if err != nil {
Expand All @@ -136,10 +146,15 @@ var repoWebhookUninstallCmd = &cobra.Command{
return fmt.Errorf("too many arguments")
}

repoID, err := resolveRepository(args[0], repoEndpoint)
if err != nil {
return err
}

uninstallWebhookReq := apiClientRepos.NewUninstallRepoWebhookParams()
uninstallWebhookReq.RepoID = args[0]
uninstallWebhookReq.RepoID = repoID

err := apiCli.Repositories.UninstallRepoWebhook(uninstallWebhookReq, authToken)
err = apiCli.Repositories.UninstallRepoWebhook(uninstallWebhookReq, authToken)
if err != nil {
return err
}
Expand Down Expand Up @@ -243,13 +258,19 @@ var repoUpdateCmd = &cobra.Command{
if len(args) > 1 {
return fmt.Errorf("too many arguments")
}

repoID, err := resolveRepository(args[0], repoEndpoint)
if err != nil {
return err
}

updateReposReq := apiClientRepos.NewUpdateRepoParams()
updateReposReq.Body = params.UpdateEntityParams{
WebhookSecret: repoWebhookSecret,
CredentialsName: repoCreds,
PoolBalancerType: params.PoolBalancerType(poolBalancerType),
}
updateReposReq.RepoID = args[0]
updateReposReq.RepoID = repoID

response, err := apiCli.Repositories.UpdateRepo(updateReposReq, authToken)
if err != nil {
Expand All @@ -275,8 +296,14 @@ var repoShowCmd = &cobra.Command{
if len(args) > 1 {
return fmt.Errorf("too many arguments")
}

repoID, err := resolveRepository(args[0], repoEndpoint)
if err != nil {
return err
}

showRepoReq := apiClientRepos.NewGetRepoParams()
showRepoReq.RepoID = args[0]
showRepoReq.RepoID = repoID
response, err := apiCli.Repositories.GetRepo(showRepoReq, authToken)
if err != nil {
return err
Expand All @@ -302,8 +329,14 @@ var repoDeleteCmd = &cobra.Command{
if len(args) > 1 {
return fmt.Errorf("too many arguments")
}

repoID, err := resolveRepository(args[0], repoEndpoint)
if err != nil {
return err
}

deleteRepoReq := apiClientRepos.NewDeleteRepoParams()
deleteRepoReq.RepoID = args[0]
deleteRepoReq.RepoID = repoID
deleteRepoReq.KeepWebhook = &keepRepoWebhook
if err := apiCli.Repositories.DeleteRepo(deleteRepoReq, authToken); err != nil {
return err
Expand Down Expand Up @@ -334,12 +367,21 @@ func init() {
repoAddCmd.MarkFlagRequired("name") //nolint

repoDeleteCmd.Flags().BoolVar(&keepRepoWebhook, "keep-webhook", false, "Do not delete any existing webhook when removing the repo from GARM.")
repoDeleteCmd.Flags().StringVar(&repoEndpoint, "endpoint", "", "When using the name of the repo, the endpoint must be specified when multiple repositories with the same name exist.")

repoShowCmd.Flags().StringVar(&repoEndpoint, "endpoint", "", "When using the name of the repo, the endpoint must be specified when multiple repositories with the same name exist.")

repoUpdateCmd.Flags().StringVar(&repoWebhookSecret, "webhook-secret", "", "The webhook secret for this repository. If you update this secret, you will have to manually update the secret in GitHub as well.")
repoUpdateCmd.Flags().StringVar(&repoCreds, "credentials", "", "Credentials name. See credentials list.")
repoUpdateCmd.Flags().StringVar(&poolBalancerType, "pool-balancer-type", "", "The balancing strategy to use when creating runners in pools matching requested labels.")
repoUpdateCmd.Flags().StringVar(&repoEndpoint, "endpoint", "", "When using the name of the repo, the endpoint must be specified when multiple repositories with the same name exist.")

repoWebhookInstallCmd.Flags().BoolVar(&insecureRepoWebhook, "insecure", false, "Ignore self signed certificate errors.")
repoWebhookInstallCmd.Flags().StringVar(&repoEndpoint, "endpoint", "", "When using the name of the repo, the endpoint must be specified when multiple repositories with the same name exist.")

repoWebhookUninstallCmd.Flags().StringVar(&repoEndpoint, "endpoint", "", "When using the name of the repo, the endpoint must be specified when multiple repositories with the same name exist.")

repoHookInfoShowCmd.Flags().StringVar(&repoEndpoint, "endpoint", "", "When using the name of the repo, the endpoint must be specified when multiple repositories with the same name exist.")

repoWebhookCmd.AddCommand(
repoWebhookInstallCmd,
Expand Down
Loading
Loading