Skip to content

Commit

Permalink
Merge #11830
Browse files Browse the repository at this point in the history
11830: grpc: WithInsecure is deprecated r=abhinav a=abhinav

[grpc.WithInsecure](https://pkg.go.dev/google.golang.org/grpc#WithInsecure) is deprecated.
Instead, we're expected to use:

    grpc.WithTransportCredentials(insecure.NewCredentials())

This updates all instances across pkg/, sdk/ and tests/.

In service to #11808


Co-authored-by: Abhinav Gupta <abhinav@pulumi.com>
  • Loading branch information
bors[bot] and abhinav committed Jan 11, 2023
2 parents abc243f + 69762ac commit 9c3c553
Show file tree
Hide file tree
Showing 13 changed files with 31 additions and 14 deletions.
3 changes: 2 additions & 1 deletion pkg/engine/lifecycletest/pulumi_test.go
Expand Up @@ -33,6 +33,7 @@ import (
"github.com/stretchr/testify/require"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/credentials/insecure"

"github.com/pulumi/pulumi/pkg/v3/engine"
. "github.com/pulumi/pulumi/pkg/v3/engine"
Expand Down Expand Up @@ -2944,7 +2945,7 @@ func (ctx *updateContext) Run(_ context.Context, req *pulumirpc.RunRequest) (*pu
// Connect to the resource monitor and create an appropriate client.
conn, err := grpc.Dial(
req.MonitorAddress,
grpc.WithInsecure(),
grpc.WithTransportCredentials(insecure.NewCredentials()),
rpcutil.GrpcChannelOptions(),
)
if err != nil {
Expand Down
3 changes: 2 additions & 1 deletion pkg/engine/plugin_host.go
Expand Up @@ -18,6 +18,7 @@ import (
"fmt"

"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"

"github.com/pulumi/pulumi/sdk/v3/go/common/resource/plugin"
"github.com/pulumi/pulumi/sdk/v3/go/common/util/rpcutil"
Expand Down Expand Up @@ -52,7 +53,7 @@ func (host *clientLanguageRuntimeHost) LanguageRuntime(
func langRuntimePluginDialOptions(ctx *plugin.Context, address string) []grpc.DialOption {
dialOpts := append(
rpcutil.OpenTracingInterceptorDialOptions(),
grpc.WithInsecure(),
grpc.WithTransportCredentials(insecure.NewCredentials()),
rpcutil.GrpcChannelOptions(),
)

Expand Down
3 changes: 2 additions & 1 deletion pkg/resource/deploy/deploytest/pluginhost.go
Expand Up @@ -26,6 +26,7 @@ import (
pbempty "github.com/golang/protobuf/ptypes/empty"

"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"

"github.com/pulumi/pulumi/sdk/v3/go/common/diag"
"github.com/pulumi/pulumi/sdk/v3/go/common/resource"
Expand Down Expand Up @@ -169,7 +170,7 @@ func wrapProviderWithGrpc(provider plugin.Provider) (plugin.Provider, io.Closer,
}
conn, err := grpc.Dial(
fmt.Sprintf("127.0.0.1:%v", handle.Port),
grpc.WithInsecure(),
grpc.WithTransportCredentials(insecure.NewCredentials()),
grpc.WithUnaryInterceptor(rpcutil.OpenTracingClientInterceptor()),
grpc.WithStreamInterceptor(rpcutil.OpenTracingStreamClientInterceptor()),
rpcutil.GrpcChannelOptions(),
Expand Down
3 changes: 2 additions & 1 deletion pkg/resource/deploy/deploytest/resourcemonitor.go
Expand Up @@ -25,6 +25,7 @@ import (
"github.com/pulumi/pulumi/sdk/v3/go/common/util/rpcutil"
pulumirpc "github.com/pulumi/pulumi/sdk/v3/proto/go"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
)

type ResourceMonitor struct {
Expand All @@ -39,7 +40,7 @@ func dialMonitor(ctx context.Context, endpoint string) (*ResourceMonitor, error)
// Connect to the resource monitor and create an appropriate client.
conn, err := grpc.Dial(
endpoint,
grpc.WithInsecure(),
grpc.WithTransportCredentials(insecure.NewCredentials()),
rpcutil.GrpcChannelOptions(),
)
if err != nil {
Expand Down
3 changes: 2 additions & 1 deletion pkg/resource/provider/host.go
Expand Up @@ -26,6 +26,7 @@ import (
lumirpc "github.com/pulumi/pulumi/sdk/v3/proto/go"
"golang.org/x/net/context"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
"google.golang.org/grpc/grpclog"
)

Expand All @@ -42,7 +43,7 @@ func NewHostClient(addr string) (*HostClient, error) {
grpclog.SetLoggerV2(grpclog.NewLoggerV2(io.Discard, io.Discard, os.Stderr))
conn, err := grpc.Dial(
addr,
grpc.WithInsecure(),
grpc.WithTransportCredentials(insecure.NewCredentials()),
grpc.WithUnaryInterceptor(rpcutil.OpenTracingClientInterceptor()),
grpc.WithStreamInterceptor(rpcutil.OpenTracingStreamClientInterceptor()),
rpcutil.GrpcChannelOptions(),
Expand Down
3 changes: 2 additions & 1 deletion sdk/go/common/resource/plugin/analyzer_plugin.go
Expand Up @@ -29,6 +29,7 @@ import (
"github.com/pkg/errors"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/credentials/insecure"

"github.com/pulumi/pulumi/sdk/v3/go/common/apitype"
"github.com/pulumi/pulumi/sdk/v3/go/common/resource"
Expand Down Expand Up @@ -422,7 +423,7 @@ func (a *analyzer) Close() error {
func analyzerPluginDialOptions(ctx *Context, name string) []grpc.DialOption {
dialOpts := append(
rpcutil.OpenTracingInterceptorDialOptions(),
grpc.WithInsecure(),
grpc.WithTransportCredentials(insecure.NewCredentials()),
rpcutil.GrpcChannelOptions(),
)

Expand Down
3 changes: 2 additions & 1 deletion sdk/go/common/resource/plugin/langruntime_plugin.go
Expand Up @@ -27,6 +27,7 @@ import (
"github.com/pkg/errors"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/credentials/insecure"

"github.com/pulumi/pulumi/sdk/v3/go/common/diag/colors"
"github.com/pulumi/pulumi/sdk/v3/go/common/tokens"
Expand Down Expand Up @@ -83,7 +84,7 @@ func NewLanguageRuntime(host Host, ctx *Context, root, pwd, runtime string,
func langRuntimePluginDialOptions(ctx *Context, runtime string) []grpc.DialOption {
dialOpts := append(
rpcutil.OpenTracingInterceptorDialOptions(),
grpc.WithInsecure(),
grpc.WithTransportCredentials(insecure.NewCredentials()),
rpcutil.GrpcChannelOptions(),
)

Expand Down
3 changes: 2 additions & 1 deletion sdk/go/common/resource/plugin/provider_plugin.go
Expand Up @@ -32,6 +32,7 @@ import (
"github.com/pkg/errors"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/credentials/insecure"

"github.com/pulumi/pulumi/sdk/v3/go/common/resource"
"github.com/pulumi/pulumi/sdk/v3/go/common/tokens"
Expand Down Expand Up @@ -166,7 +167,7 @@ func NewProvider(host Host, ctx *Context, pkg tokens.Package, version *semver.Ve
func providerPluginDialOptions(ctx *Context, pkg tokens.Package, path string) []grpc.DialOption {
dialOpts := append(
rpcutil.OpenTracingInterceptorDialOptions(otgrpc.SpanDecorator(decorateProviderSpans)),
grpc.WithInsecure(),
grpc.WithTransportCredentials(insecure.NewCredentials()),
rpcutil.GrpcChannelOptions(),
)

Expand Down
3 changes: 2 additions & 1 deletion sdk/go/common/util/rpcutil/health.go
Expand Up @@ -20,6 +20,7 @@ import (

"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/credentials/insecure"
healthpb "google.golang.org/grpc/health/grpc_health_v1"
"google.golang.org/grpc/status"
)
Expand All @@ -28,7 +29,7 @@ import (
func Healthcheck(context context.Context, addr string, duration time.Duration, cancel context.CancelFunc) error {
conn, err := grpc.Dial(
addr,
grpc.WithInsecure(),
grpc.WithTransportCredentials(insecure.NewCredentials()),
grpc.WithUnaryInterceptor(OpenTracingClientInterceptor()),
grpc.WithStreamInterceptor(OpenTracingStreamClientInterceptor()),
GrpcChannelOptions(),
Expand Down
5 changes: 3 additions & 2 deletions sdk/go/pulumi/context.go
Expand Up @@ -36,6 +36,7 @@ import (
"github.com/pulumi/pulumi/sdk/v3/go/common/util/rpcutil"
pulumirpc "github.com/pulumi/pulumi/sdk/v3/proto/go"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
)

var disableResourceReferences = cmdutil.IsTruthy(os.Getenv("PULUMI_DISABLE_RESOURCE_REFERENCES"))
Expand Down Expand Up @@ -73,7 +74,7 @@ func NewContext(ctx context.Context, info RunInfo) (*Context, error) {
if addr := info.MonitorAddr; addr != "" {
conn, err := grpc.Dial(
info.MonitorAddr,
grpc.WithInsecure(),
grpc.WithTransportCredentials(insecure.NewCredentials()),
rpcutil.GrpcChannelOptions(),
)
if err != nil {
Expand All @@ -91,7 +92,7 @@ func NewContext(ctx context.Context, info RunInfo) (*Context, error) {
} else if addr := info.EngineAddr; addr != "" {
conn, err := grpc.Dial(
info.EngineAddr,
grpc.WithInsecure(),
grpc.WithTransportCredentials(insecure.NewCredentials()),
rpcutil.GrpcChannelOptions(),
)
if err != nil {
Expand Down
3 changes: 2 additions & 1 deletion sdk/nodejs/cmd/pulumi-language-nodejs/main.go
Expand Up @@ -45,6 +45,7 @@ import (
"github.com/hashicorp/go-multierror"
opentracing "github.com/opentracing/opentracing-go"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"

"github.com/pulumi/pulumi/sdk/v3/go/common/resource/config"
"github.com/pulumi/pulumi/sdk/v3/go/common/resource/plugin"
Expand Down Expand Up @@ -444,7 +445,7 @@ func (host *nodeLanguageHost) Run(ctx context.Context, req *pulumirpc.RunRequest
// Make a connection to the real monitor that we will forward messages to.
conn, err := grpc.Dial(
req.GetMonitorAddress(),
grpc.WithInsecure(),
grpc.WithTransportCredentials(insecure.NewCredentials()),
rpcutil.GrpcChannelOptions(),
)
if err != nil {
Expand Down
3 changes: 2 additions & 1 deletion sdk/python/cmd/pulumi-language-python/main.go
Expand Up @@ -51,6 +51,7 @@ import (
pulumirpc "github.com/pulumi/pulumi/sdk/v3/proto/go"
"github.com/pulumi/pulumi/sdk/v3/python"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
)

const (
Expand Down Expand Up @@ -282,7 +283,7 @@ func (host *pythonLanguageHost) prepareVirtualEnvironment(ctx context.Context, c
// Make a connection to the real engine that we will log messages to.
conn, err := grpc.Dial(
host.engineAddress,
grpc.WithInsecure(),
grpc.WithTransportCredentials(insecure.NewCredentials()),
rpcutil.GrpcChannelOptions(),
)
if err != nil {
Expand Down
7 changes: 6 additions & 1 deletion tests/integration/integration_util_test.go
Expand Up @@ -42,6 +42,7 @@ import (
pulumirpc "github.com/pulumi/pulumi/sdk/v3/proto/go"
"github.com/stretchr/testify/assert"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
)

const WindowsOS = "windows"
Expand Down Expand Up @@ -133,7 +134,11 @@ func testComponentProviderSchema(t *testing.T, path string) {
port := strings.TrimSpace(string(bytes))

// Create a connection to the server.
conn, err := grpc.Dial("127.0.0.1:"+port, grpc.WithInsecure(), rpcutil.GrpcChannelOptions())
conn, err := grpc.Dial(
"127.0.0.1:"+port,
grpc.WithTransportCredentials(insecure.NewCredentials()),
rpcutil.GrpcChannelOptions(),
)
assert.NoError(t, err)
client := pulumirpc.NewResourceProviderClient(conn)

Expand Down

0 comments on commit 9c3c553

Please sign in to comment.