From c13c6e8ccea81acf51ad6fb7ec8abb1ed35b6b4d Mon Sep 17 00:00:00 2001 From: Venelin Date: Thu, 2 Jan 2025 16:33:00 +0200 Subject: [PATCH] Add pb.Provider.ToProviderInfo helper method --- .../providerbuilder/build_provider.go | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/pkg/pf/internal/providerbuilder/build_provider.go b/pkg/pf/internal/providerbuilder/build_provider.go index 4f8c72907..26787137a 100644 --- a/pkg/pf/internal/providerbuilder/build_provider.go +++ b/pkg/pf/internal/providerbuilder/build_provider.go @@ -24,6 +24,10 @@ import ( "github.com/hashicorp/terraform-plugin-framework/resource" "github.com/hashicorp/terraform-plugin-framework/tfsdk" "github.com/hashicorp/terraform-plugin-go/tfprotov6" + + "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/pf/tfbridge" + tfbridge0 "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge" + "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge/tokens" ) // Provider is a test provider that can be used in tests. @@ -81,6 +85,22 @@ func (impl *Provider) GRPCProvider() tfprotov6.ProviderServer { return providerserver.NewProtocol6(impl)() } +func (impl *Provider) ToProviderInfo() tfbridge0.ProviderInfo { + shimProvider := tfbridge.ShimProvider(impl) + + provider := tfbridge0.ProviderInfo{ + P: shimProvider, + Name: impl.TypeName, + Version: "0.0.1", + MetadataInfo: &tfbridge0.MetadataInfo{}, + EnableAccurateBridgePreview: true, + } + + provider.MustComputeTokens(tokens.SingleModule(impl.TypeName, "index", tokens.MakeStandard(impl.TypeName))) + + return provider +} + type NewProviderArgs struct { TypeName string Version string