Skip to content

Commit

Permalink
uses downgrade functions for framework SDK, add todo for dropping v5 …
Browse files Browse the repository at this point in the history
…protocol support
  • Loading branch information
tgoodsell-tempus committed Sep 15, 2023
1 parent 89132ba commit b7d0bef
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
12 changes: 11 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"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"
)

Expand All @@ -20,11 +21,20 @@ import (

func main() {
var debug bool

// TODO: Uses v5 protocol for now, however it's 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
providerserver.NewProtocol5(okta.NewFrameworkProvider(okta.OktaTerraformProviderVersion)),
func() tfprotov5.ProviderServer {
return framework
},
}

// use the muxer
Expand Down
8 changes: 7 additions & 1 deletion okta/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"github.com/hashicorp/terraform-plugin-framework/providerserver"
"github.com/hashicorp/terraform-plugin-go/tfprotov5"
"github.com/hashicorp/terraform-plugin-mux/tf5muxserver"
"github.com/hashicorp/terraform-plugin-mux/tf6to5server"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
Expand Down Expand Up @@ -57,9 +58,14 @@ func init() {
}

// v3 provider - terraform-plugin-framework
// TODO: Uses v5 protocol for now, however it's swap to v6 when a drop of support for TF versions prior to 1.0 can be made
frameworkProvider := NewFrameworkProvider("dev")
framework, err := tf6to5server.DowngradeServer(context.Background(), providerserver.NewProtocol6(frameworkProvider))

testAccProtoV5ProviderFactories = map[string]func() (tfprotov5.ProviderServer, error){
"okta": providerserver.NewProtocol5WithError(frameworkProvider),
"okta": func() (tfprotov5.ProviderServer, error) {
return framework, err
},
}
providers := []func() tfprotov5.ProviderServer{
// v2 plugin
Expand Down

0 comments on commit b7d0bef

Please sign in to comment.