vaguerent/internal/server/singleprocess/service_server_config.go
Paul Hinze 8b5d4b8631
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
2022-06-08 11:51:19 -05:00

44 lines
1017 B
Go

package singleprocess
import (
"context"
"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"
)
type Targeter interface {
ServerTarget() string
}
func (s *service) SetServerConfig(
ctx context.Context,
req *vagrant_server.SetServerConfigRequest,
) (*emptypb.Empty, error) {
if err := serverptypes.ValidateServerConfig(req.Config); err != nil {
return nil, status.Errorf(codes.FailedPrecondition, err.Error())
}
if err := s.state.ServerConfigSet(req.Config); err != nil {
return nil, err
}
return &emptypb.Empty{}, nil
}
func (s *service) GetServerConfig(
ctx context.Context,
req *emptypb.Empty,
) (*vagrant_server.GetServerConfigResponse, error) {
cfg, err := s.state.ServerConfigGet()
if err != nil {
return nil, err
}
return &vagrant_server.GetServerConfigResponse{Config: cfg}, nil
}