-
Notifications
You must be signed in to change notification settings - Fork 26
feat(stage): add skip/unskip commands and show skipped section in list #610
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| package cmd | ||
|
|
||
| import ( | ||
| "context" | ||
| "errors" | ||
|
|
||
| "github.com/qovery/qovery-cli/utils" | ||
| "github.com/qovery/qovery-client-go" | ||
| "github.com/spf13/cobra" | ||
| ) | ||
|
|
||
| var environmentStageSkipCmd = &cobra.Command{ | ||
| Use: "skip", | ||
| Short: "Skip service from environment-level deployments", | ||
| Long: "Mark a service as skipped so it is excluded from environment-level bulk deployments while staying in its current stage. To reverse this, use 'environment stage unskip' or move the service to a different deployment stage, which automatically clears the skipped status.", | ||
| Run: func(cmd *cobra.Command, args []string) { | ||
| utils.Capture(cmd) | ||
|
|
||
| tokenType, token, err := utils.GetAccessToken() | ||
| utils.CheckError(err) | ||
|
|
||
| client := utils.GetQoveryClient(tokenType, token) | ||
| _, _, environmentId, err := getOrganizationProjectEnvironmentContextResourcesIds(client) | ||
| utils.CheckError(err) | ||
|
|
||
| stages, _, err := client.DeploymentStageMainCallsAPI.ListEnvironmentDeploymentStage(context.Background(), environmentId).Execute() | ||
| utils.CheckError(err) | ||
|
|
||
| var service *qovery.DeploymentStageServiceResponse | ||
| var currentStageId string | ||
| for _, stage := range stages.GetResults() { | ||
| service, _ = getServiceByName(client, stage.GetServices(), serviceName) | ||
fabienfleureau marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| if service != nil { | ||
| currentStageId = stage.GetId() | ||
| break | ||
| } | ||
| } | ||
|
|
||
| if service == nil { | ||
| utils.CheckError(errors.New("service not found")) | ||
| } | ||
|
|
||
| req := qovery.AttachServiceToDeploymentStageRequest{} | ||
| req.SetIsSkipped(true) | ||
|
|
||
| _, _, err = client.DeploymentStageMainCallsAPI. | ||
| AttachServiceToDeploymentStage(context.Background(), currentStageId, service.GetServiceId()). | ||
| AttachServiceToDeploymentStageRequest(req). | ||
| Execute() | ||
| utils.CheckError(err) | ||
|
|
||
| utils.Println("Service \"" + serviceName + "\" is now skipped from environment-level deployments") | ||
| }, | ||
| } | ||
|
|
||
| func init() { | ||
| environmentStageCmd.AddCommand(environmentStageSkipCmd) | ||
| environmentStageSkipCmd.Flags().StringVarP(&organizationName, "organization", "", "", "Organization Name") | ||
| environmentStageSkipCmd.Flags().StringVarP(&projectName, "project", "", "", "Project Name") | ||
| environmentStageSkipCmd.Flags().StringVarP(&environmentName, "environment", "", "", "Environment Name") | ||
| environmentStageSkipCmd.Flags().StringVarP(&serviceName, "name", "n", "", "Service Name") | ||
|
||
|
|
||
| _ = environmentStageSkipCmd.MarkFlagRequired("name") | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| package cmd | ||
|
|
||
| import ( | ||
| "context" | ||
| "errors" | ||
|
|
||
| "github.com/qovery/qovery-cli/utils" | ||
| "github.com/qovery/qovery-client-go" | ||
| "github.com/spf13/cobra" | ||
| ) | ||
|
|
||
| var environmentStageUnskipCmd = &cobra.Command{ | ||
| Use: "unskip", | ||
| Short: "Unskip service from environment-level deployments", | ||
| Long: "Remove the skipped flag from a service so it is included again in environment-level bulk deployments.", | ||
| Run: func(cmd *cobra.Command, args []string) { | ||
| utils.Capture(cmd) | ||
|
|
||
| tokenType, token, err := utils.GetAccessToken() | ||
| utils.CheckError(err) | ||
|
|
||
| client := utils.GetQoveryClient(tokenType, token) | ||
| _, _, environmentId, err := getOrganizationProjectEnvironmentContextResourcesIds(client) | ||
| utils.CheckError(err) | ||
|
|
||
| stages, _, err := client.DeploymentStageMainCallsAPI.ListEnvironmentDeploymentStage(context.Background(), environmentId).Execute() | ||
| utils.CheckError(err) | ||
|
|
||
| var service *qovery.DeploymentStageServiceResponse | ||
| var currentStageId string | ||
| for _, stage := range stages.GetResults() { | ||
| service, _ = getServiceByName(client, stage.GetServices(), serviceName) | ||
fabienfleureau marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| if service != nil { | ||
| currentStageId = stage.GetId() | ||
| break | ||
| } | ||
| } | ||
|
|
||
| if service == nil { | ||
| utils.CheckError(errors.New("service not found")) | ||
| } | ||
|
|
||
| req := qovery.AttachServiceToDeploymentStageRequest{} | ||
| req.SetIsSkipped(false) | ||
|
|
||
| _, _, err = client.DeploymentStageMainCallsAPI. | ||
| AttachServiceToDeploymentStage(context.Background(), currentStageId, service.GetServiceId()). | ||
| AttachServiceToDeploymentStageRequest(req). | ||
| Execute() | ||
| utils.CheckError(err) | ||
|
|
||
| utils.Println("Service \"" + serviceName + "\" is no longer skipped from environment-level deployments") | ||
| }, | ||
| } | ||
|
|
||
| func init() { | ||
| environmentStageCmd.AddCommand(environmentStageUnskipCmd) | ||
| environmentStageUnskipCmd.Flags().StringVarP(&organizationName, "organization", "", "", "Organization Name") | ||
| environmentStageUnskipCmd.Flags().StringVarP(&projectName, "project", "", "", "Project Name") | ||
| environmentStageUnskipCmd.Flags().StringVarP(&environmentName, "environment", "", "", "Environment Name") | ||
| environmentStageUnskipCmd.Flags().StringVarP(&serviceName, "name", "n", "", "Service Name") | ||
|
|
||
| _ = environmentStageUnskipCmd.MarkFlagRequired("name") | ||
| } | ||
fabienfleureau marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Uh oh!
There was an error while loading. Please reload this page.