Skip to content

Commit e9ace09

Browse files
add spinner to show progress when attaching runtime (#125)
1 parent cdfe7be commit e9ace09

File tree

7 files changed

+28
-10
lines changed

7 files changed

+28
-10
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "venona",
3-
"version": "1.2.4",
3+
"version": "1.2.5",
44
"description": "Codefresh agent to run on Codefresh's runtime environment and execute pipeline",
55
"main": "index.js",
66
"scripts": {

venonactl/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.2.4
1+
1.2.5

venonactl/cmd/attach.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ var attachRuntimeCmdOptions struct {
3737
kubePath string
3838
context string
3939
}
40-
restartAgent bool
40+
restartAgent bool
4141
}
4242

4343
var attachRuntimeCmd = &cobra.Command{
@@ -78,7 +78,7 @@ var attachRuntimeCmd = &cobra.Command{
7878
RuntimeEnvironment: attachRuntimeCmdOptions.runtimeEnvironmentName,
7979
RuntimeClusterName: attachRuntimeCmdOptions.kube.namespace,
8080
RuntimeServiceAccount: attachRuntimeCmdOptions.kube.serviceAccount,
81-
RestartAgent: attachRuntimeCmdOptions.restartAgent,
81+
RestartAgent: attachRuntimeCmdOptions.restartAgent,
8282
}
8383

8484
// runtime
@@ -94,12 +94,15 @@ var attachRuntimeCmd = &cobra.Command{
9494

9595
var err error
9696
values := s.BuildValues()
97+
spn := createSpinner("Attaching runtime to agent (might take a few seconds)", "")
98+
spn.Start()
9799
for _, p := range builder.Get() {
98100
values, err = p.Install(builderInstallOpt, values)
99101
if err != nil {
100102
dieOnError(err)
101103
}
102104
}
105+
spn.Stop()
103106
lgr.Info("Attach to runtime completed Successfully")
104107

105108
},
@@ -121,5 +124,4 @@ func init() {
121124
attachRuntimeCmd.Flags().StringVar(&attachRuntimeCmdOptions.kubeVenona.kubePath, "kube-config-path-agent", viper.GetString("kubeconfig-agent"), "Path to kubeconfig file (default is $HOME/.kube/config) for agent [$KUBECONFIG]")
122125
attachRuntimeCmd.Flags().BoolVar(&attachRuntimeCmdOptions.restartAgent, "restart-agent", viper.GetBool("restart-agent"), "Restart agent after attach operation")
123126

124-
125127
}

venonactl/cmd/cmdutils.go

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@ import (
99
"os/user"
1010
"path"
1111
"strings"
12+
"time"
1213

1314
"encoding/json"
1415

16+
"github.com/briandowns/spinner"
1517
"github.com/codefresh-io/go-sdk/pkg/codefresh"
1618
sdkUtils "github.com/codefresh-io/go-sdk/pkg/utils"
1719
"github.com/codefresh-io/venona/venonactl/pkg/certs"
@@ -162,6 +164,13 @@ func createLogger(command string, verbose bool) logger.Logger {
162164
})
163165
}
164166

167+
func createSpinner(prefix, suffix string) *spinner.Spinner {
168+
s := spinner.New([]string{" ", ". ", ".. ", "..."}, 520*time.Millisecond)
169+
s.Suffix = suffix
170+
s.Prefix = prefix
171+
return s
172+
}
173+
165174
type nodeSelector map[string]string
166175

167176
func parseNodeSelector(s string) (nodeSelector, error) {
@@ -237,10 +246,10 @@ func (ns nodeSelector) String() string {
237246
return s
238247
}
239248

240-
// Parsing helpers --set-value , --set-file
249+
// Parsing helpers --set-value , --set-file
241250
// by https://github.com/helm/helm/blob/ec1d1a3d3eb672232f896f9d3b3d0797e4f519e3/pkg/cli/values/options.go#L41
242251

243-
// parses --set-value options
252+
// parses --set-value options
244253
func parseSetValues(setValuesOpts []string) (map[string]interface{}, error) {
245254
base := map[string]interface{}{}
246255
for _, value := range setValuesOpts {
@@ -251,7 +260,7 @@ func parseSetValues(setValuesOpts []string) (map[string]interface{}, error) {
251260
return base, nil
252261
}
253262

254-
// parses --set-file options
263+
// parses --set-file options
255264
func parseSetFiles(setFilesOpts []string) (map[string]interface{}, error) {
256265
base := map[string]interface{}{}
257266
for _, value := range setFilesOpts {
@@ -283,4 +292,4 @@ func mergeMaps(a, b map[string]interface{}) map[string]interface{} {
283292
out[k] = v
284293
}
285294
return out
286-
}
295+
}

venonactl/go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ require (
66
github.com/Azure/go-autorest/autorest v0.10.0 // indirect
77
github.com/Masterminds/semver v1.5.0 // indirect
88
github.com/Masterminds/sprig v2.22.0+incompatible
9+
github.com/briandowns/spinner v1.11.1
910
github.com/codefresh-io/go-sdk v0.18.0
1011
github.com/dustin/go-humanize v1.0.0
1112
github.com/gophercloud/gophercloud v0.8.0 // indirect

venonactl/go.sum

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ github.com/bitly/go-simplejson v0.5.0/go.mod h1:cXHtHw4XUPsvGaxgjIAn8PhEWG9NfngE
6464
github.com/blang/semver v3.1.0+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk=
6565
github.com/blang/semver v3.5.0+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk=
6666
github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869/go.mod h1:Ekp36dRnpXw/yCqJaO+ZrUyxD+3VXMFFr56k5XYrpB4=
67+
github.com/briandowns/spinner v1.11.1 h1:OixPqDEcX3juo5AjQZAnFPbeUA0jvkp2qzB5gOZJ/L0=
68+
github.com/briandowns/spinner v1.11.1/go.mod h1:QOuQk7x+EaDASo80FEXwlwiA+j/PPIcX3FScO+3/ZPQ=
6769
github.com/bshuster-repo/logrus-logstash-hook v0.4.1/go.mod h1:zsTqEiSzDgAa/8GZR7E1qaXrhYNDKBYy5/dWPTIflbk=
6870
github.com/bugsnag/bugsnag-go v0.0.0-20141110184014-b1d153021fcd/go.mod h1:2oa8nejYd4cQ/b0hMIopN0lCRxU0bueqREvZLWFrtK8=
6971
github.com/bugsnag/osext v0.0.0-20130617224835-0dd3f918b21b/go.mod h1:obH5gd0BsqsP2LwDJ9aOkm/6J86V6lyAXCoQWGw3K50=
@@ -136,6 +138,7 @@ github.com/evanphx/json-patch v4.2.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLi
136138
github.com/evanphx/json-patch v4.5.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk=
137139
github.com/exponent-io/jsonpath v0.0.0-20151013193312-d6023ce2651d/go.mod h1:ZZMPRZwes7CROmyNKgQzC3XPs6L/G2EJLHddWejkmf4=
138140
github.com/fatih/camelcase v1.0.0/go.mod h1:yN2Sb0lFhZJUdVvtELVWefmrXpuZESvPmqwoZc+/fpc=
141+
github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys=
139142
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
140143
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
141144
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
@@ -302,9 +305,11 @@ github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN
302305
github.com/mailru/easyjson v0.7.0/go.mod h1:KAzv3t3aY1NaHWoQz1+4F1ccyAH66Jk7yos7ldAVICs=
303306
github.com/marstr/guid v1.1.0/go.mod h1:74gB1z2wpxxInTG6yaqA7KrtM0NZ+RbrcqDvYHefzho=
304307
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
308+
github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
305309
github.com/mattn/go-colorable v0.1.6 h1:6Su7aK7lXmJ/U79bYtBjLNaha4Fs1Rg9plHpcH+vvnE=
306310
github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
307311
github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
312+
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
308313
github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=
309314
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
310315
github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
@@ -535,6 +540,7 @@ golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5h
535540
golang.org/x/sys v0.0.0-20181228144115-9a3f9b0469bb/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
536541
golang.org/x/sys v0.0.0-20190209173611-3b5209105503/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
537542
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
543+
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
538544
golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
539545
golang.org/x/sys v0.0.0-20190321052220-f7bb7a8bee54/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
540546
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=

venonactl/pkg/plugins/runtime-attach.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ func (u *runtimeAttachPlugin) Install(opt *InstallOptions, v Values) (Values, er
186186
}
187187
}
188188
}
189-
case <-time.After(45 * time.Second):
189+
case <-time.After(60 * time.Second):
190190
u.logger.Error("Failed to validate old venona pod termination")
191191
return v, fmt.Errorf("Failed to validate old venona pod termination")
192192
}

0 commit comments

Comments
 (0)