Skip to content

Commit

Permalink
Add pb.Provider.ToProviderInfo helper method
Browse files Browse the repository at this point in the history
  • Loading branch information
VenelinMartinov committed Jan 2, 2025
1 parent d1f5261 commit b797040
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions pkg/pf/internal/providerbuilder/build_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit b797040

Please sign in to comment.