Update and address protobuf package deprecations

These changes address the following warning showing up on `go get`
operations:

    go: module github.com/golang/protobuf is deprecated: Use the
    "google.golang.org/protobuf" module instead.

All changes are made using the recommendations in the per-function
deprecation notices from the docs at
https://pkg.go.dev/github.com/golang/protobuf/ptypes
This commit is contained in:
Paul Hinze 2022-06-08 11:51:19 -05:00
parent 00829ba9e6
commit 8b5d4b8631
No known key found for this signature in database
GPG Key ID: B69DEDF2D55501C0
41 changed files with 100 additions and 141 deletions

View File

@ -3,7 +3,6 @@ package push
import (
"encoding/json"
"github.com/golang/protobuf/ptypes"
"github.com/hashicorp/vagrant-plugin-sdk/component"
"github.com/hashicorp/vagrant-plugin-sdk/core"
"github.com/hashicorp/vagrant-plugin-sdk/proto/vagrant_plugin_sdk"
@ -72,7 +71,7 @@ func findPushConfig(proj core.Project, name string) (*vagrant_plugin_sdk.Vagrant
func unpackConfig(pc *vagrant_plugin_sdk.Vagrantfile_PushConfig) (map[string]interface{}, error) {
gc := pc.GetConfig()
s := &structpb.Struct{}
err := ptypes.UnmarshalAny(gc.GetConfig(), s)
err := gc.GetConfig().UnmarshalTo(s)
if err != nil {
return nil, err
}

5
go.mod
View File

@ -27,7 +27,6 @@ require (
github.com/gofrs/flock v0.8.0
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.2
github.com/google/uuid v1.1.2
github.com/gorilla/handlers v1.4.2
github.com/gorilla/mux v1.7.4 // indirect
@ -40,7 +39,7 @@ require (
github.com/hashicorp/go-memdb v1.2.0
github.com/hashicorp/go-multierror v1.1.1
github.com/hashicorp/go-plugin v1.3.0
github.com/hashicorp/go-retryablehttp v0.7.1 // indirect
github.com/hashicorp/go-retryablehttp v0.7.1
github.com/hashicorp/go-uuid v1.0.2 // indirect
github.com/hashicorp/go-version v1.3.0
github.com/hashicorp/golang-lru v0.5.4 // indirect
@ -90,7 +89,7 @@ require (
google.golang.org/api v0.60.0 // indirect
google.golang.org/genproto v0.0.0-20211116182654-e63d96a377c4
google.golang.org/grpc v1.42.0
google.golang.org/protobuf v1.27.1
google.golang.org/protobuf v1.28.0
gotest.tools/v3 v3.0.2 // indirect
k8s.io/api v0.18.0
k8s.io/apimachinery v0.18.0

5
go.sum
View File

@ -357,8 +357,6 @@ github.com/hashicorp/hcl/v2 v2.7.1-0.20201023000745-3de61ecba298 h1:pLsdnvAlWuZ9
github.com/hashicorp/hcl/v2 v2.7.1-0.20201023000745-3de61ecba298/go.mod h1:bQTN5mpo+jewjJgh8jr0JUguIi7qPHUF6yIfAEN3jqY=
github.com/hashicorp/nomad/api v0.0.0-20200814140818-42de70466a9d h1:afuZ/KNbxwUgjEzq2NXO2bRKZgsIJQgFxgIRGETF0/A=
github.com/hashicorp/nomad/api v0.0.0-20200814140818-42de70466a9d/go.mod h1:DCi2k47yuUDzf2qWAK8E1RVmWgz/lc0jZQeEnICTxmY=
github.com/hashicorp/vagrant-plugin-sdk v0.0.0-20220607203748-0546ea7b960a h1:YnR55U5cR2D+mXBMoShBhNUMTc5pEvwF9aHbY3RnO10=
github.com/hashicorp/vagrant-plugin-sdk v0.0.0-20220607203748-0546ea7b960a/go.mod h1:KWfWOiotOWKiAqdroXVc7GUFnuOzlzhnRkGTV9Js7/s=
github.com/hashicorp/vagrant-plugin-sdk v0.0.0-20220608152900-0d37aacebd23 h1:tTQgBDfk6PugU3YsKh/kPjbrfUgahovKFvGkCyVYBo0=
github.com/hashicorp/vagrant-plugin-sdk v0.0.0-20220608152900-0d37aacebd23/go.mod h1:KWfWOiotOWKiAqdroXVc7GUFnuOzlzhnRkGTV9Js7/s=
github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM=
@ -920,8 +918,9 @@ google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGj
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.27.1 h1:SnqbnDw1V7RiZcXPx5MEeqPv2s79L9i7BJUlG/+RurQ=
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw=
google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=

View File

@ -10,11 +10,11 @@ import (
"strings"
"time"
"github.com/golang/protobuf/ptypes/empty"
"github.com/hashicorp/go-plugin"
"github.com/hashicorp/vagrant-plugin-sdk/helper/paths"
bolt "go.etcd.io/bbolt"
"google.golang.org/grpc"
"google.golang.org/protobuf/types/known/emptypb"
"github.com/hashicorp/vagrant/internal/protocolversion"
"github.com/hashicorp/vagrant/internal/server"
@ -213,7 +213,7 @@ func (c *Client) initVagrantRubyRuntime() (rubyRuntime plugin.ClientProtocol, er
// that we are compatible to talk to the server.
func (c *Client) negotiateApiVersion(ctx context.Context) error {
c.logger.Trace("requesting version info from server")
resp, err := c.client.GetVersionInfo(ctx, &empty.Empty{})
resp, err := c.client.GetVersionInfo(ctx, &emptypb.Empty{})
if err != nil {
return err
}

View File

@ -1,23 +1,18 @@
package core
import (
"github.com/golang/protobuf/ptypes"
"github.com/golang/protobuf/ptypes/any"
"github.com/hashicorp/go-argmapper"
"google.golang.org/protobuf/types/known/anypb"
)
// argNamedAny returns an argmapper.Arg that specifies the Any value
// with the proper subtype.
func argNamedAny(n string, v *any.Any) argmapper.Arg {
func argNamedAny(n string, v *anypb.Any) argmapper.Arg {
if v == nil {
return nil
}
msg, err := ptypes.AnyMessageName(v)
if err != nil {
// This should never happen.
panic(err)
}
msg := string(v.MessageName())
return argmapper.NamedSubtype(n, v, msg)
}

View File

@ -8,7 +8,7 @@ import (
"strings"
"sync"
"github.com/golang/protobuf/proto"
"google.golang.org/protobuf/proto"
"github.com/hashicorp/go-argmapper"
"github.com/hashicorp/go-hclog"
"github.com/hashicorp/go-multierror"

View File

@ -5,9 +5,9 @@ import (
"fmt"
"reflect"
"github.com/golang/protobuf/proto"
"github.com/golang/protobuf/ptypes/any"
"github.com/hashicorp/go-hclog"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/types/known/anypb"
"github.com/hashicorp/vagrant-plugin-sdk/component"
"github.com/hashicorp/vagrant-plugin-sdk/terminal"
@ -47,7 +47,7 @@ type operation interface {
// StatusPtr and ValuePtr return pointers to the fields in the message
// for the status and values respectively.
StatusPtr(proto.Message) **vagrant_server.Status
ValuePtr(proto.Message) **any.Any
ValuePtr(proto.Message) **anypb.Any
// Hooks are the hooks to execute as part of this operation keyed by "when"
Hooks(scope) map[string][]*config.Hook
@ -107,7 +107,7 @@ func doOperation(
// to a local value if we get nil so that we can avoid nil checks.
valuePtr := op.ValuePtr(msg)
if valuePtr == nil {
var value *any.Any
var value *anypb.Any
valuePtr = &value
}

View File

@ -9,7 +9,7 @@ import (
"strings"
"sync"
"github.com/golang/protobuf/proto"
"google.golang.org/protobuf/proto"
"github.com/hashicorp/go-argmapper"
"github.com/hashicorp/go-hclog"
"github.com/hashicorp/go-multierror"

View File

@ -10,13 +10,12 @@ import (
"sync"
"time"
"github.com/golang/protobuf/proto"
"github.com/golang/protobuf/ptypes"
"github.com/hashicorp/go-argmapper"
"github.com/hashicorp/go-hclog"
"github.com/hashicorp/go-multierror"
"github.com/hashicorp/vagrant/internal/config"
"github.com/hashicorp/vagrant/internal/serverclient"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/types/known/anypb"
"github.com/hashicorp/vagrant-plugin-sdk/component"
@ -353,7 +352,7 @@ func (t *Target) Machine() core.Machine {
}
targetMachine := &vagrant_server.Target_Machine{}
ptypes.UnmarshalAny(t.target.Record, targetMachine)
t.target.Record.UnmarshalTo(targetMachine)
m := &Machine{
Target: t,
logger: t.logger,

View File

@ -4,7 +4,6 @@ import (
"context"
"fmt"
"github.com/golang/protobuf/ptypes/empty"
"github.com/hashicorp/go-hclog"
"github.com/hashicorp/vagrant-plugin-sdk/core"
"github.com/hashicorp/vagrant-plugin-sdk/proto/vagrant_plugin_sdk"
@ -12,6 +11,7 @@ import (
"github.com/hashicorp/vagrant/internal/serverclient"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"google.golang.org/protobuf/types/known/emptypb"
)
// TargetIndex represents
@ -79,7 +79,7 @@ func (t *TargetIndex) Set(entry core.Target) (updatedEntry core.Target, err erro
}
func (t *TargetIndex) All() (targets []core.Target, err error) {
list, err := t.client.ListTargets(t.ctx, &empty.Empty{})
list, err := t.client.ListTargets(t.ctx, &emptypb.Empty{})
if err != nil {
return
}

View File

@ -33,7 +33,7 @@ import (
"errors"
"io"
"github.com/golang/protobuf/proto"
"google.golang.org/protobuf/proto"
)
var (

View File

@ -9,7 +9,7 @@ package execclient
// "os/signal"
// "github.com/containerd/console"
// "github.com/golang/protobuf/proto"
// "google.golang.org/protobuf/proto"
// "github.com/hashicorp/go-hclog"
// grpc_net_conn "github.com/mitchellh/go-grpc-net-conn"
// sshterm "golang.org/x/crypto/ssh/terminal"

View File

@ -3,10 +3,10 @@ package server
import (
"time"
"github.com/golang/protobuf/ptypes/empty"
"github.com/oklog/run"
"google.golang.org/grpc"
"google.golang.org/grpc/reflection"
"google.golang.org/protobuf/types/known/emptypb"
"github.com/hashicorp/vagrant/internal/server/proto/vagrant_server"
)
@ -16,7 +16,7 @@ func grpcInit(group *run.Group, opts *options) error {
log := opts.Logger.Named("grpc")
// Get our server info immediately
resp, err := opts.Service.GetVersionInfo(opts.Context, &empty.Empty{})
resp, err := opts.Service.GetVersionInfo(opts.Context, &emptypb.Empty{})
if err != nil {
return err
}

View File

@ -3,8 +3,6 @@ package logviewer
import (
"context"
"github.com/golang/protobuf/ptypes"
"github.com/hashicorp/vagrant-plugin-sdk/component"
"github.com/hashicorp/vagrant/internal/server/proto/vagrant_server"
)
@ -30,7 +28,7 @@ func (v *Viewer) NextLogBatch(ctx context.Context) ([]component.LogEvent, error)
events := make([]component.LogEvent, len(batch.Lines))
for i, entry := range batch.Lines {
ts, _ := ptypes.Timestamp(entry.Timestamp)
ts := entry.Timestamp.AsTime()
events[i] = component.LogEvent{
Partition: batch.InstanceId,

View File

@ -3,7 +3,7 @@ package ptypes
// import (
// "time"
// "github.com/golang/protobuf/ptypes"
// "google.golang.org/protobuf/ptypes"
// "github.com/imdario/mergo"
// "github.com/mitchellh/go-testing-interface"
// "github.com/stretchr/testify/require"

View File

@ -9,14 +9,14 @@ import (
"strings"
"time"
"github.com/golang/protobuf/proto"
"github.com/golang/protobuf/ptypes/empty"
"github.com/golang/protobuf/ptypes/timestamp"
"github.com/mr-tron/base58"
"github.com/pkg/errors"
"golang.org/x/crypto/blake2b"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/types/known/emptypb"
"google.golang.org/protobuf/types/known/timestamppb"
"github.com/hashicorp/vagrant/internal/server/proto/vagrant_server"
)
@ -199,7 +199,7 @@ func (s *service) NewLoginToken(
}
// Create a new login token. This is just a gRPC wrapper around NewLoginToken.
func (s *service) GenerateLoginToken(ctx context.Context, _ *empty.Empty) (*vagrant_server.NewTokenResponse, error) {
func (s *service) GenerateLoginToken(ctx context.Context, _ *emptypb.Empty) (*vagrant_server.NewTokenResponse, error) {
token, err := s.NewLoginToken(DefaultKeyId, nil, nil)
if err != nil {
return nil, err
@ -223,7 +223,7 @@ func (s *service) NewInviteToken(
body.Entrypoint = entrypoint
now := time.Now().UTC().Add(duration)
body.ValidUntil = &timestamp.Timestamp{
body.ValidUntil = &timestamppb.Timestamp{
Seconds: now.Unix(),
Nanos: int32(now.Nanosecond()),
}
@ -275,7 +275,7 @@ func (s *service) ConvertInviteToken(ctx context.Context, req *vagrant_server.Co
return &vagrant_server.NewTokenResponse{Token: token}, nil
}
func (s *service) BootstrapToken(ctx context.Context, req *empty.Empty) (*vagrant_server.NewTokenResponse, error) {
func (s *service) BootstrapToken(ctx context.Context, req *emptypb.Empty) (*vagrant_server.NewTokenResponse, error) {
if !s.state.HMACKeyEmpty() {
return nil, status.Errorf(codes.PermissionDenied, "server is already bootstrapped")
}

View File

@ -6,14 +6,14 @@ import (
"testing"
"time"
"github.com/golang/protobuf/proto"
"github.com/golang/protobuf/ptypes/empty"
"github.com/mr-tron/base58"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"golang.org/x/crypto/blake2b"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/types/known/emptypb"
"github.com/hashicorp/vagrant/internal/server/proto/vagrant_server"
)
@ -167,14 +167,14 @@ func TestServiceBootstrapToken(t *testing.T) {
{
// Initial bootstrap should return a token
resp, err := impl.BootstrapToken(ctx, &empty.Empty{})
resp, err := impl.BootstrapToken(ctx, &emptypb.Empty{})
require.NoError(err)
require.NotEmpty(resp.Token)
}
{
// Subs calls should fail
resp, err := impl.BootstrapToken(ctx, &empty.Empty{})
resp, err := impl.BootstrapToken(ctx, &emptypb.Empty{})
require.Error(err)
require.Equal(codes.PermissionDenied, status.Code(err))
require.Nil(resp)

View File

@ -3,9 +3,8 @@ package singleprocess
import (
"context"
"github.com/golang/protobuf/ptypes/empty"
"github.com/hashicorp/vagrant/internal/server/proto/vagrant_server"
"google.golang.org/protobuf/types/known/emptypb"
)
func (s *service) UpsertBasis(
@ -45,7 +44,7 @@ func (s *service) FindBasis(
func (s *service) ListBasis(
ctx context.Context,
req *empty.Empty,
req *emptypb.Empty,
) (*vagrant_server.ListBasisResponse, error) {
result, err := s.state.BasisList()
if err != nil {

View File

@ -3,13 +3,13 @@ package singleprocess
import (
"context"
"github.com/golang/protobuf/ptypes/empty"
"github.com/hashicorp/vagrant/internal/server/proto/vagrant_server"
"google.golang.org/protobuf/types/known/emptypb"
)
func (s *service) ListBoxes(
ctx context.Context,
req *empty.Empty,
req *emptypb.Empty,
) (*vagrant_server.ListBoxesResponse, error) {
result, err := s.state.BoxList()
if err != nil {
@ -22,9 +22,9 @@ func (s *service) ListBoxes(
func (s *service) DeleteBox(
ctx context.Context,
req *vagrant_server.DeleteBoxRequest,
) (empt *empty.Empty, err error) {
) (empt *emptypb.Empty, err error) {
err = s.state.BoxDelete(req.Box)
return &empty.Empty{}, nil
return &emptypb.Empty{}, nil
}
func (s *service) GetBox(

View File

@ -4,12 +4,12 @@ import (
"context"
"time"
"github.com/golang/protobuf/ptypes"
"github.com/golang/protobuf/ptypes/empty"
"github.com/hashicorp/go-hclog"
"github.com/hashicorp/go-memdb"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"google.golang.org/protobuf/types/known/emptypb"
"google.golang.org/protobuf/types/known/timestamppb"
"github.com/hashicorp/vagrant/internal/server"
"github.com/hashicorp/vagrant/internal/server/logbuffer"
@ -24,10 +24,10 @@ const (
func (s *service) PruneOldJobs(
ctx context.Context,
_ *empty.Empty,
) (*empty.Empty, error) {
_ *emptypb.Empty,
) (*emptypb.Empty, error) {
_, err := s.state.JobsDBPruneOld(maximumJobsIndexed)
return &empty.Empty{}, err
return &emptypb.Empty{}, err
}
// TODO: test
@ -64,12 +64,12 @@ func (s *service) XListJobs(
func (s *service) CancelJob(
ctx context.Context,
req *vagrant_server.CancelJobRequest,
) (*empty.Empty, error) {
) (*emptypb.Empty, error) {
if err := s.state.JobCancel(req.JobId, false); err != nil {
return nil, err
}
return &empty.Empty{}, nil
return &emptypb.Empty{}, nil
}
func (s *service) QueueJob(
@ -138,10 +138,7 @@ func (s *service) QueueJob(
"Invalid expiry duration: %s", err.Error())
}
job.ExpireTime, err = ptypes.TimestampProto(time.Now().Add(dur))
if err != nil {
return nil, status.Errorf(codes.Aborted, "error configuring expiration: %s", err)
}
job.ExpireTime = timestamppb.New(time.Now().Add(dur))
}
// Queue the job

View File

@ -3,9 +3,8 @@ package singleprocess
import (
"context"
"github.com/golang/protobuf/ptypes/empty"
"github.com/hashicorp/vagrant/internal/server/proto/vagrant_server"
"google.golang.org/protobuf/types/known/emptypb"
)
func (s *service) UpsertProject(
@ -45,7 +44,7 @@ func (s *service) FindProject(
func (s *service) ListProjects(
ctx context.Context,
req *empty.Empty,
req *emptypb.Empty,
) (*vagrant_server.ListProjectsResponse, error) {
result, err := s.state.ProjectList()
if err != nil {

View File

@ -3,9 +3,9 @@ package singleprocess
import (
"context"
"github.com/golang/protobuf/ptypes/empty"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"google.golang.org/protobuf/types/known/emptypb"
"github.com/hashicorp/vagrant/internal/server/proto/vagrant_server"
serverptypes "github.com/hashicorp/vagrant/internal/server/ptypes"
@ -18,7 +18,7 @@ type Targeter interface {
func (s *service) SetServerConfig(
ctx context.Context,
req *vagrant_server.SetServerConfigRequest,
) (*empty.Empty, error) {
) (*emptypb.Empty, error) {
if err := serverptypes.ValidateServerConfig(req.Config); err != nil {
return nil, status.Errorf(codes.FailedPrecondition, err.Error())
}
@ -27,12 +27,12 @@ func (s *service) SetServerConfig(
return nil, err
}
return &empty.Empty{}, nil
return &emptypb.Empty{}, nil
}
func (s *service) GetServerConfig(
ctx context.Context,
req *empty.Empty,
req *emptypb.Empty,
) (*vagrant_server.GetServerConfigResponse, error) {
cfg, err := s.state.ServerConfigGet()
if err != nil {

View File

@ -7,16 +7,16 @@ import (
"io"
"os"
"github.com/golang/protobuf/ptypes/empty"
"github.com/hashicorp/go-hclog"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"google.golang.org/protobuf/types/known/emptypb"
"github.com/hashicorp/vagrant/internal/server/proto/vagrant_server"
)
func (s *service) CreateSnapshot(
req *empty.Empty,
req *emptypb.Empty,
srv vagrant_server.Vagrant_CreateSnapshotServer,
) error {
// Always send the open message. In the future we'll send some metadata here.
@ -108,7 +108,7 @@ func (s *service) RestoreSnapshot(
return err
}
return srv.SendAndClose(&empty.Empty{})
return srv.SendAndClose(&emptypb.Empty{})
case err := <-restoreCloseCh:
// The restore ended
@ -123,7 +123,7 @@ func (s *service) RestoreSnapshot(
os.Exit(2) // kind of a weird exit code to note this was manufactured
}
return srv.SendAndClose(&empty.Empty{})
return srv.SendAndClose(&emptypb.Empty{})
case req, active := <-clientEventCh:
// If we aren't active anymore, then the client closed the connection

View File

@ -6,10 +6,10 @@ import (
"io"
"testing"
"github.com/golang/protobuf/ptypes/empty"
"github.com/stretchr/testify/require"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"google.golang.org/protobuf/types/known/emptypb"
"github.com/hashicorp/vagrant/internal/server"
"github.com/hashicorp/vagrant/internal/server/proto/vagrant_server"
@ -52,7 +52,7 @@ func TestServiceRestoreSnapshot_full(t *testing.T) {
// Take a snapshot and write the contents to a buf
var snapshotBuf bytes.Buffer
{
stream, err := client.CreateSnapshot(ctx, &empty.Empty{})
stream, err := client.CreateSnapshot(ctx, &emptypb.Empty{})
require.NoError(err)
// Should get the open message

View File

@ -3,7 +3,6 @@ package singleprocess
import (
"context"
"github.com/golang/protobuf/ptypes/empty"
"google.golang.org/protobuf/types/known/emptypb"
"github.com/hashicorp/vagrant/internal/server/proto/vagrant_server"
@ -25,7 +24,7 @@ func (s *service) UpsertTarget(
func (s *service) DeleteTarget(
ctx context.Context,
req *vagrant_server.DeleteTargetRequest,
) (empt *empty.Empty, err error) {
) (empt *emptypb.Empty, err error) {
err = s.state.TargetDelete(req.Target)
return &emptypb.Empty{}, err
}
@ -57,7 +56,7 @@ func (s *service) FindTarget(
// TODO: test
func (s *service) ListTargets(
ctx context.Context,
req *empty.Empty,
req *emptypb.Empty,
) (*vagrant_server.ListTargetsResponse, error) {
result, err := s.state.TargetList()
if err != nil {

View File

@ -3,15 +3,14 @@ package singleprocess
import (
"context"
"github.com/golang/protobuf/ptypes/empty"
"github.com/hashicorp/vagrant/internal/protocolversion"
"github.com/hashicorp/vagrant/internal/server/proto/vagrant_server"
"google.golang.org/protobuf/types/known/emptypb"
)
func (s *service) GetVersionInfo(
ctx context.Context,
req *empty.Empty,
req *emptypb.Empty,
) (*vagrant_server.GetVersionInfoResponse, error) {
return &vagrant_server.GetVersionInfoResponse{
Info: protocolversion.Current(),

View File

@ -3,7 +3,7 @@ package state
import (
"strings"
"github.com/golang/protobuf/proto"
"google.golang.org/protobuf/proto"
"github.com/hashicorp/go-memdb"
bolt "go.etcd.io/bbolt"
"google.golang.org/grpc/codes"

View File

@ -1,7 +1,7 @@
package state
import (
"github.com/golang/protobuf/proto"
"google.golang.org/protobuf/proto"
"github.com/hashicorp/go-memdb"
"github.com/hashicorp/go-version"
"github.com/hashicorp/vagrant-plugin-sdk/proto/vagrant_plugin_sdk"

View File

@ -4,7 +4,7 @@ import (
"fmt"
"sort"
"github.com/golang/protobuf/proto"
"google.golang.org/protobuf/proto"
"github.com/hashicorp/go-memdb"
"github.com/hashicorp/vagrant-plugin-sdk/proto/vagrant_plugin_sdk"
bolt "go.etcd.io/bbolt"

View File

@ -4,7 +4,7 @@ import (
"strconv"
"strings"
"github.com/golang/protobuf/proto"
"google.golang.org/protobuf/proto"
bolt "go.etcd.io/bbolt"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"

View File

@ -8,11 +8,10 @@ import (
"sync/atomic"
"time"
"github.com/golang/protobuf/proto"
"github.com/golang/protobuf/ptypes"
"github.com/hashicorp/go-memdb"
"github.com/mitchellh/go-testing-interface"
bolt "go.etcd.io/bbolt"
"google.golang.org/protobuf/proto"
// "github.com/stretchr/testify/require"
"google.golang.org/grpc/codes"
@ -575,21 +574,21 @@ func (op *genericOperation) indexPut(s *State, txn *memdb.Txn, value proto.Messa
statusVal := statusRaw.(*vagrant_server.Status)
if statusVal != nil {
if t := statusVal.StartTime; t != nil {
st, err := ptypes.Timestamp(t)
err := t.CheckValid()
if err != nil {
return status.Errorf(codes.Internal, "time for operation can't be parsed")
}
startTime = st
startTime = t.AsTime()
}
if t := statusVal.CompleteTime; t != nil {
ct, err := ptypes.Timestamp(statusVal.CompleteTime)
err := t.CheckValid()
if err != nil {
return status.Errorf(codes.Internal, "time for operation can't be parsed")
}
completeTime = ct
completeTime = t.AsTime()
}
}
}

View File

@ -5,7 +5,7 @@ import (
"io"
"sync/atomic"
"github.com/golang/protobuf/proto"
"google.golang.org/protobuf/proto"
"github.com/hashicorp/go-memdb"
bolt "go.etcd.io/bbolt"

View File

@ -7,13 +7,12 @@ import (
"sort"
"time"
"github.com/golang/protobuf/proto"
"github.com/golang/protobuf/ptypes"
"github.com/golang/protobuf/ptypes/timestamp"
"github.com/hashicorp/go-memdb"
bolt "go.etcd.io/bbolt"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/types/known/timestamppb"
"github.com/hashicorp/vagrant-plugin-sdk/proto/vagrant_plugin_sdk"
"github.com/hashicorp/vagrant/internal/server/logbuffer"
@ -368,12 +367,7 @@ RETRY_ASSIGN:
job.State = vagrant_server.Job_WAITING
result, err := s.jobReadAndUpdate(job.Id, func(jobpb *vagrant_server.Job) error {
jobpb.State = job.State
jobpb.AssignTime, err = ptypes.TimestampProto(time.Now())
if err != nil {
// This should never happen since encoding a time now should be safe
panic("time encoding failed: " + err.Error())
}
jobpb.AssignTime = timestamppb.New(time.Now())
return nil
})
if err != nil {
@ -434,11 +428,7 @@ func (s *State) JobAck(id string, ack bool) (*Job, error) {
// Set to accepted
job.State = vagrant_server.Job_RUNNING
jobpb.State = job.State
jobpb.AckTime, err = ptypes.TimestampProto(time.Now())
if err != nil {
// This should never happen since encoding a time now should be safe
panic("time encoding failed: " + err.Error())
}
jobpb.AckTime = timestamppb.New(time.Now())
// We also initialize the output buffer here because we can
// expect output to begin streaming in.
@ -525,11 +515,7 @@ func (s *State) JobComplete(id string, result *vagrant_server.Job_Result, cerr e
job.State = vagrant_server.Job_SUCCESS
jobpb.State = job.State
jobpb.Result = result
jobpb.CompleteTime, err = ptypes.TimestampProto(time.Now())
if err != nil {
// This should never happen since encoding a time now should be safe
panic("time encoding failed: " + err.Error())
}
jobpb.CompleteTime = timestamppb.New(time.Now())
if cerr != nil {
job.State = vagrant_server.Job_ERROR
@ -619,13 +605,8 @@ func (s *State) jobCancel(txn *memdb.Txn, job *jobIndex, force bool) error {
// Persist the on-disk data
_, err := s.jobReadAndUpdate(job.Id, func(jobpb *vagrant_server.Job) error {
var err error
jobpb.State = job.State
jobpb.CancelTime, err = ptypes.TimestampProto(time.Now())
if err != nil {
// This should never happen since encoding a time now should be safe
panic("time encoding failed: " + err.Error())
}
jobpb.CancelTime = timestamppb.New(time.Now())
// If we transitioned to the error state we note that we were force
// cancelled. We can only be in the error state under that scenario
@ -848,17 +829,17 @@ func (s *State) jobIndexSet(txn *memdb.Txn, id []byte, jobpb *vagrant_server.Job
// Timestamps
timestamps := []struct {
Field *time.Time
Src *timestamp.Timestamp
Src *timestamppb.Timestamp
}{
{&rec.QueueTime, jobpb.QueueTime},
}
for _, ts := range timestamps {
t, err := ptypes.Timestamp(ts.Src)
err := ts.Src.CheckValid()
if err != nil {
return nil, err
}
*ts.Field = t
*ts.Field = ts.Src.AsTime()
}
// If this job is assigned. Then we have to start a nacking timer.
@ -883,12 +864,12 @@ func (s *State) jobIndexSet(txn *memdb.Txn, id []byte, jobpb *vagrant_server.Job
if jobpb.ExpireTime != nil {
now := time.Now()
t, err := ptypes.Timestamp(jobpb.ExpireTime)
err := jobpb.ExpireTime.CheckValid()
if err != nil {
return nil, err
}
dur := t.Sub(now)
dur := jobpb.ExpireTime.AsTime().Sub(now)
if dur < 0 {
dur = 1
}
@ -904,10 +885,7 @@ func (s *State) jobCreate(dbTxn *bolt.Tx, memTxn *memdb.Txn, jobpb *vagrant_serv
// Setup our initial job state
var err error
jobpb.State = vagrant_server.Job_QUEUED
jobpb.QueueTime, err = ptypes.TimestampProto(time.Now())
if err != nil {
return err
}
jobpb.QueueTime = timestamppb.New(time.Now())
id := []byte(jobpb.Id)

View File

@ -3,7 +3,7 @@ package state
import (
"strings"
"github.com/golang/protobuf/proto"
"google.golang.org/protobuf/proto"
"github.com/hashicorp/go-memdb"
bolt "go.etcd.io/bbolt"
"google.golang.org/grpc/codes"

View File

@ -1,7 +1,7 @@
package state
import (
"github.com/golang/protobuf/proto"
"google.golang.org/protobuf/proto"
"github.com/hashicorp/go-memdb"
bolt "go.etcd.io/bbolt"

View File

@ -1,7 +1,7 @@
package state
import (
"github.com/golang/protobuf/proto"
"google.golang.org/protobuf/proto"
"github.com/google/uuid"
"github.com/hashicorp/go-memdb"
bolt "go.etcd.io/bbolt"

View File

@ -3,7 +3,7 @@ package sort
// import (
// "sort"
// "github.com/golang/protobuf/ptypes"
// "google.golang.org/protobuf/ptypes"
// pb "github.com/hashicorp/vagrant/internal/server/gen"
// )

View File

@ -3,7 +3,7 @@ package sort
// import (
// "sort"
// "github.com/golang/protobuf/ptypes"
// "google.golang.org/protobuf/ptypes"
// pb "github.com/hashicorp/vagrant/internal/server/gen"
// )

View File

@ -3,7 +3,7 @@ package sort
// import (
// "sort"
// "github.com/golang/protobuf/ptypes"
// "google.golang.org/protobuf/ptypes"
// pb "github.com/hashicorp/vagrant/internal/server/gen"
// )

View File

@ -1,9 +1,9 @@
package server
import (
"github.com/golang/protobuf/ptypes"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"google.golang.org/protobuf/types/known/timestamppb"
"github.com/hashicorp/vagrant/internal/server/proto/vagrant_server"
)
@ -12,7 +12,7 @@ import (
func NewStatus(init vagrant_server.Status_State) *vagrant_server.Status {
return &vagrant_server.Status{
State: init,
StartTime: ptypes.TimestampNow(),
StartTime: timestamppb.Now(),
}
}
@ -26,12 +26,12 @@ func StatusSetError(s *vagrant_server.Status, err error) {
s.State = vagrant_server.Status_ERROR
s.Error = st.Proto()
s.CompleteTime = ptypes.TimestampNow()
s.CompleteTime = timestamppb.Now()
}
// StatusSetSuccess sets state of the status to success and marks the
// completion time.
func StatusSetSuccess(s *vagrant_server.Status) {
s.State = vagrant_server.Status_SUCCESS
s.CompleteTime = ptypes.TimestampNow()
s.CompleteTime = timestamppb.Now()
}

View File

@ -4,10 +4,10 @@ import (
"context"
"errors"
"github.com/golang/protobuf/ptypes/empty"
"github.com/hashicorp/go-hclog"
"github.com/hashicorp/go-plugin"
"google.golang.org/grpc"
"google.golang.org/protobuf/types/known/emptypb"
"github.com/hashicorp/vagrant-plugin-sdk/internal-shared/pluginclient"
"github.com/hashicorp/vagrant-plugin-sdk/proto/vagrant_plugin_sdk"
@ -58,7 +58,7 @@ func (r *RubyVagrantClient) GRPCBroker() *plugin.GRPCBroker {
}
func (r *RubyVagrantClient) GetPlugins() ([]*ruby_vagrant.Plugin, error) {
plugins, err := r.client.GetPlugins(context.Background(), &empty.Empty{})
plugins, err := r.client.GetPlugins(context.Background(), &emptypb.Empty{})
if err != nil {
return nil, err
}