update stack grpc client

fixing-stacks-plugin-server-panics
UKEME BASSEY 1 year ago
parent 509be4ea1b
commit fcdcb15f56

@ -15,8 +15,8 @@ import (
"github.com/hashicorp/terraform-svchost/disco"
"github.com/hashicorp/terraform/internal/addrs"
"github.com/hashicorp/terraform/internal/cliconfig"
"github.com/hashicorp/terraform/internal/command"
"github.com/hashicorp/terraform/internal/command/cliconfig"
"github.com/hashicorp/terraform/internal/command/views"
"github.com/hashicorp/terraform/internal/command/webbrowser"
"github.com/hashicorp/terraform/internal/getproviders"

@ -1,7 +1,7 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: BUSL-1.1
package stacksplugin1
package rpcapi
import (
"context"
@ -12,11 +12,10 @@ import (
"github.com/hashicorp/go-plugin"
"github.com/hashicorp/terraform-svchost/disco"
"github.com/hashicorp/terraform/internal/pluginshared"
"github.com/hashicorp/terraform/internal/rpcapishared"
"github.com/hashicorp/terraform/internal/rpcapishared/dynrpcserver"
"github.com/hashicorp/terraform/internal/rpcapishared/terraform1/dependencies"
"github.com/hashicorp/terraform/internal/rpcapishared/terraform1/packages"
"github.com/hashicorp/terraform/internal/rpcapishared/terraform1/stacks"
"github.com/hashicorp/terraform/internal/rpcapi/dynrpcserver"
"github.com/hashicorp/terraform/internal/rpcapi/terraform1/dependencies"
"github.com/hashicorp/terraform/internal/rpcapi/terraform1/packages"
"github.com/hashicorp/terraform/internal/rpcapi/terraform1/stacks"
"github.com/hashicorp/terraform/internal/stacksplugin/stacksproto1"
"google.golang.org/grpc"
@ -36,7 +35,7 @@ var _ pluginshared.CustomPluginClient = GRPCStacksClient{}
// Execute sends the client Execute request and waits for the plugin to return
// an exit code response before returning
func (c GRPCStacksClient) Execute(args []string, stdout, stderr io.Writer) int {
handles := rpcapishared.NewHandleTable()
handles := newHandleTable()
dependenciesServer := dynrpcserver.NewDependenciesStub()
packagesServer := dynrpcserver.NewPackagesStub()
@ -46,7 +45,7 @@ func (c GRPCStacksClient) Execute(args []string, stdout, stderr io.Writer) int {
dependenciesServerFunc := func(opts []grpc.ServerOption) *grpc.Server {
s = grpc.NewServer(opts...)
dependencies.RegisterDependenciesServer(s, dependenciesServer)
dependenciesServer.ActivateRPCServer(rpcapishared.NewDependenciesServer(handles, c.Services))
dependenciesServer.ActivateRPCServer(newDependenciesServer(handles, c.Services))
return s
}
@ -57,7 +56,7 @@ func (c GRPCStacksClient) Execute(args []string, stdout, stderr io.Writer) int {
packagesServerFunc := func(opts []grpc.ServerOption) *grpc.Server {
s = grpc.NewServer(opts...)
packages.RegisterPackagesServer(s, packagesServer)
packagesServer.ActivateRPCServer(rpcapishared.NewPackagesServer(c.Services))
packagesServer.ActivateRPCServer(newPackagesServer(c.Services))
return s
}
@ -68,8 +67,8 @@ func (c GRPCStacksClient) Execute(args []string, stdout, stderr io.Writer) int {
stacksServerFunc := func(opts []grpc.ServerOption) *grpc.Server {
s = grpc.NewServer(opts...)
stacks.RegisterStacksServer(s, stacksServer)
stacksServer.ActivateRPCServer(rpcapishared.NewStacksServer(
rpcapishared.NewStopper(), handles, c.Services, rpcapishared.NewServiceOpts(true)))
stacksServer.ActivateRPCServer(newStacksServer(
newStopper(), handles, c.Services, &serviceOpts{experimentsAllowed: true}))
return s
}

@ -11,6 +11,7 @@ import (
"github.com/hashicorp/go-plugin"
"github.com/hashicorp/terraform-svchost/disco"
"github.com/hashicorp/terraform/internal/pluginshared"
"github.com/hashicorp/terraform/internal/rpcapi"
"github.com/hashicorp/terraform/internal/stacksplugin/stacksproto1"
"google.golang.org/grpc"
"google.golang.org/grpc/metadata"
@ -40,7 +41,7 @@ func (p *GRPCStacksPlugin) Client(*plugin.MuxBroker, *rpc.Client) (interface{},
// GRPCClient returns a new GRPC client for interacting with the cloud plugin server.
func (p *GRPCStacksPlugin) GRPCClient(ctx context.Context, broker *plugin.GRPCBroker, c *grpc.ClientConn) (interface{}, error) {
ctx = metadata.NewOutgoingContext(ctx, p.Metadata)
return &GRPCStacksClient{
return &rpcapi.GRPCStacksClient{
Client: stacksproto1.NewCommandServiceClient(c),
Broker: broker,
Services: p.Services,

Loading…
Cancel
Save