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
2 changes: 1 addition & 1 deletion cmd/environment/action/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 7 additions & 3 deletions cmd/environment/action/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package action
import (
"errors"
"fmt"
"time"

"bunnyshell.com/cli/pkg/api/common"
"bunnyshell.com/cli/pkg/api/component/endpoint"
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/environment/action/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/environment/action/stop.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
7 changes: 7 additions & 0 deletions pkg/api/common/action.go
Original file line number Diff line number Diff line change
@@ -1,23 +1,30 @@
package common

import (
"time"

"github.com/spf13/pflag"
)

type ActionOptions struct {
ItemOptions

WithoutPipeline bool

Interval time.Duration
}

func NewActionOptions(id string) *ActionOptions {
return &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")
}
2 changes: 1 addition & 1 deletion pkg/progress/vars.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const (
)

const (
defaultSpinnerUpdate = 150 * time.Millisecond
defaultSpinnerUpdate = 2000 * time.Millisecond
defaultProgressSet = 69 // ∙∙●
)

Expand Down
Loading