feat: Introduce muxing for new elements

This commit is contained in:
xvlcwk
2024-02-05 00:19:08 +01:00
committed by chris
parent 81c08dd5a7
commit ce6854b8b6
84 changed files with 912 additions and 790 deletions

57
main.go
View File

@@ -1,11 +1,62 @@
package main
import (
"github.com/hashicorp/terraform/plugin"
"context"
"flag"
"github.com/hashicorp/terraform-plugin-go/tfprotov6"
"github.com/hashicorp/terraform-plugin-go/tfprotov6/tf6server"
"github.com/hashicorp/terraform-plugin-mux/tf5to6server"
"github.com/hashicorp/terraform-plugin-mux/tf6muxserver"
"log"
"github.com/hashicorp/terraform-plugin-framework/providerserver"
"github.com/xvlcwk-terraform/terraform-provider-bitbucketserver/bitbucket"
)
func main() {
plugin.Serve(&plugin.ServeOpts{
ProviderFunc: bitbucket.Provider})
ctx := context.Background()
var debug bool
flag.BoolVar(&debug, "debug", false, "set to true to run the provider with support for debuggers like delve")
flag.Parse()
upgradedSdkServer, err := tf5to6server.UpgradeServer(
ctx,
// terraform-plugin-sdk provider
bitbucket.Provider().GRPCProvider, //nolint:staticcheck
)
if err != nil {
log.Fatal(err)
}
providers := []func() tfprotov6.ProviderServer{
providerserver.NewProtocol6(bitbucket.New()), // Example terraform-plugin-framework provider
func() tfprotov6.ProviderServer {
return upgradedSdkServer
},
}
muxServer, err := tf6muxserver.NewMuxServer(ctx, providers...)
if err != nil {
log.Fatal(err)
}
var serveOpts []tf6server.ServeOpt
if debug {
serveOpts = append(serveOpts, tf6server.WithManagedDebug())
}
err = tf6server.Serve(
"registry.terraform.io/xvlcwk-terraform/terraform-provider-bitbucketserver",
muxServer.ProviderServer,
serveOpts...,
)
if err != nil {
log.Fatal(err)
}
}