diff --git a/cmd/environment/action/delete.go b/cmd/environment/action/delete.go index 0561513..3b06603 100644 --- a/cmd/environment/action/delete.go +++ b/cmd/environment/action/delete.go @@ -34,7 +34,7 @@ func init() { return lib.FormatCommandData(cmd, event) } - if err = processEventPipeline(cmd, event, "delete", settings.IsStylish()); err != nil { + if err = processEventPipeline(cmd, event, "delete", settings.IsStylish(), deleteOptions.Interval); err != nil { cmd.Printf("\nEnvironment %s deletion failed\n", deleteOptions.ID) return err diff --git a/cmd/environment/action/root.go b/cmd/environment/action/root.go index 321f8e6..63d7e56 100644 --- a/cmd/environment/action/root.go +++ b/cmd/environment/action/root.go @@ -3,6 +3,7 @@ package action import ( "errors" "fmt" + "time" "bunnyshell.com/cli/pkg/api/common" "bunnyshell.com/cli/pkg/api/component/endpoint" @@ -58,7 +59,7 @@ func HandleDeploy(cmd *cobra.Command, deployOptions *environment.DeployOptions, return lib.FormatCommandData(cmd, event) } - if err = processEventPipeline(cmd, event, "deploy", printLogs); err != nil { + if err = processEventPipeline(cmd, event, "deploy", printLogs, deployOptions.Interval); err != nil { if printLogs { cmd.Printf("\nEnvironment %s deploying failed\n", deployOptions.ID) } @@ -120,8 +121,11 @@ func ensureKubernetesIntegration(deployOptions *environment.DeployOptions, kuber return err } -func processEventPipeline(cmd *cobra.Command, event *sdk.EventItem, action string, printLogs bool) error { +func processEventPipeline(cmd *cobra.Command, event *sdk.EventItem, action string, printLogs bool, interval time.Duration) error { progressOptions := progress.NewOptions() + if interval != 0 { + progressOptions.Interval = interval + } if printLogs { cmd.Printf( @@ -150,7 +154,7 @@ func processEventPipeline(cmd *cobra.Command, event *sdk.EventItem, action strin } } - if err = progress.Pipeline(pipeline.GetId(), nil); err != nil { + if err = progress.Pipeline(pipeline.GetId(), progressOptions); err != nil { return err } diff --git a/cmd/environment/action/start.go b/cmd/environment/action/start.go index 63307dc..0c00d50 100644 --- a/cmd/environment/action/start.go +++ b/cmd/environment/action/start.go @@ -36,7 +36,7 @@ func init() { printLogs := settings.IsStylish() - if err = processEventPipeline(cmd, event, "start", printLogs); err != nil { + if err = processEventPipeline(cmd, event, "start", printLogs, startOptions.Interval); err != nil { if printLogs { cmd.Printf("\nEnvironment %s starting failed\n", startOptions.ID) } diff --git a/cmd/environment/action/stop.go b/cmd/environment/action/stop.go index 96bcd25..5f8900f 100644 --- a/cmd/environment/action/stop.go +++ b/cmd/environment/action/stop.go @@ -36,7 +36,7 @@ func init() { printLogs := settings.IsStylish() - if err = processEventPipeline(cmd, event, "stop", printLogs); err != nil { + if err = processEventPipeline(cmd, event, "stop", printLogs, stopOptions.Interval); err != nil { if printLogs { cmd.Printf("\nEnvironment %s stopping failed\n", stopOptions.ID) } diff --git a/pkg/api/common/action.go b/pkg/api/common/action.go index 323915f..21f5d44 100644 --- a/pkg/api/common/action.go +++ b/pkg/api/common/action.go @@ -1,6 +1,8 @@ package common import ( + "time" + "github.com/spf13/pflag" ) @@ -8,6 +10,8 @@ type ActionOptions struct { ItemOptions WithoutPipeline bool + + Interval time.Duration } func NewActionOptions(id string) *ActionOptions { @@ -15,9 +19,12 @@ func NewActionOptions(id string) *ActionOptions { ItemOptions: *NewItemOptions(id), WithoutPipeline: false, + + Interval: 2000 * time.Millisecond, } } func (ao *ActionOptions) UpdateFlagSet(flags *pflag.FlagSet) { flags.BoolVar(&ao.WithoutPipeline, "no-wait", ao.WithoutPipeline, "Do not wait for pipeline until finish") + flags.DurationVar(&ao.Interval, "pipeline-monitor-interval", ao.Interval, "Pipeline check interval") } diff --git a/pkg/progress/vars.go b/pkg/progress/vars.go index 30723fe..4f1dde4 100644 --- a/pkg/progress/vars.go +++ b/pkg/progress/vars.go @@ -35,7 +35,7 @@ const ( ) const ( - defaultSpinnerUpdate = 150 * time.Millisecond + defaultSpinnerUpdate = 2000 * time.Millisecond defaultProgressSet = 69 // ∙∙● )