diff --git a/cmd/helmspray/main.go b/cmd/helmspray/main.go index 1d505f8..ed6f93f 100644 --- a/cmd/helmspray/main.go +++ b/cmd/helmspray/main.go @@ -21,6 +21,7 @@ import ( "github.com/gemalto/helm-spray/internal/values" "github.com/gemalto/helm-spray/pkg/helm" "github.com/gemalto/helm-spray/pkg/kubectl" + "github.com/gemalto/helm-spray/pkg/util" "helm.sh/helm/v3/pkg/chart/loader" cliValues "helm.sh/helm/v3/pkg/cli/values" "io/ioutil" @@ -211,6 +212,8 @@ func (p *sprayCmd) spray() error { log.Info(1, "starting spray with flags: %+v\n", p) } + startTime := time.Now() + // Load and validate the umbrella chart... chart, err := loader.Load(p.chartName) if err != nil { @@ -293,7 +296,7 @@ func (p *sprayCmd) spray() error { } } - log.Info(1, "upgrade of solution chart \"%s\" completed", p.chartName) + log.Info(1, "upgrade of solution chart \"%s\" completed in %s", p.chartName, util.Duration(time.Since(startTime))) return nil } diff --git a/pkg/util/util.go b/pkg/util/util.go new file mode 100644 index 0000000..078ea53 --- /dev/null +++ b/pkg/util/util.go @@ -0,0 +1,18 @@ +package util + +import ( + "strings" + "time" +) + +func Duration(d time.Duration) string { + d = d.Truncate(time.Second) + s := d.String() + if strings.HasSuffix(s, "m0s") { + s = s[:len(s)-2] + } + if strings.HasSuffix(s, "h0m") { + s = s[:len(s)-2] + } + return s +} diff --git a/plugin.yaml b/plugin.yaml index 7bcdd0f..e144296 100644 --- a/plugin.yaml +++ b/plugin.yaml @@ -1,5 +1,5 @@ name: "spray" -version: 4.0.0-rc.1 +version: 4.0.0-rc.2 usage: "upgrade sub-charts from an umbrella chart with dependency orders" description: "Helm plugin for upgrading sub-charts from umbrella chart with dependency orders" command: "$HELM_PLUGIN_DIR/bin/helm-spray"