Skip to content

Commit

Permalink
upgrade ptypes.TimestampProto to timestamppb.New
Browse files Browse the repository at this point in the history
Signed-off-by: arcolife <[email protected]>
  • Loading branch information
arcolife authored and gauravgahlot committed Jun 2, 2021
1 parent 836244b commit 1fc2cec
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
10 changes: 5 additions & 5 deletions db/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import (
"fmt"
"time"

"github.com/golang/protobuf/ptypes"
"github.com/golang/protobuf/ptypes/timestamp"
"github.com/google/uuid"
"github.com/pkg/errors"
tb "github.com/tinkerbell/tink/protos/template"
wflow "github.com/tinkerbell/tink/workflow"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"google.golang.org/protobuf/types/known/timestamppb"
)

// CreateTemplate creates a new workflow template
Expand Down Expand Up @@ -83,8 +83,8 @@ func (d TinkDB) GetTemplate(ctx context.Context, fields map[string]string, delet
)
err = row.Scan(&id, &name, &data, &createdAt, &updatedAt)
if err == nil {
crAt, _ := ptypes.TimestampProto(createdAt)
upAt, _ := ptypes.TimestampProto(updatedAt)
crAt := timestamppb.New(createdAt)
upAt := timestamppb.New(updatedAt)
return &tb.WorkflowTemplate{
Id: id,
Name: name,
Expand Down Expand Up @@ -160,8 +160,8 @@ func (d TinkDB) ListTemplates(filter string, fn func(id, n string, in, del *time
return err
}

tCr, _ := ptypes.TimestampProto(createdAt)
tUp, _ := ptypes.TimestampProto(updatedAt)
tCr := timestamppb.New(createdAt)
tUp := timestamppb.New(updatedAt)
err = fn(id, name, tCr, tUp)
if err != nil {
return err
Expand Down
12 changes: 6 additions & 6 deletions db/workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ import (
"strings"
"time"

"github.com/golang/protobuf/ptypes"
"github.com/golang/protobuf/ptypes/timestamp"
"github.com/google/uuid"
"github.com/pkg/errors"
pb "github.com/tinkerbell/tink/protos/workflow"
wflow "github.com/tinkerbell/tink/workflow"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"google.golang.org/protobuf/types/known/timestamppb"
)

// Workflow represents a workflow instance in database
Expand Down Expand Up @@ -351,8 +351,8 @@ func (d TinkDB) GetWorkflow(ctx context.Context, id string) (Workflow, error) {
)
err := row.Scan(&tmp, &tar, &crAt, &upAt)
if err == nil {
createdAt, _ := ptypes.TimestampProto(crAt)
updatedAt, _ := ptypes.TimestampProto(upAt)
createdAt := timestamppb.New(crAt)
updatedAt := timestamppb.New(upAt)
return Workflow{
ID: id,
Template: tmp,
Expand Down Expand Up @@ -449,8 +449,8 @@ func (d TinkDB) ListWorkflows(fn func(wf Workflow) error) error {
Template: tmp,
Hardware: tar,
}
wf.CreatedAt, _ = ptypes.TimestampProto(crAt)
wf.UpdatedAt, _ = ptypes.TimestampProto(upAt)
wf.CreatedAt = timestamppb.New(crAt)
wf.UpdatedAt = timestamppb.New(upAt)
err = fn(wf)
if err != nil {
return err
Expand Down Expand Up @@ -645,7 +645,7 @@ func (d TinkDB) ShowWorkflowEvents(wfID string, fn func(wfs *pb.WorkflowActionSt
d.logger.Error(err)
return err
}
createdAt, _ := ptypes.TimestampProto(evTime)
createdAt := timestamppb.New(evTime)
wfs := &pb.WorkflowActionStatus{
WorkerId: id,
TaskName: tName,
Expand Down

0 comments on commit 1fc2cec

Please sign in to comment.