diff --git a/go.mod b/go.mod index c312d05..9294c96 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ replace github.com/imdario/mergo => github.com/imdario/mergo v0.3.16 require ( bunnyshell.com/dev v0.7.2 - bunnyshell.com/sdk v0.22.2 + bunnyshell.com/sdk v0.22.4 github.com/AlecAivazis/survey/v2 v2.3.7 github.com/MakeNowJust/heredoc v1.0.0 github.com/avast/retry-go/v4 v4.6.0 diff --git a/go.sum b/go.sum index eb715b0..d8e8cc7 100644 --- a/go.sum +++ b/go.sum @@ -1,7 +1,7 @@ bunnyshell.com/dev v0.7.2 h1:fa0ZvnIAXLVJINCJqo7uenjHmjPrlHmY18Zc8ypo/6E= bunnyshell.com/dev v0.7.2/go.mod h1:+Xk46UXX9AW0nHrFMdO/IwpUPfALrck1/qI+LIXsDmE= -bunnyshell.com/sdk v0.22.2 h1:LGJePQTdrBC6YvM282K+1/bw4ohu0XWFQdJN4Drg6l8= -bunnyshell.com/sdk v0.22.2/go.mod h1:RfgfUzZ4WHZGCkToUfu2/hoQS6XsQc8IdPTVAlpS138= +bunnyshell.com/sdk v0.22.4 h1:+arvsU9c8FcYp5GjeN8W78bIuwYndKKMaR6CqGu1EQw= +bunnyshell.com/sdk v0.22.4/go.mod h1:RfgfUzZ4WHZGCkToUfu2/hoQS6XsQc8IdPTVAlpS138= github.com/AlecAivazis/survey/v2 v2.3.7 h1:6I/u8FvytdGsgonrYsVn2t8t4QiRnh6QSTqkkhIiSjQ= github.com/AlecAivazis/survey/v2 v2.3.7/go.mod h1:xUTIdE4KCOIjsBAE1JYsUPoCqYdZ1reCfTwbto0Fduo= github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 h1:L/gRVlceqvL25UVaW/CKtUDjefjrs0SPonmDGUVOYP0= diff --git a/pkg/api/environment/action_delete.go b/pkg/api/environment/action_delete.go index 7553ba8..b4cdde3 100644 --- a/pkg/api/environment/action_delete.go +++ b/pkg/api/environment/action_delete.go @@ -1,9 +1,10 @@ package environment import ( - "github.com/spf13/pflag" "net/http" + "github.com/spf13/pflag" + "bunnyshell.com/cli/pkg/api" "bunnyshell.com/cli/pkg/api/common" "bunnyshell.com/cli/pkg/lib" @@ -26,7 +27,7 @@ func NewDeleteOptions(id string) *DeleteOptions { func (options *DeleteOptions) UpdateFlagSet(flags *pflag.FlagSet) { options.ActionOptions.UpdateFlagSet(flags) - //flags.BoolVar(&options.QueueIfSomethingInProgress, "queue", options.QueueIfSomethingInProgress, "Queue the delete pipeline if another operation is in progress now") + flags.BoolVar(&options.QueueIfSomethingInProgress, "queue", options.QueueIfSomethingInProgress, "Queue the delete pipeline if another operation is in progress now") } func Delete(options *DeleteOptions) (*sdk.EventItem, error) { @@ -44,7 +45,8 @@ func DeleteRaw(options *DeleteOptions) (*sdk.EventItem, *http.Response, error) { ctx, cancel := lib.GetContextFromProfile(profile) defer cancel() - request := lib.GetAPIFromProfile(profile).EnvironmentAPI.EnvironmentDelete(ctx, options.ID) + request := lib.GetAPIFromProfile(profile).EnvironmentAPI.EnvironmentDelete(ctx, options.ID). + QueueIfSomethingInProgress(options.QueueIfSomethingInProgress) return request.Execute() } diff --git a/pkg/api/environment/action_start.go b/pkg/api/environment/action_start.go index 7e5b06f..9ee57a2 100644 --- a/pkg/api/environment/action_start.go +++ b/pkg/api/environment/action_start.go @@ -3,22 +3,25 @@ package environment import ( "net/http" + "github.com/spf13/pflag" + "bunnyshell.com/cli/pkg/api" "bunnyshell.com/cli/pkg/api/common" "bunnyshell.com/cli/pkg/lib" "bunnyshell.com/sdk" - "github.com/spf13/pflag" ) type StartOptions struct { common.PartialActionOptions - WithDependencies bool + WithDependencies bool + QueueIfSomethingInProgress bool } func NewStartOptions(id string) *StartOptions { return &StartOptions{ - PartialActionOptions: *common.NewPartialActionOptions(id), + PartialActionOptions: *common.NewPartialActionOptions(id), + QueueIfSomethingInProgress: false, } } @@ -26,6 +29,7 @@ func (options *StartOptions) UpdateFlagSet(flags *pflag.FlagSet) { options.PartialActionOptions.UpdateFlagSet(flags) flags.BoolVar(&options.WithDependencies, "with-dependencies", options.WithDependencies, "Start the component dependencies too.") + flags.BoolVar(&options.QueueIfSomethingInProgress, "queue", options.QueueIfSomethingInProgress, "Queue the start pipeline if another operation is in progress now") } func Start(options *StartOptions) (*sdk.EventItem, error) { @@ -47,9 +51,10 @@ func StartRaw(options *StartOptions) (*sdk.EventItem, *http.Response, error) { request := lib.GetAPIFromProfile(profile).EnvironmentAPI.EnvironmentStart(ctx, options.ID). EnvironmentPartialStartAction(sdk.EnvironmentPartialStartAction{ - IsPartial: &isPartialAction, - Components: options.GetActionComponents(), - WithDependencies: &options.WithDependencies, + IsPartial: &isPartialAction, + Components: options.GetActionComponents(), + WithDependencies: &options.WithDependencies, + QueueIfSomethingInProgress: &options.QueueIfSomethingInProgress, }) return request.Execute() diff --git a/pkg/api/environment/action_stop.go b/pkg/api/environment/action_stop.go index a6823dc..32b5727 100644 --- a/pkg/api/environment/action_stop.go +++ b/pkg/api/environment/action_stop.go @@ -3,6 +3,8 @@ package environment import ( "net/http" + "github.com/spf13/pflag" + "bunnyshell.com/cli/pkg/api" "bunnyshell.com/cli/pkg/api/common" "bunnyshell.com/cli/pkg/lib" @@ -11,14 +13,23 @@ import ( type StopOptions struct { common.PartialActionOptions + + QueueIfSomethingInProgress bool } func NewStopOptions(id string) *StopOptions { return &StopOptions{ - PartialActionOptions: *common.NewPartialActionOptions(id), + PartialActionOptions: *common.NewPartialActionOptions(id), + QueueIfSomethingInProgress: false, } } +func (options *StopOptions) UpdateFlagSet(flags *pflag.FlagSet) { + options.PartialActionOptions.UpdateFlagSet(flags) + + flags.BoolVar(&options.QueueIfSomethingInProgress, "queue", options.QueueIfSomethingInProgress, "Queue the stop pipeline if another operation is in progress now") +} + func Stop(options *StopOptions) (*sdk.EventItem, error) { model, resp, err := StopRaw(options) if err != nil { @@ -37,9 +48,10 @@ func StopRaw(options *StopOptions) (*sdk.EventItem, *http.Response, error) { isPartialAction := options.IsPartial() request := lib.GetAPIFromProfile(profile).EnvironmentAPI.EnvironmentStop(ctx, options.ID). - EnvironmentPartialAction(sdk.EnvironmentPartialAction{ - IsPartial: &isPartialAction, - Components: options.GetActionComponents(), + EnvironmentPartialStopAction(sdk.EnvironmentPartialStopAction{ + IsPartial: &isPartialAction, + Components: options.GetActionComponents(), + QueueIfSomethingInProgress: &options.QueueIfSomethingInProgress, }) return request.Execute()