2017-06-05 16:59:08 -04:00
|
|
|
package main
|
|
|
|
|
|
2017-06-06 11:50:36 -04:00
|
|
|
import (
|
2026-01-21 17:13:34 -05:00
|
|
|
"context"
|
2021-03-18 03:30:54 -04:00
|
|
|
"flag"
|
2026-01-21 17:13:34 -05:00
|
|
|
"log"
|
2021-03-18 03:30:54 -04:00
|
|
|
|
2026-01-21 17:13:34 -05:00
|
|
|
"github.com/hashicorp/terraform-plugin-framework/providerserver"
|
|
|
|
|
"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"
|
2021-03-18 03:30:54 -04:00
|
|
|
"github.com/terraform-providers/terraform-provider-docker/internal/provider"
|
|
|
|
|
)
|
|
|
|
|
|
2021-05-21 08:30:56 -04:00
|
|
|
// Run "go generate" to format example terraform files and generate the docs for the registry/website
|
|
|
|
|
|
|
|
|
|
// If you do not have terraform installed, you can remove the formatting command, but its suggested to
|
|
|
|
|
// ensure the documentation is formatted properly.
|
|
|
|
|
//go:generate terraform fmt -recursive ./examples/
|
|
|
|
|
|
|
|
|
|
// Run the docs generation tool, check its repository for more information on how it works and how docs
|
|
|
|
|
// can be customized.
|
|
|
|
|
//go:generate go run github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs
|
|
|
|
|
|
2021-03-18 03:30:54 -04:00
|
|
|
var (
|
|
|
|
|
// these will be set by the goreleaser configuration
|
|
|
|
|
// to appropriate values for the compiled binary
|
|
|
|
|
version string = "dev"
|
|
|
|
|
|
|
|
|
|
// goreleaser can also pass the specific commit if you want
|
|
|
|
|
// commit string = ""
|
2017-06-06 11:50:36 -04:00
|
|
|
)
|
|
|
|
|
|
2017-06-05 16:59:08 -04:00
|
|
|
func main() {
|
2021-03-18 03:30:54 -04:00
|
|
|
var debugMode bool
|
|
|
|
|
|
|
|
|
|
flag.BoolVar(&debugMode, "debug", false, "set to true to run the provider with support for debuggers like delve")
|
|
|
|
|
flag.Parse()
|
|
|
|
|
|
2026-01-21 17:13:34 -05:00
|
|
|
ctx := context.Background()
|
|
|
|
|
|
|
|
|
|
// Create the SDK v2 provider server
|
|
|
|
|
var sdkV2Provider = provider.New(version)
|
|
|
|
|
|
|
|
|
|
// Create the Plugin Framework provider server
|
|
|
|
|
frameworkProviderServer := provider.NewFrameworkProvider(version)
|
|
|
|
|
|
|
|
|
|
upgradedSdkPluginProvider, err := tf5to6server.UpgradeServer(
|
|
|
|
|
context.Background(),
|
|
|
|
|
sdkV2Provider().GRPCProvider,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
log.Fatal(err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
providers := []func() tfprotov6.ProviderServer{
|
|
|
|
|
func() tfprotov6.ProviderServer {
|
|
|
|
|
return upgradedSdkPluginProvider
|
|
|
|
|
},
|
|
|
|
|
providerserver.NewProtocol6(frameworkProviderServer()),
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
muxServer, err := tf6muxserver.NewMuxServer(ctx, providers...)
|
|
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
log.Fatal(err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var serveOpts []tf6server.ServeOpt
|
2021-03-18 03:30:54 -04:00
|
|
|
|
|
|
|
|
if debugMode {
|
2026-01-21 17:13:34 -05:00
|
|
|
serveOpts = append(serveOpts, tf6server.WithManagedDebug())
|
2021-03-18 03:30:54 -04:00
|
|
|
}
|
|
|
|
|
|
2026-01-21 17:13:34 -05:00
|
|
|
err = tf6server.Serve(
|
|
|
|
|
"registry.terraform.io/kreuzwerker/docker",
|
|
|
|
|
muxServer.ProviderServer,
|
|
|
|
|
serveOpts...,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
log.Fatal(err)
|
|
|
|
|
}
|
2017-06-05 16:59:08 -04:00
|
|
|
}
|