From 93abfd75ad55828ac918e5c890f434385be1a153 Mon Sep 17 00:00:00 2001 From: Taylor Thomas Date: Wed, 16 Oct 2019 21:01:52 -0500 Subject: [PATCH] Remove reference to stdtime to reduce confusion Signed-off-by: Taylor Thomas --- cmd/helm/history.go | 18 +++++++++--------- cmd/helm/status_test.go | 10 +++++----- pkg/action/hooks.go | 12 ++++++------ pkg/action/rollback.go | 8 ++++---- pkg/action/uninstall.go | 8 ++++---- pkg/releaseutil/sorter_test.go | 8 ++++---- 6 files changed, 32 insertions(+), 32 deletions(-) diff --git a/cmd/helm/history.go b/cmd/helm/history.go index 8e355c56e..99f3444eb 100644 --- a/cmd/helm/history.go +++ b/cmd/helm/history.go @@ -19,7 +19,7 @@ package main import ( "fmt" "io" - stdtime "time" + "time" "github.com/gosuri/uitable" "github.com/spf13/cobra" @@ -30,7 +30,7 @@ import ( "helm.sh/helm/v3/pkg/cli/output" "helm.sh/helm/v3/pkg/release" "helm.sh/helm/v3/pkg/releaseutil" - "helm.sh/helm/v3/pkg/time" + helmtime "helm.sh/helm/v3/pkg/time" ) var historyHelp = ` @@ -77,12 +77,12 @@ func newHistoryCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { } type releaseInfo struct { - Revision int `json:"revision"` - Updated time.Time `json:"updated"` - Status string `json:"status"` - Chart string `json:"chart"` - AppVersion string `json:"app_version"` - Description string `json:"description"` + Revision int `json:"revision"` + Updated helmtime.Time `json:"updated"` + Status string `json:"status"` + Chart string `json:"chart"` + AppVersion string `json:"app_version"` + Description string `json:"description"` } type releaseHistory []releaseInfo @@ -99,7 +99,7 @@ func (r releaseHistory) WriteTable(out io.Writer) error { tbl := uitable.New() tbl.AddRow("REVISION", "UPDATED", "STATUS", "CHART", "APP VERSION", "DESCRIPTION") for _, item := range r { - tbl.AddRow(item.Revision, item.Updated.Format(stdtime.ANSIC), item.Status, item.Chart, item.AppVersion, item.Description) + tbl.AddRow(item.Revision, item.Updated.Format(time.ANSIC), item.Status, item.Chart, item.AppVersion, item.Description) } return output.EncodeTable(out, tbl) } diff --git a/cmd/helm/status_test.go b/cmd/helm/status_test.go index b5eff833d..91a008e5a 100644 --- a/cmd/helm/status_test.go +++ b/cmd/helm/status_test.go @@ -18,16 +18,16 @@ package main import ( "testing" - stdtime "time" + "time" "helm.sh/helm/v3/pkg/chart" "helm.sh/helm/v3/pkg/release" - "helm.sh/helm/v3/pkg/time" + helmtime "helm.sh/helm/v3/pkg/time" ) func TestStatusCmd(t *testing.T) { releasesMockWithStatus := func(info *release.Info, hooks ...*release.Hook) []*release.Release { - info.LastDeployed = time.Unix(1452902400, 0).UTC() + info.LastDeployed = helmtime.Unix(1452902400, 0).UTC() return []*release.Release{{ Name: "flummoxed-chickadee", Namespace: "default", @@ -104,7 +104,7 @@ func TestStatusCmd(t *testing.T) { runTestCmd(t, tests) } -func mustParseTime(t string) time.Time { - res, _ := time.Parse(stdtime.RFC3339, t) +func mustParseTime(t string) helmtime.Time { + res, _ := helmtime.Parse(time.RFC3339, t) return res } diff --git a/pkg/action/hooks.go b/pkg/action/hooks.go index 828ea1dbb..a161f9377 100644 --- a/pkg/action/hooks.go +++ b/pkg/action/hooks.go @@ -18,16 +18,16 @@ package action import ( "bytes" "sort" - stdtime "time" + "time" "github.com/pkg/errors" "helm.sh/helm/v3/pkg/release" - "helm.sh/helm/v3/pkg/time" + helmtime "helm.sh/helm/v3/pkg/time" ) // execHook executes all of the hooks for the given hook event. -func (cfg *Configuration) execHook(rl *release.Release, hook release.HookEvent, timeout stdtime.Duration) error { +func (cfg *Configuration) execHook(rl *release.Release, hook release.HookEvent, timeout time.Duration) error { executingHooks := []*release.Hook{} for _, h := range rl.Hooks { @@ -61,7 +61,7 @@ func (cfg *Configuration) execHook(rl *release.Release, hook release.HookEvent, // Record the time at which the hook was applied to the cluster h.LastRun = release.HookExecution{ - StartedAt: time.Now(), + StartedAt: helmtime.Now(), Phase: release.HookPhaseRunning, } cfg.recordRelease(rl) @@ -73,7 +73,7 @@ func (cfg *Configuration) execHook(rl *release.Release, hook release.HookEvent, // Create hook resources if _, err := cfg.KubeClient.Create(resources); err != nil { - h.LastRun.CompletedAt = time.Now() + h.LastRun.CompletedAt = helmtime.Now() h.LastRun.Phase = release.HookPhaseFailed return errors.Wrapf(err, "warning: Hook %s %s failed", hook, h.Path) } @@ -81,7 +81,7 @@ func (cfg *Configuration) execHook(rl *release.Release, hook release.HookEvent, // Watch hook resources until they have completed err = cfg.KubeClient.WatchUntilReady(resources, timeout) // Note the time of success/failure - h.LastRun.CompletedAt = time.Now() + h.LastRun.CompletedAt = helmtime.Now() // Mark hook as succeeded or failed if err != nil { h.LastRun.Phase = release.HookPhaseFailed diff --git a/pkg/action/rollback.go b/pkg/action/rollback.go index eebc67d7c..942c9d8af 100644 --- a/pkg/action/rollback.go +++ b/pkg/action/rollback.go @@ -20,12 +20,12 @@ import ( "bytes" "fmt" "strings" - stdtime "time" + "time" "github.com/pkg/errors" "helm.sh/helm/v3/pkg/release" - "helm.sh/helm/v3/pkg/time" + helmtime "helm.sh/helm/v3/pkg/time" ) // Rollback is the action for rolling back to a given release. @@ -35,7 +35,7 @@ type Rollback struct { cfg *Configuration Version int - Timeout stdtime.Duration + Timeout time.Duration Wait bool DisableHooks bool DryRun bool @@ -120,7 +120,7 @@ func (r *Rollback) prepareRollback(name string) (*release.Release, *release.Rele Config: previousRelease.Config, Info: &release.Info{ FirstDeployed: currentRelease.Info.FirstDeployed, - LastDeployed: time.Now(), + LastDeployed: helmtime.Now(), Status: release.StatusPendingRollback, Notes: previousRelease.Info.Notes, // Because we lose the reference to previous version elsewhere, we set the diff --git a/pkg/action/uninstall.go b/pkg/action/uninstall.go index 21c237709..fb72a845b 100644 --- a/pkg/action/uninstall.go +++ b/pkg/action/uninstall.go @@ -18,13 +18,13 @@ package action import ( "strings" - stdtime "time" + "time" "github.com/pkg/errors" "helm.sh/helm/v3/pkg/release" "helm.sh/helm/v3/pkg/releaseutil" - "helm.sh/helm/v3/pkg/time" + helmtime "helm.sh/helm/v3/pkg/time" ) // Uninstall is the action for uninstalling releases. @@ -36,7 +36,7 @@ type Uninstall struct { DisableHooks bool DryRun bool KeepHistory bool - Timeout stdtime.Duration + Timeout time.Duration } // NewUninstall creates a new Uninstall object with the given configuration. @@ -90,7 +90,7 @@ func (u *Uninstall) Run(name string) (*release.UninstallReleaseResponse, error) u.cfg.Log("uninstall: Deleting %s", name) rel.Info.Status = release.StatusUninstalling - rel.Info.Deleted = time.Now() + rel.Info.Deleted = helmtime.Now() rel.Info.Description = "Deletion in progress (or silently failed)" res := &release.UninstallReleaseResponse{Release: rel} diff --git a/pkg/releaseutil/sorter_test.go b/pkg/releaseutil/sorter_test.go index 5db8bb1d7..69a6543ad 100644 --- a/pkg/releaseutil/sorter_test.go +++ b/pkg/releaseutil/sorter_test.go @@ -18,10 +18,10 @@ package releaseutil // import "helm.sh/helm/v3/pkg/releaseutil" import ( "testing" - stdtime "time" + "time" rspb "helm.sh/helm/v3/pkg/release" - "helm.sh/helm/v3/pkg/time" + helmtime "helm.sh/helm/v3/pkg/time" ) // note: this test data is shared with filter_test.go. @@ -33,8 +33,8 @@ var releases = []*rspb.Release{ tsRelease("vocal-dogs", 3, 6000, rspb.StatusUninstalled), } -func tsRelease(name string, vers int, dur stdtime.Duration, status rspb.Status) *rspb.Release { - info := &rspb.Info{Status: status, LastDeployed: time.Now().Add(dur)} +func tsRelease(name string, vers int, dur time.Duration, status rspb.Status) *rspb.Release { + info := &rspb.Info{Status: status, LastDeployed: helmtime.Now().Add(dur)} return &rspb.Release{ Name: name, Version: vers,