Skip to content

Commit

Permalink
added time duration
Browse files Browse the repository at this point in the history
  • Loading branch information
Christophe VILA committed May 20, 2020
1 parent d5068b6 commit 2869df8
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
5 changes: 4 additions & 1 deletion cmd/helmspray/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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
}
Expand Down
18 changes: 18 additions & 0 deletions pkg/util/util.go
Original file line number Diff line number Diff line change
@@ -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
}
2 changes: 1 addition & 1 deletion plugin.yaml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down

0 comments on commit 2869df8

Please sign in to comment.