Pass subcontext to call

This commit is contained in:
Chris Roberts 2019-04-04 14:32:17 -07:00
parent 6e9fc12b08
commit dcac2a167f
4 changed files with 34 additions and 34 deletions

View File

@ -68,7 +68,7 @@ func (s *GRPCGuestCapabilitiesServer) GuestCapabilities(ctx context.Context, req
func (s *GRPCGuestCapabilitiesServer) GuestCapability(ctx context.Context, req *vagrant_proto.GuestCapabilityRequest) (resp *vagrant_proto.GenericResponse, err error) {
resp = &vagrant_proto.GenericResponse{}
g, _ := errgroup.WithContext(ctx)
g, gctx := errgroup.WithContext(ctx)
g.Go(func() (err error) {
var args interface{}
if err = json.Unmarshal([]byte(req.Arguments), &args); err != nil {
@ -81,7 +81,7 @@ func (s *GRPCGuestCapabilitiesServer) GuestCapability(ctx context.Context, req *
cap := &vagrant.SystemCapability{
Name: req.Capability.Name,
Platform: req.Capability.Platform}
r, err := s.Impl.GuestCapability(ctx, cap, args, machine)
r, err := s.Impl.GuestCapability(gctx, cap, args, machine)
result, err := json.Marshal(r)
if err != nil {
return
@ -192,7 +192,7 @@ func (s *GRPCHostCapabilitiesServer) HostCapabilities(ctx context.Context, req *
func (s *GRPCHostCapabilitiesServer) HostCapability(ctx context.Context, req *vagrant_proto.HostCapabilityRequest) (resp *vagrant_proto.GenericResponse, err error) {
resp = &vagrant_proto.GenericResponse{}
g, _ := errgroup.WithContext(ctx)
g, gctx := errgroup.WithContext(ctx)
g.Go(func() (err error) {
var args interface{}
if err = json.Unmarshal([]byte(req.Arguments), &args); err != nil {
@ -206,7 +206,7 @@ func (s *GRPCHostCapabilitiesServer) HostCapability(ctx context.Context, req *va
Name: req.Capability.Name,
Platform: req.Capability.Platform}
r, err := s.Impl.HostCapability(ctx, cap, args, env)
r, err := s.Impl.HostCapability(gctx, cap, args, env)
result, err := json.Marshal(r)
if err != nil {
return
@ -319,7 +319,7 @@ func (s *GRPCProviderCapabilitiesServer) ProviderCapabilities(ctx context.Contex
func (s *GRPCProviderCapabilitiesServer) ProviderCapability(ctx context.Context, req *vagrant_proto.ProviderCapabilityRequest) (resp *vagrant_proto.GenericResponse, err error) {
resp = &vagrant_proto.GenericResponse{}
g, _ := errgroup.WithContext(ctx)
g, gctx := errgroup.WithContext(ctx)
g.Go(func() (err error) {
var args interface{}
if err = json.Unmarshal([]byte(req.Arguments), &args); err != nil {
@ -333,7 +333,7 @@ func (s *GRPCProviderCapabilitiesServer) ProviderCapability(ctx context.Context,
Name: req.Capability.Name,
Provider: req.Capability.Provider}
r, err := s.Impl.ProviderCapability(ctx, cap, args, m)
r, err := s.Impl.ProviderCapability(gctx, cap, args, m)
if err != nil {
return
}

View File

@ -61,14 +61,14 @@ func (s *GRPCConfigServer) ConfigAttributes(ctx context.Context, req *vagrant_pr
func (s *GRPCConfigServer) ConfigLoad(ctx context.Context, req *vagrant_proto.Configuration) (resp *vagrant_proto.Configuration, err error) {
resp = &vagrant_proto.Configuration{}
g, _ := errgroup.WithContext(ctx)
g, gctx := errgroup.WithContext(ctx)
g.Go(func() (err error) {
var data map[string]interface{}
err = json.Unmarshal([]byte(req.Data), &data)
if err != nil {
return
}
r, err := s.Impl.ConfigLoad(ctx, data)
r, err := s.Impl.ConfigLoad(gctx, data)
if err != nil {
return
}
@ -85,7 +85,7 @@ func (s *GRPCConfigServer) ConfigLoad(ctx context.Context, req *vagrant_proto.Co
func (s *GRPCConfigServer) ConfigValidate(ctx context.Context, req *vagrant_proto.Configuration) (resp *vagrant_proto.ListResponse, err error) {
resp = &vagrant_proto.ListResponse{}
g, _ := errgroup.WithContext(ctx)
g, gctx := errgroup.WithContext(ctx)
g.Go(func() (err error) {
var data map[string]interface{}
err = json.Unmarshal([]byte(req.Data), &data)
@ -96,7 +96,7 @@ func (s *GRPCConfigServer) ConfigValidate(ctx context.Context, req *vagrant_prot
if err != nil {
return
}
resp.Items, err = s.Impl.ConfigValidate(ctx, data, m)
resp.Items, err = s.Impl.ConfigValidate(gctx, data, m)
return
})
err = g.Wait()
@ -105,14 +105,14 @@ func (s *GRPCConfigServer) ConfigValidate(ctx context.Context, req *vagrant_prot
func (s *GRPCConfigServer) ConfigFinalize(ctx context.Context, req *vagrant_proto.Configuration) (resp *vagrant_proto.Configuration, err error) {
resp = &vagrant_proto.Configuration{}
g, _ := errgroup.WithContext(ctx)
g, gctx := errgroup.WithContext(ctx)
g.Go(func() (err error) {
var data map[string]interface{}
err = json.Unmarshal([]byte(req.Data), &data)
if err != nil {
return
}
r, err := s.Impl.ConfigFinalize(ctx, data)
r, err := s.Impl.ConfigFinalize(gctx, data)
if err != nil {
return
}

View File

@ -230,13 +230,13 @@ type GRPCProviderServer struct {
func (s *GRPCProviderServer) Action(ctx context.Context, req *vagrant_proto.GenericAction) (resp *vagrant_proto.ListResponse, err error) {
resp = &vagrant_proto.ListResponse{}
g, _ := errgroup.WithContext(ctx)
g, gctx := errgroup.WithContext(ctx)
g.Go(func() (err error) {
m, err := vagrant.LoadMachine(req.Machine, s.Impl)
if err != nil {
return
}
r, err := s.Impl.Action(ctx, req.Name, m)
r, err := s.Impl.Action(gctx, req.Name, m)
if err != nil {
return
}
@ -249,7 +249,7 @@ func (s *GRPCProviderServer) Action(ctx context.Context, req *vagrant_proto.Gene
func (s *GRPCProviderServer) RunAction(ctx context.Context, req *vagrant_proto.ExecuteAction) (resp *vagrant_proto.GenericResponse, err error) {
resp = &vagrant_proto.GenericResponse{}
g, _ := errgroup.WithContext(ctx)
g, gctx := errgroup.WithContext(ctx)
g.Go(func() (err error) {
var args interface{}
m, err := vagrant.LoadMachine(req.Machine, s.Impl)
@ -259,7 +259,7 @@ func (s *GRPCProviderServer) RunAction(ctx context.Context, req *vagrant_proto.E
if err = json.Unmarshal([]byte(req.Data), &args); err != nil {
return
}
r, err := s.Impl.RunAction(ctx, req.Name, args, m)
r, err := s.Impl.RunAction(gctx, req.Name, args, m)
if err != nil {
return
}
@ -289,13 +289,13 @@ func (s *GRPCProviderServer) Info(ctx context.Context, req *vagrant_proto.Empty)
func (s *GRPCProviderServer) IsInstalled(ctx context.Context, req *vagrant_proto.Machine) (resp *vagrant_proto.Valid, err error) {
resp = &vagrant_proto.Valid{}
g, _ := errgroup.WithContext(ctx)
g, gctx := errgroup.WithContext(ctx)
g.Go(func() (err error) {
m, err := vagrant.LoadMachine(req.Machine, s.Impl)
if err != nil {
return
}
resp.Result, err = s.Impl.IsInstalled(ctx, m)
resp.Result, err = s.Impl.IsInstalled(gctx, m)
return
})
err = g.Wait()
@ -304,13 +304,13 @@ func (s *GRPCProviderServer) IsInstalled(ctx context.Context, req *vagrant_proto
func (s *GRPCProviderServer) IsUsable(ctx context.Context, req *vagrant_proto.Machine) (resp *vagrant_proto.Valid, err error) {
resp = &vagrant_proto.Valid{}
g, _ := errgroup.WithContext(ctx)
g, gctx := errgroup.WithContext(ctx)
g.Go(func() (err error) {
m, err := vagrant.LoadMachine(req.Machine, s.Impl)
if err != nil {
return
}
resp.Result, err = s.Impl.IsUsable(ctx, m)
resp.Result, err = s.Impl.IsUsable(gctx, m)
return
})
err = g.Wait()
@ -319,13 +319,13 @@ func (s *GRPCProviderServer) IsUsable(ctx context.Context, req *vagrant_proto.Ma
func (s *GRPCProviderServer) SshInfo(ctx context.Context, req *vagrant_proto.Machine) (resp *vagrant_proto.MachineSshInfo, err error) {
resp = &vagrant_proto.MachineSshInfo{}
g, _ := errgroup.WithContext(ctx)
g, gctx := errgroup.WithContext(ctx)
g.Go(func() (err error) {
m, err := vagrant.LoadMachine(req.Machine, s.Impl)
if err != nil {
return
}
r, err := s.Impl.SshInfo(ctx, m)
r, err := s.Impl.SshInfo(gctx, m)
if err != nil {
return
}
@ -341,13 +341,13 @@ func (s *GRPCProviderServer) SshInfo(ctx context.Context, req *vagrant_proto.Mac
func (s *GRPCProviderServer) State(ctx context.Context, req *vagrant_proto.Machine) (resp *vagrant_proto.MachineState, err error) {
resp = &vagrant_proto.MachineState{}
g, _ := errgroup.WithContext(ctx)
g, gctx := errgroup.WithContext(ctx)
g.Go(func() (err error) {
m, err := vagrant.LoadMachine(req.Machine, s.Impl)
if err != nil {
return
}
r, err := s.Impl.State(ctx, m)
r, err := s.Impl.State(gctx, m)
if err != nil {
return
}
@ -362,13 +362,13 @@ func (s *GRPCProviderServer) State(ctx context.Context, req *vagrant_proto.Machi
func (s *GRPCProviderServer) MachineIdChanged(ctx context.Context, req *vagrant_proto.Machine) (resp *vagrant_proto.Machine, err error) {
resp = &vagrant_proto.Machine{}
g, _ := errgroup.WithContext(ctx)
g, gctx := errgroup.WithContext(ctx)
g.Go(func() (err error) {
m, err := vagrant.LoadMachine(req.Machine, s.Impl)
if err != nil {
return
}
if err = s.Impl.MachineIdChanged(ctx, m); err != nil {
if err = s.Impl.MachineIdChanged(gctx, m); err != nil {
return
}
mdata, err := vagrant.DumpMachine(m)

View File

@ -154,7 +154,7 @@ type GRPCSyncedFolderServer struct {
func (s *GRPCSyncedFolderServer) Cleanup(ctx context.Context, req *vagrant_proto.SyncedFolders) (resp *vagrant_proto.Empty, err error) {
resp = &vagrant_proto.Empty{}
g, _ := errgroup.WithContext(ctx)
g, gctx := errgroup.WithContext(ctx)
g.Go(func() (err error) {
machine, err := vagrant.LoadMachine(req.Machine, s.Impl)
if err != nil {
@ -165,7 +165,7 @@ func (s *GRPCSyncedFolderServer) Cleanup(ctx context.Context, req *vagrant_proto
if err != nil {
return
}
err = s.Impl.Cleanup(ctx, machine, options)
err = s.Impl.Cleanup(gctx, machine, options)
return
})
err = g.Wait()
@ -174,7 +174,7 @@ func (s *GRPCSyncedFolderServer) Cleanup(ctx context.Context, req *vagrant_proto
func (s *GRPCSyncedFolderServer) Disable(ctx context.Context, req *vagrant_proto.SyncedFolders) (resp *vagrant_proto.Empty, err error) {
resp = &vagrant_proto.Empty{}
g, _ := errgroup.WithContext(ctx)
g, gctx := errgroup.WithContext(ctx)
g.Go(func() (err error) {
machine, err := vagrant.LoadMachine(req.Machine, s.Impl)
if err != nil {
@ -190,7 +190,7 @@ func (s *GRPCSyncedFolderServer) Disable(ctx context.Context, req *vagrant_proto
if err != nil {
return
}
err = s.Impl.Disable(ctx, machine, folders, options)
err = s.Impl.Disable(gctx, machine, folders, options)
return
})
err = g.Wait()
@ -199,7 +199,7 @@ func (s *GRPCSyncedFolderServer) Disable(ctx context.Context, req *vagrant_proto
func (s *GRPCSyncedFolderServer) Enable(ctx context.Context, req *vagrant_proto.SyncedFolders) (resp *vagrant_proto.Empty, err error) {
resp = &vagrant_proto.Empty{}
g, _ := errgroup.WithContext(ctx)
g, gctx := errgroup.WithContext(ctx)
g.Go(func() (err error) {
machine, err := vagrant.LoadMachine(req.Machine, s.Impl)
if err != nil {
@ -215,7 +215,7 @@ func (s *GRPCSyncedFolderServer) Enable(ctx context.Context, req *vagrant_proto.
if err != nil {
return
}
err = s.Impl.Enable(ctx, machine, folders, options)
err = s.Impl.Enable(gctx, machine, folders, options)
return
})
err = g.Wait()
@ -260,7 +260,7 @@ func (s *GRPCSyncedFolderServer) Name(_ context.Context, req *vagrant_proto.Empt
func (s *GRPCSyncedFolderServer) Prepare(ctx context.Context, req *vagrant_proto.SyncedFolders) (resp *vagrant_proto.Empty, err error) {
resp = &vagrant_proto.Empty{}
g, _ := errgroup.WithContext(ctx)
g, gctx := errgroup.WithContext(ctx)
g.Go(func() (err error) {
machine, err := vagrant.LoadMachine(req.Machine, s.Impl)
if err != nil {
@ -276,7 +276,7 @@ func (s *GRPCSyncedFolderServer) Prepare(ctx context.Context, req *vagrant_proto
if err != nil {
return
}
err = s.Impl.Prepare(ctx, machine, folders, options)
err = s.Impl.Prepare(gctx, machine, folders, options)
return
})
err = g.Wait()