From 9471bc2b3824c6d8f264b686ff75942b0cc5a48f Mon Sep 17 00:00:00 2001 From: Aaron Friel Date: Fri, 9 Dec 2022 13:25:58 -0800 Subject: [PATCH 1/2] Ensure forward build compatibility for resource provider --- pkg/tfbridge/provider.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkg/tfbridge/provider.go b/pkg/tfbridge/provider.go index 24f07a996..13a2079aa 100644 --- a/pkg/tfbridge/provider.go +++ b/pkg/tfbridge/provider.go @@ -49,6 +49,8 @@ import ( // Provider implements the Pulumi resource provider operations for any Terraform plugin. type Provider struct { + pulumirpc.UnimplementedResourceProviderServer + host *provider.HostClient // the RPC link back to the Pulumi engine. module string // the Terraform module name. version string // the plugin version number. From 4e46f2dca6a488928d8c07a8195e9a3507e58442 Mon Sep 17 00:00:00 2001 From: Aaron Friel Date: Fri, 9 Dec 2022 19:42:23 -0800 Subject: [PATCH 2/2] Ensure fwd compat with inmemoryProvider impl --- go.mod | 6 +-- go.sum | 12 +++--- pkg/tfgen/pluginHost.go | 83 +---------------------------------------- 3 files changed, 11 insertions(+), 90 deletions(-) diff --git a/go.mod b/go.mod index 74eaa834d..f353fb0c8 100644 --- a/go.mod +++ b/go.mod @@ -34,9 +34,9 @@ require ( github.com/mitchellh/reflectwalk v1.0.2 github.com/pkg/errors v0.9.1 github.com/pulumi/pulumi-java/pkg v0.6.0 - github.com/pulumi/pulumi-yaml v1.0.3 - github.com/pulumi/pulumi/pkg/v3 v3.48.1-0.20221207201642-68308f522cbf - github.com/pulumi/pulumi/sdk/v3 v3.48.1-0.20221207201642-68308f522cbf + github.com/pulumi/pulumi-yaml v1.0.4 + github.com/pulumi/pulumi/pkg/v3 v3.49.1-0.20221210190028-cbf32d1940fa + github.com/pulumi/pulumi/sdk/v3 v3.49.1-0.20221210190028-cbf32d1940fa github.com/pulumi/schema-tools v0.1.0 github.com/pulumi/terraform-diff-reader v0.0.0-20201211191010-ad4715e9285e github.com/russross/blackfriday/v2 v2.1.0 diff --git a/go.sum b/go.sum index f792056cb..dedbda161 100644 --- a/go.sum +++ b/go.sum @@ -1550,12 +1550,12 @@ github.com/prometheus/prometheus v0.37.0/go.mod h1:egARUgz+K93zwqsVIAneFlLZefyGO github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= github.com/pulumi/pulumi-java/pkg v0.6.0 h1:haiSQJlhrQIBBcR0r0aQCIF8i69e4znzRnHpaNQUchE= github.com/pulumi/pulumi-java/pkg v0.6.0/go.mod h1:xSK2B792P8zjwYZTHYapMM1RJdue2BpRFQNYObWO0C8= -github.com/pulumi/pulumi-yaml v1.0.3 h1:JDRQfGcQYxwJETIepa7T3B7wTV7Bk2P7uApmWvQZeL4= -github.com/pulumi/pulumi-yaml v1.0.3/go.mod h1:KLFTyADnoNoPU9djMyRvXymrTH2SCBg9wnXaapuggEA= -github.com/pulumi/pulumi/pkg/v3 v3.48.1-0.20221207201642-68308f522cbf h1:I2S7oE0dUEWAEunNGv2KHRSBCF8n6QzXBTrlUrWeqEs= -github.com/pulumi/pulumi/pkg/v3 v3.48.1-0.20221207201642-68308f522cbf/go.mod h1:IomAktCnqXcRWhEex4E/vZD6Cd+YThXF3Cy/IUn3UsA= -github.com/pulumi/pulumi/sdk/v3 v3.48.1-0.20221207201642-68308f522cbf h1:+GTw1p/ReedDxKzIZyfMgj1Vp6wN2pTNu9kmr6qv5O0= -github.com/pulumi/pulumi/sdk/v3 v3.48.1-0.20221207201642-68308f522cbf/go.mod h1:n5EPRVFDh+EFwYZ+oaZmEtwgVN1A6NnI82B7ks/bmTU= +github.com/pulumi/pulumi-yaml v1.0.4 h1:p+989rW3AqkkxbzxtxccHKAN4xCJi3K2cRpvA2K84tw= +github.com/pulumi/pulumi-yaml v1.0.4/go.mod h1:Szj8ud4Vqyq3oO1n3kzIUfaP3AiCjYZM4FYjOVWwJn8= +github.com/pulumi/pulumi/pkg/v3 v3.49.1-0.20221210190028-cbf32d1940fa h1:mz0XaaXGaKJumG8vtK01p1lij7HBRXMXWBqZjfYM1wA= +github.com/pulumi/pulumi/pkg/v3 v3.49.1-0.20221210190028-cbf32d1940fa/go.mod h1:4metm4SXH718jHxL3kQwWTzyJMFEVARH4L5zF1qnCek= +github.com/pulumi/pulumi/sdk/v3 v3.49.1-0.20221210190028-cbf32d1940fa h1:lM7pipmKzPeZRfMul9tc0Ja3hX7jA/R1ZPs8osoXQeY= +github.com/pulumi/pulumi/sdk/v3 v3.49.1-0.20221210190028-cbf32d1940fa/go.mod h1:58NOiU6vEdA0S8KFiFt4/eqH7vKtWhDFsEGCUFRBovw= github.com/pulumi/schema-tools v0.1.0 h1:o1nVQaJEnmcA+3trxe+0sIDlrILxEIOvgUQ2Ze4OFsk= github.com/pulumi/schema-tools v0.1.0/go.mod h1:feL1siLWdcCNUm+irXoHyNHbGaqoX7pfYojpGZe2ziY= github.com/pulumi/terraform-diff-reader v0.0.0-20201211191010-ad4715e9285e h1:Dik4Qe/+xguB8JagPyXNlbOnRiXGmq/PSPQTGunYnTk= diff --git a/pkg/tfgen/pluginHost.go b/pkg/tfgen/pluginHost.go index b3c3a4b81..9c07cc92c 100644 --- a/pkg/tfgen/pluginHost.go +++ b/pkg/tfgen/pluginHost.go @@ -20,7 +20,6 @@ import ( "sync" "github.com/blang/semver" - "github.com/pulumi/pulumi/sdk/v3/go/common/resource" "github.com/pulumi/pulumi/sdk/v3/go/common/resource/plugin" "github.com/pulumi/pulumi/sdk/v3/go/common/tokens" "github.com/pulumi/pulumi/sdk/v3/go/common/workspace" @@ -32,6 +31,8 @@ import ( var _ = (plugin.Provider)((*inmemoryProvider)(nil)) type inmemoryProvider struct { + plugin.UnimplementedProvider + name tokens.Package schema []byte info tfbridge.ProviderInfo @@ -82,86 +83,6 @@ func (p *inmemoryProvider) GetPluginInfo() (workspace.PluginInfo, error) { }, nil } -func (p *inmemoryProvider) Call(tok tokens.ModuleMember, args resource.PropertyMap, info plugin.CallInfo, - options plugin.CallOptions) (plugin.CallResult, error) { - panic("unimplemented") -} - -func (p *inmemoryProvider) CheckConfig(urn resource.URN, olds, news resource.PropertyMap, - allowUnknowns bool) (resource.PropertyMap, []plugin.CheckFailure, error) { - panic("unimplemented") -} - -// DiffConfig checks what impacts a hypothetical change to this provider's configuration will have on the provider. -func (p *inmemoryProvider) DiffConfig(urn resource.URN, olds, news resource.PropertyMap, allowUnknowns bool, - ignoreChanges []string) (plugin.DiffResult, error) { - panic("unimplemented") -} - -// Configure configures the resource provider with "globals" that control its behavior. -func (p *inmemoryProvider) Configure(inputs resource.PropertyMap) error { - panic("unimplemented") -} - -func (p *inmemoryProvider) Check(urn resource.URN, olds, news resource.PropertyMap, - allowUnknowns bool, randomSeed []byte) (resource.PropertyMap, []plugin.CheckFailure, error) { - panic("unimplemented") -} - -// Diff checks what impacts a hypothetical update will have on the resource's properties. -func (p *inmemoryProvider) Diff(urn resource.URN, id resource.ID, olds resource.PropertyMap, news resource.PropertyMap, - allowUnknowns bool, ignoreChanges []string) (plugin.DiffResult, error) { - panic("unimplemented") -} - -// Create allocates a new instance of the provided resource and returns its unique resource.ID. -func (p *inmemoryProvider) Create(urn resource.URN, news resource.PropertyMap, timeout float64, - preview bool) (resource.ID, resource.PropertyMap, resource.Status, error) { - panic("unimplemented") -} - -// Read the current live state associated with a resource. Enough state must be include in the inputs to uniquely -// identify the resource; this is typically just the resource ID, but may also include some properties. If the -// resource is missing (for instance, because it has been deleted), the resulting property map will be nil. -func (p *inmemoryProvider) Read(urn resource.URN, id resource.ID, - inputs, state resource.PropertyMap) (plugin.ReadResult, resource.Status, error) { - panic("unimplemented") -} - -// Update updates an existing resource with new values. -func (p *inmemoryProvider) Update(urn resource.URN, id resource.ID, - olds resource.PropertyMap, news resource.PropertyMap, timeout float64, ignoreChanges []string, - preview bool) (resource.PropertyMap, resource.Status, error) { - panic("unimplemented") -} - -// Delete tears down an existing resource. -func (p *inmemoryProvider) Delete(urn resource.URN, id resource.ID, props resource.PropertyMap, - timeout float64) (resource.Status, error) { - panic("unimplemented") -} - -// Construct creates a new component resource. -func (p *inmemoryProvider) Construct(info plugin.ConstructInfo, typ tokens.Type, name tokens.QName, - parent resource.URN, inputs resource.PropertyMap, options plugin.ConstructOptions) (plugin.ConstructResult, error) { - panic("unimplemented") -} - -// Invoke dynamically executes a built-in function in the provider. -func (p *inmemoryProvider) Invoke(tok tokens.ModuleMember, args resource.PropertyMap) (resource.PropertyMap, - []plugin.CheckFailure, error) { - panic("unimplemented") -} - -// StreamInvoke dynamically executes a built-in function in the provider, which returns a stream -// of responses. -func (p *inmemoryProvider) StreamInvoke( - tok tokens.ModuleMember, - args resource.PropertyMap, - onNext func(resource.PropertyMap) error) ([]plugin.CheckFailure, error) { - panic("unimplemented") -} - func (p *inmemoryProvider) Close() error { return nil }