Skip to content

Commit 2447269

Browse files
committed
Move stacks plugin client to rpcapi package
1 parent 2639f92 commit 2447269

File tree

4 files changed

+7
-204
lines changed

4 files changed

+7
-204
lines changed

internal/stacksplugin/stacksplugin1/grpc_client.go internal/rpcapi/stacks_plugin_client.go

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright (c) HashiCorp, Inc.
22
// SPDX-License-Identifier: BUSL-1.1
33

4-
package stacksplugin1
4+
package rpcapi
55

66
import (
77
"context"
@@ -11,7 +11,6 @@ import (
1111

1212
"github.com/hashicorp/go-plugin"
1313
"github.com/hashicorp/terraform-svchost/disco"
14-
"github.com/hashicorp/terraform/internal/rpcapi"
1514
"github.com/hashicorp/terraform/internal/rpcapi/dynrpcserver"
1615
"github.com/hashicorp/terraform/internal/rpcapi/terraform1/dependencies"
1716
"github.com/hashicorp/terraform/internal/rpcapi/terraform1/packages"
@@ -35,7 +34,7 @@ var _ stacksplugin.Stacks1 = GRPCStacksClient{}
3534
// Execute sends the client Execute request and waits for the plugin to return
3635
// an exit code response before returning
3736
func (c GRPCStacksClient) Execute(args []string, stdout, stderr io.Writer) int {
38-
handles := rpcapi.NewHandleTable()
37+
handles := NewHandleTable()
3938

4039
dependenciesServer := dynrpcserver.NewDependenciesStub()
4140
packagesServer := dynrpcserver.NewPackagesStub()
@@ -45,7 +44,7 @@ func (c GRPCStacksClient) Execute(args []string, stdout, stderr io.Writer) int {
4544
dependenciesServerFunc := func(opts []grpc.ServerOption) *grpc.Server {
4645
s = grpc.NewServer(opts...)
4746
dependencies.RegisterDependenciesServer(s, dependenciesServer)
48-
dependenciesServer.ActivateRPCServer(rpcapi.NewDependenciesServer(handles, c.Services))
47+
dependenciesServer.ActivateRPCServer(NewDependenciesServer(handles, c.Services))
4948

5049
return s
5150
}
@@ -56,7 +55,7 @@ func (c GRPCStacksClient) Execute(args []string, stdout, stderr io.Writer) int {
5655
packagesServerFunc := func(opts []grpc.ServerOption) *grpc.Server {
5756
s = grpc.NewServer(opts...)
5857
packages.RegisterPackagesServer(s, packagesServer)
59-
packagesServer.ActivateRPCServer(rpcapi.NewPackagesServer(c.Services))
58+
packagesServer.ActivateRPCServer(NewPackagesServer(c.Services))
6059

6160
return s
6261
}
@@ -67,7 +66,7 @@ func (c GRPCStacksClient) Execute(args []string, stdout, stderr io.Writer) int {
6766
stacksServerFunc := func(opts []grpc.ServerOption) *grpc.Server {
6867
s = grpc.NewServer(opts...)
6968
stacks.RegisterStacksServer(s, stacksServer)
70-
stacksServer.ActivateRPCServer(rpcapi.NewStacksServer(rpcapi.NewStopper(), handles, &rpcapi.ServiceOpts{
69+
stacksServer.ActivateRPCServer(NewStacksServer(NewStopper(), handles, &ServiceOpts{
7170
ExperimentsAllowed: true,
7271
}))
7372
return s

internal/stacksplugin/stacksplugin1/convert.go

-136
This file was deleted.

internal/stacksplugin/stacksplugin1/grpc_helpers.go

-54
This file was deleted.

internal/stacksplugin/stacksplugin1/grpc_plugin.go

+2-8
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010

1111
"github.com/hashicorp/go-plugin"
1212
"github.com/hashicorp/terraform-svchost/disco"
13+
"github.com/hashicorp/terraform/internal/rpcapi"
1314
"github.com/hashicorp/terraform/internal/stacksplugin"
1415
"github.com/hashicorp/terraform/internal/stacksplugin/stacksproto1"
1516
"google.golang.org/grpc"
@@ -47,7 +48,7 @@ func (p *GRPCStacksPlugin) Client(*plugin.MuxBroker, *rpc.Client) (interface{},
4748
// GRPCClient returns a new GRPC client for interacting with the cloud plugin server.
4849
func (p *GRPCStacksPlugin) GRPCClient(ctx context.Context, broker *plugin.GRPCBroker, c *grpc.ClientConn) (interface{}, error) {
4950
ctx = metadata.NewOutgoingContext(ctx, p.Metadata)
50-
return &GRPCStacksClient{
51+
return &rpcapi.GRPCStacksClient{
5152
Client: stacksproto1.NewCommandServiceClient(c),
5253
Broker: broker,
5354
Services: p.Services,
@@ -58,12 +59,5 @@ func (p *GRPCStacksPlugin) GRPCClient(ctx context.Context, broker *plugin.GRPCBr
5859
// GRPCServer always returns an error; we're only implementing the client
5960
// interface, not the server.
6061
func (p *GRPCStacksPlugin) GRPCServer(broker *plugin.GRPCBroker, s *grpc.Server) error {
61-
/**
62-
stacksproto1.RegisterCommandServiceServer(s, &GRPCStacksServer{
63-
Impl: p.Impl,
64-
broker: broker,
65-
})
66-
return nil
67-
*/
6862
return errors.ErrUnsupported
6963
}

0 commit comments

Comments
 (0)