diff --git a/builtin/myplugin/push/encouragement.go b/builtin/myplugin/push/encouragement.go index 2803d5daf..018817359 100644 --- a/builtin/myplugin/push/encouragement.go +++ b/builtin/myplugin/push/encouragement.go @@ -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 } diff --git a/go.mod b/go.mod index 38b7f6027..57a080b60 100644 --- a/go.mod +++ b/go.mod @@ -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 diff --git a/go.sum b/go.sum index ecce99c53..ffd90f689 100644 --- a/go.sum +++ b/go.sum @@ -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= diff --git a/internal/client/server.go b/internal/client/server.go index e530c46d9..21687da27 100644 --- a/internal/client/server.go +++ b/internal/client/server.go @@ -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 } diff --git a/internal/core/arg.go b/internal/core/arg.go index fe19fe5f0..851aad952 100644 --- a/internal/core/arg.go +++ b/internal/core/arg.go @@ -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) } diff --git a/internal/core/basis.go b/internal/core/basis.go index a6974235c..6316281e4 100644 --- a/internal/core/basis.go +++ b/internal/core/basis.go @@ -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" diff --git a/internal/core/operation.go b/internal/core/operation.go index 17d25d02a..088dfa2b0 100644 --- a/internal/core/operation.go +++ b/internal/core/operation.go @@ -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 } diff --git a/internal/core/project.go b/internal/core/project.go index 31443f311..27675bc58 100644 --- a/internal/core/project.go +++ b/internal/core/project.go @@ -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" diff --git a/internal/core/target.go b/internal/core/target.go index 5e3a86b5d..8d2163a04 100644 --- a/internal/core/target.go +++ b/internal/core/target.go @@ -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, diff --git a/internal/core/target_index.go b/internal/core/target_index.go index bbbe37011..014168fe9 100644 --- a/internal/core/target_index.go +++ b/internal/core/target_index.go @@ -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 } diff --git a/internal/pkg/protowriter/protowriter.go b/internal/pkg/protowriter/protowriter.go index 4d829cba3..69dcde907 100644 --- a/internal/pkg/protowriter/protowriter.go +++ b/internal/pkg/protowriter/protowriter.go @@ -33,7 +33,7 @@ import ( "errors" "io" - "github.com/golang/protobuf/proto" + "google.golang.org/protobuf/proto" ) var ( diff --git a/internal/server/execclient/client.go b/internal/server/execclient/client.go index 569ead683..ab12ef737 100644 --- a/internal/server/execclient/client.go +++ b/internal/server/execclient/client.go @@ -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" diff --git a/internal/server/grpc.go b/internal/server/grpc.go index 8070d76dd..914c2f42c 100644 --- a/internal/server/grpc.go +++ b/internal/server/grpc.go @@ -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 } diff --git a/internal/server/logviewer/logviewer.go b/internal/server/logviewer/logviewer.go index d5ee7729f..a0dced3fa 100644 --- a/internal/server/logviewer/logviewer.go +++ b/internal/server/logviewer/logviewer.go @@ -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, diff --git a/internal/server/ptypes/component.go b/internal/server/ptypes/component.go index e2544fe61..c7d504b69 100644 --- a/internal/server/ptypes/component.go +++ b/internal/server/ptypes/component.go @@ -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" diff --git a/internal/server/singleprocess/auth.go b/internal/server/singleprocess/auth.go index 6ee5e5670..77f4dc956 100644 --- a/internal/server/singleprocess/auth.go +++ b/internal/server/singleprocess/auth.go @@ -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 = ×tamp.Timestamp{ + body.ValidUntil = ×tamppb.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") } diff --git a/internal/server/singleprocess/auth_test.go b/internal/server/singleprocess/auth_test.go index ba9b339de..a939ee6cf 100644 --- a/internal/server/singleprocess/auth_test.go +++ b/internal/server/singleprocess/auth_test.go @@ -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) diff --git a/internal/server/singleprocess/service_basis.go b/internal/server/singleprocess/service_basis.go index c649bdc11..96794b89b 100644 --- a/internal/server/singleprocess/service_basis.go +++ b/internal/server/singleprocess/service_basis.go @@ -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 { diff --git a/internal/server/singleprocess/service_box.go b/internal/server/singleprocess/service_box.go index 11c65b5fd..3fdba63a2 100644 --- a/internal/server/singleprocess/service_box.go +++ b/internal/server/singleprocess/service_box.go @@ -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( diff --git a/internal/server/singleprocess/service_job.go b/internal/server/singleprocess/service_job.go index 21676adb0..51b0143ea 100644 --- a/internal/server/singleprocess/service_job.go +++ b/internal/server/singleprocess/service_job.go @@ -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 diff --git a/internal/server/singleprocess/service_project.go b/internal/server/singleprocess/service_project.go index a2c4dc2de..7f0116f47 100644 --- a/internal/server/singleprocess/service_project.go +++ b/internal/server/singleprocess/service_project.go @@ -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 { diff --git a/internal/server/singleprocess/service_server_config.go b/internal/server/singleprocess/service_server_config.go index be0dc790b..bc2b6c295 100644 --- a/internal/server/singleprocess/service_server_config.go +++ b/internal/server/singleprocess/service_server_config.go @@ -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 { diff --git a/internal/server/singleprocess/service_snapshot.go b/internal/server/singleprocess/service_snapshot.go index 449f5b38f..6f9b202ad 100644 --- a/internal/server/singleprocess/service_snapshot.go +++ b/internal/server/singleprocess/service_snapshot.go @@ -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 diff --git a/internal/server/singleprocess/service_snapshot_test.go b/internal/server/singleprocess/service_snapshot_test.go index afec4987e..0c5188764 100644 --- a/internal/server/singleprocess/service_snapshot_test.go +++ b/internal/server/singleprocess/service_snapshot_test.go @@ -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 diff --git a/internal/server/singleprocess/service_target.go b/internal/server/singleprocess/service_target.go index f30243394..7046bb541 100644 --- a/internal/server/singleprocess/service_target.go +++ b/internal/server/singleprocess/service_target.go @@ -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 { diff --git a/internal/server/singleprocess/service_version.go b/internal/server/singleprocess/service_version.go index f46e14b39..11a752f81 100644 --- a/internal/server/singleprocess/service_version.go +++ b/internal/server/singleprocess/service_version.go @@ -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(), diff --git a/internal/server/singleprocess/state/basis.go b/internal/server/singleprocess/state/basis.go index e8ecdedb6..e90d188ef 100644 --- a/internal/server/singleprocess/state/basis.go +++ b/internal/server/singleprocess/state/basis.go @@ -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" diff --git a/internal/server/singleprocess/state/box.go b/internal/server/singleprocess/state/box.go index c2bf847c3..65f31ed8e 100644 --- a/internal/server/singleprocess/state/box.go +++ b/internal/server/singleprocess/state/box.go @@ -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" diff --git a/internal/server/singleprocess/state/config.go b/internal/server/singleprocess/state/config.go index f797f07cf..dcd9481aa 100644 --- a/internal/server/singleprocess/state/config.go +++ b/internal/server/singleprocess/state/config.go @@ -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" diff --git a/internal/server/singleprocess/state/db.go b/internal/server/singleprocess/state/db.go index 9d2d630c1..9df987799 100644 --- a/internal/server/singleprocess/state/db.go +++ b/internal/server/singleprocess/state/db.go @@ -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" diff --git a/internal/server/singleprocess/state/generic_operation.go b/internal/server/singleprocess/state/generic_operation.go index 2a502296d..11431952a 100644 --- a/internal/server/singleprocess/state/generic_operation.go +++ b/internal/server/singleprocess/state/generic_operation.go @@ -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() } } } diff --git a/internal/server/singleprocess/state/hmac.go b/internal/server/singleprocess/state/hmac.go index 88d027da1..6ec0ef4aa 100644 --- a/internal/server/singleprocess/state/hmac.go +++ b/internal/server/singleprocess/state/hmac.go @@ -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" diff --git a/internal/server/singleprocess/state/job.go b/internal/server/singleprocess/state/job.go index 01e7832aa..d8ade3d43 100644 --- a/internal/server/singleprocess/state/job.go +++ b/internal/server/singleprocess/state/job.go @@ -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) diff --git a/internal/server/singleprocess/state/project.go b/internal/server/singleprocess/state/project.go index cea8e95d8..d102b8ced 100644 --- a/internal/server/singleprocess/state/project.go +++ b/internal/server/singleprocess/state/project.go @@ -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" diff --git a/internal/server/singleprocess/state/server_config.go b/internal/server/singleprocess/state/server_config.go index 62602decb..0c3fed260 100644 --- a/internal/server/singleprocess/state/server_config.go +++ b/internal/server/singleprocess/state/server_config.go @@ -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" diff --git a/internal/server/singleprocess/state/target.go b/internal/server/singleprocess/state/target.go index 04c3b653e..1ad93cea2 100644 --- a/internal/server/singleprocess/state/target.go +++ b/internal/server/singleprocess/state/target.go @@ -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" diff --git a/internal/server/sort/artifact.go b/internal/server/sort/artifact.go index b6b2ccf94..f388a29cd 100644 --- a/internal/server/sort/artifact.go +++ b/internal/server/sort/artifact.go @@ -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" // ) diff --git a/internal/server/sort/build.go b/internal/server/sort/build.go index a79118c41..bbed0a023 100644 --- a/internal/server/sort/build.go +++ b/internal/server/sort/build.go @@ -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" // ) diff --git a/internal/server/sort/deploy.go b/internal/server/sort/deploy.go index fbf2aa1c2..c197b0325 100644 --- a/internal/server/sort/deploy.go +++ b/internal/server/sort/deploy.go @@ -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" // ) diff --git a/internal/server/status.go b/internal/server/status.go index d602f5720..69051e024 100644 --- a/internal/server/status.go +++ b/internal/server/status.go @@ -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() } diff --git a/internal/serverclient/ruby_client.go b/internal/serverclient/ruby_client.go index 57ae49724..c0a613897 100644 --- a/internal/serverclient/ruby_client.go +++ b/internal/serverclient/ruby_client.go @@ -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 }