Skip to content

Commit

Permalink
feat: Creating the v2 version of the provider
Browse files Browse the repository at this point in the history
  • Loading branch information
rlinstorres committed Nov 21, 2024
1 parent f237cea commit b5a233e
Showing 1 changed file with 14 additions and 29 deletions.
43 changes: 14 additions & 29 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,40 +1,25 @@
package main

import (
kubernetes "github.com/gavinbunney/terraform-provider-kubectl/kubernetes"
goplugin "github.com/hashicorp/go-plugin"
"github.com/hashicorp/terraform-plugin-go/tfprotov5"
tf5server "github.com/hashicorp/terraform-plugin-go/tfprotov5/server"
"flag"
"github.com/alekc/terraform-provider-kubectl/kubernetes"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/plugin"
"google.golang.org/grpc"
)

func main() {
opts := &plugin.ServeOpts{}
grpcProviderFunc := func() tfprotov5.ProviderServer {
return schema.NewGRPCProviderServer(kubernetes.Provider())
}
var debug bool

// taken from github.com/hashicorp/terraform-plugin-sdk/[email protected]/plugin/serve.go
// configured to allow larger message sizes than 4mb
goplugin.Serve(&goplugin.ServeConfig{
HandshakeConfig: plugin.Handshake,
VersionedPlugins: map[int]goplugin.PluginSet{
5: {
plugin.ProviderPluginName: &tf5server.GRPCProviderPlugin{
GRPCProvider: func() tfprotov5.ProviderServer {
return grpcProviderFunc()
},
},
},
},
GRPCServer: func(opts []grpc.ServerOption) *grpc.Server {
return grpc.NewServer(append(opts,
grpc.MaxSendMsgSize(64<<20 /* 64MB */),
grpc.MaxRecvMsgSize(64<<20 /* 64MB */))...)
flag.BoolVar(&debug, "debug", false, "set to true to run the provider with support for debuggers like delve")
flag.Parse()

opts := &plugin.ServeOpts{
Debug: debug,
ProviderAddr: "registry.terraform.io/alekc/kubectl",
ProviderFunc: func() *schema.Provider {
return kubernetes.Provider()
},
Logger: opts.Logger,
Test: opts.TestConfig,
})
}

plugin.Serve(opts)
}

0 comments on commit b5a233e

Please sign in to comment.