From b52cda1806e23673b6ddfc671ac4872aaac5fa7b Mon Sep 17 00:00:00 2001 From: Jason Schroeder Date: Tue, 20 May 2025 20:00:21 -0700 Subject: [PATCH 1/2] refactor: avoid deprecated methods --- view/operation.go | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/view/operation.go b/view/operation.go index 3f66e46..e885b80 100644 --- a/view/operation.go +++ b/view/operation.go @@ -272,57 +272,66 @@ func renderExecutedActionMetadata(em *reapi.ExecutedActionMetadata, workerSelect } var qt, wst, wct, ifst, ifct, est, ect, oust, ouct time.Time var err error - if qt, err = ptypes.Timestamp(em.QueuedTimestamp); err != nil { + if err = em.QueuedTimestamp.CheckValid(); err != nil { text += err.Error() + "\n" return text } + qt = em.QueuedTimestamp.AsTime() if em.WorkerStartTimestamp != nil { - if wst, err = ptypes.Timestamp(em.WorkerStartTimestamp); err != nil { + if err = em.WorkerStartTimestamp.CheckValid(); err != nil { text += err.Error() + "\n" return text } + wst = em.WorkerStartTimestamp.AsTime() } if em.WorkerCompletedTimestamp != nil { - if wct, err = ptypes.Timestamp(em.WorkerCompletedTimestamp); err != nil { + if err = em.WorkerCompletedTimestamp.CheckValid(); err != nil { text += err.Error() + "\n" return text } + wct = em.WorkerCompletedTimestamp.AsTime() } if em.InputFetchStartTimestamp != nil { - if ifst, err = ptypes.Timestamp(em.InputFetchStartTimestamp); err != nil { + if err = em.InputFetchStartTimestamp.CheckValid(); err != nil { text += err.Error() + "\n" return text } + ifst = em.InputFetchStartTimestamp.AsTime() } if em.InputFetchCompletedTimestamp != nil { - if ifct, err = ptypes.Timestamp(em.InputFetchCompletedTimestamp); err != nil { + if err = em.InputFetchCompletedTimestamp.CheckValid(); err != nil { text += err.Error() + "\n" return text } + ifct = em.InputFetchCompletedTimestamp.AsTime() } if em.ExecutionStartTimestamp != nil { - if est, err = ptypes.Timestamp(em.ExecutionStartTimestamp); err != nil { + if err = em.ExecutionStartTimestamp.CheckValid(); err != nil { text += err.Error() + "\n" return text } + est = em.ExecutionStartTimestamp.AsTime() } if em.ExecutionCompletedTimestamp != nil { - if ect, err = ptypes.Timestamp(em.ExecutionCompletedTimestamp); err != nil { + if err = em.ExecutionCompletedTimestamp.CheckValid(); err != nil { text += err.Error() + "\n" return text } + ect = em.ExecutionCompletedTimestamp.AsTime() } if em.OutputUploadStartTimestamp != nil { - if oust, err = ptypes.Timestamp(em.OutputUploadStartTimestamp); err != nil { + if err = em.OutputUploadStartTimestamp.CheckValid(); err != nil { text += err.Error() + "\n" return text } + oust = em.OutputUploadStartTimestamp.AsTime() } if em.OutputUploadCompletedTimestamp != nil { - if ouct, err = ptypes.Timestamp(em.OutputUploadCompletedTimestamp); err != nil { + if err = em.OutputUploadCompletedTimestamp.CheckValid(); err != nil { text += err.Error() + "\n" return text } + ouct = em.OutputUploadCompletedTimestamp.AsTime() } text += fmt.Sprintf("queued at: %s\n", formatTime(qt)) var qstall time.Duration From 0c1269e16ac8a5df8f07478f4e30fab7548400ae Mon Sep 17 00:00:00 2001 From: Jason Schroeder Date: Wed, 21 May 2025 17:05:16 -0700 Subject: [PATCH 2/2] refactor: avoid ptypes.Is --- client/operation.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/client/operation.go b/client/operation.go index 60fdf01..74b5c27 100644 --- a/client/operation.go +++ b/client/operation.go @@ -19,12 +19,12 @@ func ExecuteOperationMetadata(op *longrunning.Operation) (*reapi.ExecuteOperatio m := op.Metadata em := &reapi.ExecuteOperationMetadata{} qm := &bfpb.QueuedOperationMetadata{} - if ptypes.Is(m, em) { + if m.MessageIs(em) { if err := ptypes.UnmarshalAny(m, em); err != nil { return nil, err } return em, nil - } else if ptypes.Is(m, qm) { + } else if m.MessageIs(qm) { if err := ptypes.UnmarshalAny(m, qm); err != nil { return nil, err } @@ -37,9 +37,9 @@ func RequestMetadata(o *longrunning.Operation) *reapi.RequestMetadata { m := o.Metadata em := &reapi.ExecuteOperationMetadata{} qm := &bfpb.QueuedOperationMetadata{} - if ptypes.Is(m, em) { + if m.MessageIs(em) { return nil - } else if ptypes.Is(m, qm) { + } else if m.MessageIs(qm) { if err := ptypes.UnmarshalAny(m, qm); err != nil { return nil } else { @@ -54,7 +54,7 @@ func ExecutedActionMetadata(o *longrunning.Operation) (*reapi.ExecutedActionMeta switch r := o.Result.(type) { case *longrunning.Operation_Response: er := &reapi.ExecuteResponse{} - if ptypes.Is(r.Response, er) { + if r.Response.MessageIs(er) { err := ptypes.UnmarshalAny(r.Response, er) if err == nil && er.Result != nil { if er.Result.ExecutionMetadata == nil {