-
Notifications
You must be signed in to change notification settings - Fork 208
/
main.go
62 lines (52 loc) · 1.94 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// Package main terraform initial entrypoint & redirect to the okta package
package main
import (
"context"
"log"
"github.com/hashicorp/terraform-plugin-framework/providerserver"
"github.com/hashicorp/terraform-plugin-go/tfprotov5"
"github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server"
"github.com/hashicorp/terraform-plugin-mux/tf5muxserver"
"github.com/hashicorp/terraform-plugin-mux/tf6to5server"
"github.com/okta/terraform-provider-okta/okta"
)
// Ensure the documentation is formatted properly.
//go:generate terraform fmt -recursive ./examples/
// Generate documentation.
//go:generate go run github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs
func main() {
var debug bool
// TODO: Uses v5 protocol for now, however lets swap to v6 when a drop of support for TF versions prior to 1.0 can be made
framework, err := tf6to5server.DowngradeServer(context.Background(), providerserver.NewProtocol6(okta.NewFrameworkProvider(okta.OktaTerraformProviderVersion)))
if err != nil {
log.Fatalf(err.Error())
}
providers := []func() tfprotov5.ProviderServer{
// v2 plugin
okta.Provider().GRPCProvider,
// v3 plugin
func() tfprotov5.ProviderServer {
return framework
},
}
// At the moment, there is no way to use tf6muxserver to mux the new and old provider because the okta.Provider().GRPCProvider only return protocolv5
// Most likely we will have to convert all of the old provider to new provider to use v6
// There are constraint of using v5, such as not being able to use NestedAttributes, we have to use NestedBlock instead (see okta_org_metada)
// use the muxer
muxServer, err := tf5muxserver.NewMuxServer(context.Background(), providers...)
if err != nil {
log.Fatalf(err.Error())
}
var serveOpts []tf5server.ServeOpt
if debug {
serveOpts = append(serveOpts, tf5server.WithManagedDebug())
}
err = tf5server.Serve(
"okta/okta",
muxServer.ProviderServer,
serveOpts...,
)
if err != nil {
log.Fatal(err)
}
}