util: remove time.go

The same function is already provided by pointer.go
This commit is contained in:
Simone Gotti 2019-08-01 14:14:56 +02:00
parent e48a28d5b9
commit d0c5621201
5 changed files with 15 additions and 36 deletions

View File

@ -779,9 +779,9 @@ func (e *Executor) executeTask(ctx context.Context, et *types.ExecutorTask) {
}()
et.Status.Phase = types.ExecutorTaskPhaseRunning
et.Status.StartTime = util.TimePtr(time.Now())
et.Status.StartTime = util.TimeP(time.Now())
et.Status.SetupStep.Phase = types.ExecutorTaskPhaseRunning
et.Status.SetupStep.StartTime = util.TimePtr(time.Now())
et.Status.SetupStep.StartTime = util.TimeP(time.Now())
if err := e.sendExecutorTaskStatus(ctx, et); err != nil {
log.Errorf("err: %+v", err)
}
@ -789,9 +789,9 @@ func (e *Executor) executeTask(ctx context.Context, et *types.ExecutorTask) {
if err := e.setupTask(ctx, rt); err != nil {
log.Errorf("err: %+v", err)
et.Status.Phase = types.ExecutorTaskPhaseFailed
et.Status.EndTime = util.TimePtr(time.Now())
et.Status.EndTime = util.TimeP(time.Now())
et.Status.SetupStep.Phase = types.ExecutorTaskPhaseFailed
et.Status.SetupStep.EndTime = util.TimePtr(time.Now())
et.Status.SetupStep.EndTime = util.TimeP(time.Now())
if err := e.sendExecutorTaskStatus(ctx, et); err != nil {
log.Errorf("err: %+v", err)
}
@ -800,7 +800,7 @@ func (e *Executor) executeTask(ctx context.Context, et *types.ExecutorTask) {
}
et.Status.SetupStep.Phase = types.ExecutorTaskPhaseSuccess
et.Status.SetupStep.EndTime = util.TimePtr(time.Now())
et.Status.SetupStep.EndTime = util.TimeP(time.Now())
if err := e.sendExecutorTaskStatus(ctx, et); err != nil {
log.Errorf("err: %+v", err)
}
@ -817,7 +817,7 @@ func (e *Executor) executeTask(ctx context.Context, et *types.ExecutorTask) {
et.Status.Phase = types.ExecutorTaskPhaseSuccess
}
et.Status.EndTime = util.TimePtr(time.Now())
et.Status.EndTime = util.TimeP(time.Now())
if err := e.sendExecutorTaskStatus(ctx, et); err != nil {
log.Errorf("err: %+v", err)
@ -916,7 +916,7 @@ func (e *Executor) executeTaskSteps(ctx context.Context, rt *runningTask, pod dr
for i, step := range rt.et.Steps {
rt.Lock()
rt.et.Status.Steps[i].Phase = types.ExecutorTaskPhaseRunning
rt.et.Status.Steps[i].StartTime = util.TimePtr(time.Now())
rt.et.Status.Steps[i].StartTime = util.TimeP(time.Now())
if err := e.sendExecutorTaskStatus(ctx, rt.et); err != nil {
log.Errorf("err: %+v", err)
}
@ -961,7 +961,7 @@ func (e *Executor) executeTaskSteps(ctx context.Context, rt *runningTask, pod dr
var serr error
rt.Lock()
rt.et.Status.Steps[i].EndTime = util.TimePtr(time.Now())
rt.et.Status.Steps[i].EndTime = util.TimeP(time.Now())
rt.et.Status.Steps[i].Phase = types.ExecutorTaskPhaseSuccess
@ -1162,12 +1162,12 @@ func (e *Executor) taskUpdater(ctx context.Context, et *types.ExecutorTask) {
if !ok {
log.Infof("marking executor task %s as failed since there's no running task", et.ID)
et.Status.Phase = types.ExecutorTaskPhaseFailed
et.Status.EndTime = util.TimePtr(time.Now())
et.Status.EndTime = util.TimeP(time.Now())
// mark in progress step as failed too
for _, s := range et.Status.Steps {
if s.Phase == types.ExecutorTaskPhaseRunning {
s.Phase = types.ExecutorTaskPhaseFailed
s.EndTime = util.TimePtr(time.Now())
s.EndTime = util.TimeP(time.Now())
}
}
if err := e.sendExecutorTaskStatus(ctx, et); err != nil {

View File

@ -395,7 +395,7 @@ func (h *ActionHandler) saveRun(ctx context.Context, rb *types.RunBundle, runcgt
c++
run.Counter = c
run.EnqueueTime = util.TimePtr(time.Now())
run.EnqueueTime = util.TimeP(time.Now())
actions := []*datamanager.Action{}

View File

@ -838,11 +838,11 @@ func (s *Runservice) executorTaskCleaner(ctx context.Context, et *types.Executor
log.Warnf("executor with id %q doesn't exist. marking executor task %q as failed", et.Status.ExecutorID, et.ID)
et.FailError = "executor deleted"
et.Status.Phase = types.ExecutorTaskPhaseFailed
et.Status.EndTime = util.TimePtr(time.Now())
et.Status.EndTime = util.TimeP(time.Now())
for _, s := range et.Status.Steps {
if s.Phase == types.ExecutorTaskPhaseRunning {
s.Phase = types.ExecutorTaskPhaseFailed
s.EndTime = util.TimePtr(time.Now())
s.EndTime = util.TimeP(time.Now())
}
}
if _, err := store.AtomicPutExecutorTask(ctx, s.e, et); err != nil {

View File

@ -142,9 +142,9 @@ func (r *Run) ChangePhase(phase RunPhase) {
r.Phase = phase
switch {
case phase == RunPhaseRunning:
r.StartTime = util.TimePtr(time.Now())
r.StartTime = util.TimeP(time.Now())
case phase.IsFinished():
r.EndTime = util.TimePtr(time.Now())
r.EndTime = util.TimeP(time.Now())
}
}

View File

@ -1,21 +0,0 @@
// Copyright 2019 Sorint.lab
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied
// See the License for the specific language governing permissions and
// limitations under the License.
package util
import "time"
func TimePtr(t time.Time) *time.Time {
return &t
}