From fcdcb15f56dd5f1f1c1cb074a86cac0a2f86a129 Mon Sep 17 00:00:00 2001 From: UKEME BASSEY Date: Tue, 29 Apr 2025 11:43:40 -0400 Subject: [PATCH] update stack grpc client --- commands.go | 2 +- .../stacks_grpc_client.go | 21 +++++++++---------- .../stacksplugin1/stacks_grpc_plugin.go | 3 ++- 3 files changed, 13 insertions(+), 13 deletions(-) rename internal/{stacksplugin/stacksplugin1 => rpcapi}/stacks_grpc_client.go (83%) diff --git a/commands.go b/commands.go index 976b59ea17..7264bbec5a 100644 --- a/commands.go +++ b/commands.go @@ -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" diff --git a/internal/stacksplugin/stacksplugin1/stacks_grpc_client.go b/internal/rpcapi/stacks_grpc_client.go similarity index 83% rename from internal/stacksplugin/stacksplugin1/stacks_grpc_client.go rename to internal/rpcapi/stacks_grpc_client.go index 36472b1576..76de4aed5b 100644 --- a/internal/stacksplugin/stacksplugin1/stacks_grpc_client.go +++ b/internal/rpcapi/stacks_grpc_client.go @@ -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 } diff --git a/internal/stacksplugin/stacksplugin1/stacks_grpc_plugin.go b/internal/stacksplugin/stacksplugin1/stacks_grpc_plugin.go index 1a07e84190..6a106f84fb 100644 --- a/internal/stacksplugin/stacksplugin1/stacks_grpc_plugin.go +++ b/internal/stacksplugin/stacksplugin1/stacks_grpc_plugin.go @@ -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,