Skip to content

Commit 91043f9

Browse files
Merge pull request #71 from mihaichitic/ND-7580
[ND-7580] - add Pipeline monitor interval to env actions
2 parents 0879a05 + 07f1022 commit 91043f9

File tree

6 files changed

+18
-7
lines changed

6 files changed

+18
-7
lines changed

cmd/environment/action/delete.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func init() {
3434
return lib.FormatCommandData(cmd, event)
3535
}
3636

37-
if err = processEventPipeline(cmd, event, "delete", settings.IsStylish()); err != nil {
37+
if err = processEventPipeline(cmd, event, "delete", settings.IsStylish(), deleteOptions.Interval); err != nil {
3838
cmd.Printf("\nEnvironment %s deletion failed\n", deleteOptions.ID)
3939

4040
return err

cmd/environment/action/root.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package action
33
import (
44
"errors"
55
"fmt"
6+
"time"
67

78
"bunnyshell.com/cli/pkg/api/common"
89
"bunnyshell.com/cli/pkg/api/component/endpoint"
@@ -58,7 +59,7 @@ func HandleDeploy(cmd *cobra.Command, deployOptions *environment.DeployOptions,
5859
return lib.FormatCommandData(cmd, event)
5960
}
6061

61-
if err = processEventPipeline(cmd, event, "deploy", printLogs); err != nil {
62+
if err = processEventPipeline(cmd, event, "deploy", printLogs, deployOptions.Interval); err != nil {
6263
if printLogs {
6364
cmd.Printf("\nEnvironment %s deploying failed\n", deployOptions.ID)
6465
}
@@ -120,8 +121,11 @@ func ensureKubernetesIntegration(deployOptions *environment.DeployOptions, kuber
120121
return err
121122
}
122123

123-
func processEventPipeline(cmd *cobra.Command, event *sdk.EventItem, action string, printLogs bool) error {
124+
func processEventPipeline(cmd *cobra.Command, event *sdk.EventItem, action string, printLogs bool, interval time.Duration) error {
124125
progressOptions := progress.NewOptions()
126+
if interval != 0 {
127+
progressOptions.Interval = interval
128+
}
125129

126130
if printLogs {
127131
cmd.Printf(
@@ -150,7 +154,7 @@ func processEventPipeline(cmd *cobra.Command, event *sdk.EventItem, action strin
150154
}
151155
}
152156

153-
if err = progress.Pipeline(pipeline.GetId(), nil); err != nil {
157+
if err = progress.Pipeline(pipeline.GetId(), progressOptions); err != nil {
154158
return err
155159
}
156160

cmd/environment/action/start.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func init() {
3636

3737
printLogs := settings.IsStylish()
3838

39-
if err = processEventPipeline(cmd, event, "start", printLogs); err != nil {
39+
if err = processEventPipeline(cmd, event, "start", printLogs, startOptions.Interval); err != nil {
4040
if printLogs {
4141
cmd.Printf("\nEnvironment %s starting failed\n", startOptions.ID)
4242
}

cmd/environment/action/stop.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func init() {
3636

3737
printLogs := settings.IsStylish()
3838

39-
if err = processEventPipeline(cmd, event, "stop", printLogs); err != nil {
39+
if err = processEventPipeline(cmd, event, "stop", printLogs, stopOptions.Interval); err != nil {
4040
if printLogs {
4141
cmd.Printf("\nEnvironment %s stopping failed\n", stopOptions.ID)
4242
}

pkg/api/common/action.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,30 @@
11
package common
22

33
import (
4+
"time"
5+
46
"github.com/spf13/pflag"
57
)
68

79
type ActionOptions struct {
810
ItemOptions
911

1012
WithoutPipeline bool
13+
14+
Interval time.Duration
1115
}
1216

1317
func NewActionOptions(id string) *ActionOptions {
1418
return &ActionOptions{
1519
ItemOptions: *NewItemOptions(id),
1620

1721
WithoutPipeline: false,
22+
23+
Interval: 2000 * time.Millisecond,
1824
}
1925
}
2026

2127
func (ao *ActionOptions) UpdateFlagSet(flags *pflag.FlagSet) {
2228
flags.BoolVar(&ao.WithoutPipeline, "no-wait", ao.WithoutPipeline, "Do not wait for pipeline until finish")
29+
flags.DurationVar(&ao.Interval, "pipeline-monitor-interval", ao.Interval, "Pipeline check interval")
2330
}

pkg/progress/vars.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const (
3535
)
3636

3737
const (
38-
defaultSpinnerUpdate = 150 * time.Millisecond
38+
defaultSpinnerUpdate = 2000 * time.Millisecond
3939
defaultProgressSet = 69 // ∙∙●
4040
)
4141

0 commit comments

Comments
 (0)