buildkite / terraform-provider-buildkite

Terraform provider for Buildkite
https://registry.terraform.io/providers/buildkite/buildkite/latest
MIT License
56 stars 34 forks source link

[feat request] Add buildkite.Provider() returns schema provider #496

Closed runlevel5 closed 7 months ago

runlevel5 commented 7 months ago

Describe the bug In the pulumi-buildkite, I ran into the provider error upon constructing the ProviderInfo:

error: fatal: failed to Init GRPC to register RPC handlers: failed to create resource provider: info.P must be constructed with ShimProvider or ShimProviderWithContext: found non-conforming type *muxer.ProviderShim

The source code construct ProviderInfo like this:

import (
    "github.com/buildkite/terraform-provider-buildkite/buildkite"
    pfbridge "github.com/pulumi/pulumi-terraform-bridge/pf/tfbridge"
    "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge"
    shim "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim"
    "github.com/pulumi/pulumi/sdk/v3/go/common/resource"
    "github.com/pulumiverse/pulumi-buildkite/provider/pkg/version"
)

func Provider() tfbridge.ProviderInfo {
    // Instantiate the Terraform provider
    p := pfbridge.MuxShimWithPF(context.Background(),
        pfbridge.ShimProvider(buildkite.New(version.Version)),
        buildkite.New(version.Version),
    )

    // Create a Pulumi provider mapping
    prov := tfbridge.ProviderInfo{
        P: p,

...// stripped

The info.P was expecting a conforming provider type...

I have seen many plugins providing Provider() function which returns conforming provider (for example https://github.com/pulumi/pulumi-mongodbatlas/blob/master/provider/resources.go#L72). So can we adopt the same pattern?

import(
    shimv2 "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim/sdk-v2"
)

func Provider() tfbridge.ProviderInfo {
    // Instantiate the Terraform provider
    p := pfbridge.MuxShimWithPF(context.Background(),
        shimv2.NewProvider(buildkite.Provider()), // <-- main change here
        buildkite.New(version.Version),
    )

    // Create a Pulumi provider mapping
    prov := tfbridge.ProviderInfo{
        P: p
...
runlevel5 commented 7 months ago

I am going to close this ticket because it makes no senses to ask for the support of SDKv2 style when we are already on the framework lib