From 0968d170467c558ac697335bfc9574c440926f80 Mon Sep 17 00:00:00 2001 From: Carlos Gajardo Date: Tue, 20 Feb 2024 10:44:51 -0300 Subject: [PATCH] Move pagerdutyplugin to protocol version 6 --- main.go | 32 +- ..._source_pagerduty_business_service_test.go | 2 +- .../data_source_pagerduty_service_test.go | 9 +- ...agerduty_standards_resource_scores_test.go | 2 +- ...gerduty_standards_resources_scores_test.go | 2 +- .../data_source_pagerduty_standards_test.go | 4 +- .../import_pagerduty_business_service_test.go | 2 +- pagerdutyplugin/provider_test.go | 27 +- ...esource_pagerduty_business_service_test.go | 6 +- .../internal/tfprotov5tov6/tfprotov5tov6.go | 618 ++++++++++++++++ .../internal/tfprotov6tov5/tfprotov6tov5.go | 673 ++++++++++++++++++ .../{tf5muxserver => tf5to6server}/doc.go | 8 +- .../tf5to6server/tf5to6server.go | 238 +++++++ .../diagnostics.go | 46 +- .../terraform-plugin-mux/tf6muxserver/doc.go | 15 + .../mux_server.go | 60 +- .../mux_server_ApplyResourceChange.go | 10 +- .../mux_server_CallFunction.go | 18 +- .../mux_server_ConfigureProvider.go | 14 +- .../mux_server_GetFunctions.go | 20 +- .../mux_server_GetMetadata.go | 26 +- .../mux_server_GetProviderSchema.go | 28 +- .../mux_server_ImportResourceState.go | 10 +- .../mux_server_PlanResourceChange.go | 14 +- .../mux_server_ReadDataSource.go | 10 +- .../mux_server_ReadResource.go | 10 +- .../mux_server_StopProvider.go | 10 +- .../mux_server_UpgradeResourceState.go | 10 +- .../mux_server_ValidateDataResourceConfig.go} | 16 +- .../mux_server_ValidateProviderConfig.go} | 16 +- .../mux_server_ValidateResourceConfig.go} | 16 +- .../schema_equality.go | 14 +- .../server_capabilities.go | 8 +- vendor/modules.txt | 5 +- 34 files changed, 1780 insertions(+), 219 deletions(-) create mode 100644 vendor/github.com/hashicorp/terraform-plugin-mux/internal/tfprotov5tov6/tfprotov5tov6.go create mode 100644 vendor/github.com/hashicorp/terraform-plugin-mux/internal/tfprotov6tov5/tfprotov6tov5.go rename vendor/github.com/hashicorp/terraform-plugin-mux/{tf5muxserver => tf5to6server}/doc.go (69%) create mode 100644 vendor/github.com/hashicorp/terraform-plugin-mux/tf5to6server/tf5to6server.go rename vendor/github.com/hashicorp/terraform-plugin-mux/{tf5muxserver => tf6muxserver}/diagnostics.go (68%) create mode 100644 vendor/github.com/hashicorp/terraform-plugin-mux/tf6muxserver/doc.go rename vendor/github.com/hashicorp/terraform-plugin-mux/{tf5muxserver => tf6muxserver}/mux_server.go (83%) rename vendor/github.com/hashicorp/terraform-plugin-mux/{tf5muxserver => tf6muxserver}/mux_server_ApplyResourceChange.go (76%) rename vendor/github.com/hashicorp/terraform-plugin-mux/{tf5muxserver => tf6muxserver}/mux_server_CallFunction.go (74%) rename vendor/github.com/hashicorp/terraform-plugin-mux/{tf5muxserver => tf6muxserver}/mux_server_ConfigureProvider.go (74%) rename vendor/github.com/hashicorp/terraform-plugin-mux/{tf5muxserver => tf6muxserver}/mux_server_GetFunctions.go (72%) rename vendor/github.com/hashicorp/terraform-plugin-mux/{tf5muxserver => tf6muxserver}/mux_server_GetMetadata.go (76%) rename vendor/github.com/hashicorp/terraform-plugin-mux/{tf5muxserver => tf6muxserver}/mux_server_GetProviderSchema.go (80%) rename vendor/github.com/hashicorp/terraform-plugin-mux/{tf5muxserver => tf6muxserver}/mux_server_ImportResourceState.go (76%) rename vendor/github.com/hashicorp/terraform-plugin-mux/{tf5muxserver => tf6muxserver}/mux_server_PlanResourceChange.go (84%) rename vendor/github.com/hashicorp/terraform-plugin-mux/{tf5muxserver => tf6muxserver}/mux_server_ReadDataSource.go (75%) rename vendor/github.com/hashicorp/terraform-plugin-mux/{tf5muxserver => tf6muxserver}/mux_server_ReadResource.go (75%) rename vendor/github.com/hashicorp/terraform-plugin-mux/{tf5muxserver => tf6muxserver}/mux_server_StopProvider.go (79%) rename vendor/github.com/hashicorp/terraform-plugin-mux/{tf5muxserver => tf6muxserver}/mux_server_UpgradeResourceState.go (76%) rename vendor/github.com/hashicorp/terraform-plugin-mux/{tf5muxserver/mux_server_ValidateDataSourceConfig.go => tf6muxserver/mux_server_ValidateDataResourceConfig.go} (50%) rename vendor/github.com/hashicorp/terraform-plugin-mux/{tf5muxserver/mux_server_PrepareProviderConfig.go => tf6muxserver/mux_server_ValidateProviderConfig.go} (60%) rename vendor/github.com/hashicorp/terraform-plugin-mux/{tf5muxserver/mux_server_ValidateResourceTypeConfig.go => tf6muxserver/mux_server_ValidateResourceConfig.go} (51%) rename vendor/github.com/hashicorp/terraform-plugin-mux/{tf5muxserver => tf6muxserver}/schema_equality.go (69%) rename vendor/github.com/hashicorp/terraform-plugin-mux/{tf5muxserver => tf6muxserver}/server_capabilities.go (74%) diff --git a/main.go b/main.go index b8782dede..1f47a19de 100644 --- a/main.go +++ b/main.go @@ -4,12 +4,13 @@ import ( "context" "log" + pd "github.com/PagerDuty/terraform-provider-pagerduty/pagerduty" + pdp "github.com/PagerDuty/terraform-provider-pagerduty/pagerdutyplugin" "github.com/hashicorp/terraform-plugin-framework/providerserver" - "github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server" - "github.com/hashicorp/terraform-plugin-mux/tf5muxserver" - - "github.com/PagerDuty/terraform-provider-pagerduty/pagerduty" - pagerdutyplugin "github.com/PagerDuty/terraform-provider-pagerduty/pagerdutyplugin" + "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" ) func main() { @@ -19,21 +20,26 @@ func main() { func Serve() { ctx := context.Background() - muxServer, err := tf5muxserver.NewMuxServer( + upgradedSdkServer, err := tf5to6server.UpgradeServer(ctx, pd.Provider(pd.IsMuxed).GRPCProvider) + if err != nil { + log.Fatal(err) + } + + muxServer, err := tf6muxserver.NewMuxServer( ctx, - // terraform-plugin-framework - providerserver.NewProtocol5(pagerdutyplugin.New()), - // terraform-plugin-sdk - pagerduty.Provider(pagerduty.IsMuxed).GRPCProvider, + providerserver.NewProtocol6(pdp.New()), + func() tfprotov6.ProviderServer { return upgradedSdkServer }, ) if err != nil { log.Fatal(err) } - var serveOpts []tf5server.ServeOpt - address := "registry.terraform.io/pagerduty/pagerduty" - err = tf5server.Serve(address, muxServer.ProviderServer, serveOpts...) + if err != nil { + log.Fatal(err) + } + + err = tf6server.Serve(address, muxServer.ProviderServer) if err != nil { log.Fatal(err) } diff --git a/pagerdutyplugin/data_source_pagerduty_business_service_test.go b/pagerdutyplugin/data_source_pagerduty_business_service_test.go index 312a57626..10f234015 100644 --- a/pagerdutyplugin/data_source_pagerduty_business_service_test.go +++ b/pagerdutyplugin/data_source_pagerduty_business_service_test.go @@ -14,7 +14,7 @@ func TestAccDataSourcePagerDutyBusinessService_Basic(t *testing.T) { resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, - ProtoV5ProviderFactories: testAccProtoV5ProviderFactories(), + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories(), Steps: []resource.TestStep{ { Config: testAccDataSourcePagerDutyBusinessServiceConfig(name), diff --git a/pagerdutyplugin/data_source_pagerduty_service_test.go b/pagerdutyplugin/data_source_pagerduty_service_test.go index 31b940300..91ec6e294 100644 --- a/pagerdutyplugin/data_source_pagerduty_service_test.go +++ b/pagerdutyplugin/data_source_pagerduty_service_test.go @@ -18,7 +18,7 @@ func TestAccDataSourcePagerDutyService_Basic(t *testing.T) { resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, - ProtoV5ProviderFactories: testAccProtoV5ProviderFactories(), + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories(), Steps: []resource.TestStep{ { Config: testAccDataSourcePagerDutyServiceConfig(username, email, service, escalationPolicy, teamname), @@ -39,7 +39,7 @@ func TestAccDataSourcePagerDutyService_HasNoTeam(t *testing.T) { resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, - ProtoV5ProviderFactories: testAccProtoV5ProviderFactories(), + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories(), Steps: []resource.TestStep{ { Config: testAccDataSourcePagerDutyServiceConfig(username, email, service, escalationPolicy, teamname), @@ -60,7 +60,7 @@ func TestAccDataSourcePagerDutyService_HasOneTeam(t *testing.T) { resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, - ProtoV5ProviderFactories: testAccProtoV5ProviderFactories(), + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories(), Steps: []resource.TestStep{ { Config: testAccDataSourcePagerDutyServiceConfig(username, email, service, escalationPolicy, teamname), @@ -161,6 +161,5 @@ data "pagerduty_service" "no_team_service" { data "pagerduty_service" "one_team_service" { name = pagerduty_service.one_team_service.name } - -`, teamname, username, email, service, escalationPolicy) +`, teamname, username, email, escalationPolicy, service) } diff --git a/pagerdutyplugin/data_source_pagerduty_standards_resource_scores_test.go b/pagerdutyplugin/data_source_pagerduty_standards_resource_scores_test.go index 7cb808889..e9184c3f8 100644 --- a/pagerdutyplugin/data_source_pagerduty_standards_resource_scores_test.go +++ b/pagerdutyplugin/data_source_pagerduty_standards_resource_scores_test.go @@ -13,7 +13,7 @@ func TestAccDataSourcePagerDutyStandardsResourceScores_Basic(t *testing.T) { resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, - ProtoV5ProviderFactories: testAccProtoV5ProviderFactories(), + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories(), Steps: []resource.TestStep{ { Config: testAccDataSourcePagerDutyStandardsResourceScoresConfig(name), diff --git a/pagerdutyplugin/data_source_pagerduty_standards_resources_scores_test.go b/pagerdutyplugin/data_source_pagerduty_standards_resources_scores_test.go index 4d5ae2459..4ef7c6380 100644 --- a/pagerdutyplugin/data_source_pagerduty_standards_resources_scores_test.go +++ b/pagerdutyplugin/data_source_pagerduty_standards_resources_scores_test.go @@ -13,7 +13,7 @@ func TestAccDataSourcePagerDutyStandardsResourcesScores_Basic(t *testing.T) { resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, - ProtoV5ProviderFactories: testAccProtoV5ProviderFactories(), + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories(), Steps: []resource.TestStep{ { Config: testAccDataSourcePagerDutyStandardsResourcesScoresConfig(name), diff --git a/pagerdutyplugin/data_source_pagerduty_standards_test.go b/pagerdutyplugin/data_source_pagerduty_standards_test.go index 436837431..fb45ccb03 100644 --- a/pagerdutyplugin/data_source_pagerduty_standards_test.go +++ b/pagerdutyplugin/data_source_pagerduty_standards_test.go @@ -14,7 +14,7 @@ func TestAccDataSourcePagerDutyStandards_Basic(t *testing.T) { resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, - ProtoV5ProviderFactories: testAccProtoV5ProviderFactories(), + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories(), Steps: []resource.TestStep{ { Config: testAccDataSourcePagerDutyStandardsConfig(name), @@ -34,7 +34,7 @@ func TestAccDataSourcePagerDutyStandards_WithResourceType(t *testing.T) { resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, - ProtoV5ProviderFactories: testAccProtoV5ProviderFactories(), + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories(), Steps: []resource.TestStep{ { Config: testAccDataSourcePagerDutyStandardsConfigWithResourceType(name, resourceType), diff --git a/pagerdutyplugin/import_pagerduty_business_service_test.go b/pagerdutyplugin/import_pagerduty_business_service_test.go index 4a7c784eb..a2a24954e 100644 --- a/pagerdutyplugin/import_pagerduty_business_service_test.go +++ b/pagerdutyplugin/import_pagerduty_business_service_test.go @@ -15,7 +15,7 @@ func TestAccPagerDutyBusinessService_import(t *testing.T) { resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, - ProtoV5ProviderFactories: testAccProtoV5ProviderFactories(), + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories(), CheckDestroy: testAccCheckPagerDutyBusinessServiceDestroy, Steps: []resource.TestStep{ { diff --git a/pagerdutyplugin/provider_test.go b/pagerdutyplugin/provider_test.go index 66e63338a..2e2cd3d15 100644 --- a/pagerdutyplugin/provider_test.go +++ b/pagerdutyplugin/provider_test.go @@ -5,13 +5,13 @@ import ( "os" "testing" + pd "github.com/PagerDuty/terraform-provider-pagerduty/pagerduty" "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-go/tfprotov6" + "github.com/hashicorp/terraform-plugin-mux/tf5to6server" + "github.com/hashicorp/terraform-plugin-mux/tf6muxserver" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" - - pd "github.com/PagerDuty/terraform-provider-pagerduty/pagerduty" ) var testAccProvider = New() @@ -51,16 +51,21 @@ func testAccExternalProviders() map[string]resource.ExternalProvider { return m } -func testAccProtoV5ProviderFactories() map[string]func() (tfprotov5.ProviderServer, error) { - return map[string]func() (tfprotov5.ProviderServer, error){ - "pagerduty": func() (tfprotov5.ProviderServer, error) { +func testAccProtoV6ProviderFactories() map[string]func() (tfprotov6.ProviderServer, error) { + return map[string]func() (tfprotov6.ProviderServer, error){ + "pagerduty": func() (tfprotov6.ProviderServer, error) { ctx := context.Background() - providers := []func() tfprotov5.ProviderServer{ - pd.Provider(pd.IsMuxed).GRPCProvider, - providerserver.NewProtocol5(testAccProvider), + + upgradedSdkServer, err := tf5to6server.UpgradeServer(ctx, pd.Provider(pd.IsMuxed).GRPCProvider) + if err != nil { + return nil, err } - muxServer, err := tf5muxserver.NewMuxServer(ctx, providers...) + muxServer, err := tf6muxserver.NewMuxServer( + ctx, + providerserver.NewProtocol6(testAccProvider), + func() tfprotov6.ProviderServer { return upgradedSdkServer }, + ) if err != nil { return nil, err } diff --git a/pagerdutyplugin/resource_pagerduty_business_service_test.go b/pagerdutyplugin/resource_pagerduty_business_service_test.go index 6af157831..7b8054167 100644 --- a/pagerdutyplugin/resource_pagerduty_business_service_test.go +++ b/pagerdutyplugin/resource_pagerduty_business_service_test.go @@ -22,7 +22,7 @@ func TestAccPagerDutyBusinessService_Basic(t *testing.T) { resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, - ProtoV5ProviderFactories: testAccProtoV5ProviderFactories(), + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories(), CheckDestroy: testAccCheckPagerDutyBusinessServiceDestroy, Steps: []resource.TestStep{ { @@ -58,7 +58,7 @@ func TestAccPagerDutyBusinessService_WithTeam(t *testing.T) { resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, - ProtoV5ProviderFactories: testAccProtoV5ProviderFactories(), + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories(), CheckDestroy: testAccCheckPagerDutyBusinessServiceDestroy, Steps: []resource.TestStep{ { @@ -98,7 +98,7 @@ func TestAccPagerDutyBusinessService_SDKv2Compatibility(t *testing.T) { ), }, { - ProtoV5ProviderFactories: testAccProtoV5ProviderFactories(), + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories(), Config: commonConfig, ConfigPlanChecks: resource.ConfigPlanChecks{PreApply: []plancheck.PlanCheck{plancheck.ExpectEmptyPlan()}}, }, diff --git a/vendor/github.com/hashicorp/terraform-plugin-mux/internal/tfprotov5tov6/tfprotov5tov6.go b/vendor/github.com/hashicorp/terraform-plugin-mux/internal/tfprotov5tov6/tfprotov5tov6.go new file mode 100644 index 000000000..52bc39ae7 --- /dev/null +++ b/vendor/github.com/hashicorp/terraform-plugin-mux/internal/tfprotov5tov6/tfprotov5tov6.go @@ -0,0 +1,618 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + +package tfprotov5tov6 + +import ( + "github.com/hashicorp/terraform-plugin-go/tfprotov5" + "github.com/hashicorp/terraform-plugin-go/tfprotov6" +) + +func ApplyResourceChangeRequest(in *tfprotov5.ApplyResourceChangeRequest) *tfprotov6.ApplyResourceChangeRequest { + if in == nil { + return nil + } + + return &tfprotov6.ApplyResourceChangeRequest{ + Config: DynamicValue(in.Config), + PlannedPrivate: in.PlannedPrivate, + PlannedState: DynamicValue(in.PlannedState), + PriorState: DynamicValue(in.PriorState), + ProviderMeta: DynamicValue(in.ProviderMeta), + TypeName: in.TypeName, + } +} + +func ApplyResourceChangeResponse(in *tfprotov5.ApplyResourceChangeResponse) *tfprotov6.ApplyResourceChangeResponse { + if in == nil { + return nil + } + + return &tfprotov6.ApplyResourceChangeResponse{ + Diagnostics: Diagnostics(in.Diagnostics), + NewState: DynamicValue(in.NewState), + Private: in.Private, + UnsafeToUseLegacyTypeSystem: in.UnsafeToUseLegacyTypeSystem, //nolint:staticcheck + } +} + +func CallFunctionRequest(in *tfprotov5.CallFunctionRequest) *tfprotov6.CallFunctionRequest { + if in == nil { + return nil + } + + out := &tfprotov6.CallFunctionRequest{ + Arguments: make([]*tfprotov6.DynamicValue, 0, len(in.Arguments)), + Name: in.Name, + } + + for _, argument := range in.Arguments { + out.Arguments = append(out.Arguments, DynamicValue(argument)) + } + + return out +} + +func CallFunctionResponse(in *tfprotov5.CallFunctionResponse) *tfprotov6.CallFunctionResponse { + if in == nil { + return nil + } + + return &tfprotov6.CallFunctionResponse{ + Diagnostics: Diagnostics(in.Diagnostics), + Result: DynamicValue(in.Result), + } +} + +func ConfigureProviderRequest(in *tfprotov5.ConfigureProviderRequest) *tfprotov6.ConfigureProviderRequest { + if in == nil { + return nil + } + + return &tfprotov6.ConfigureProviderRequest{ + Config: DynamicValue(in.Config), + TerraformVersion: in.TerraformVersion, + } +} + +func ConfigureProviderResponse(in *tfprotov5.ConfigureProviderResponse) *tfprotov6.ConfigureProviderResponse { + if in == nil { + return nil + } + + return &tfprotov6.ConfigureProviderResponse{ + Diagnostics: Diagnostics(in.Diagnostics), + } +} + +func DataSourceMetadata(in tfprotov5.DataSourceMetadata) tfprotov6.DataSourceMetadata { + return tfprotov6.DataSourceMetadata{ + TypeName: in.TypeName, + } +} + +func Diagnostics(in []*tfprotov5.Diagnostic) []*tfprotov6.Diagnostic { + if in == nil { + return nil + } + + diags := make([]*tfprotov6.Diagnostic, 0, len(in)) + + for _, diag := range in { + if diag == nil { + diags = append(diags, nil) + continue + } + + diags = append(diags, &tfprotov6.Diagnostic{ + Severity: tfprotov6.DiagnosticSeverity(diag.Severity), + Summary: diag.Summary, + Detail: diag.Detail, + Attribute: diag.Attribute, + }) + } + + return diags +} + +func DynamicValue(in *tfprotov5.DynamicValue) *tfprotov6.DynamicValue { + if in == nil { + return nil + } + + return &tfprotov6.DynamicValue{ + MsgPack: in.MsgPack, + JSON: in.JSON, + } +} + +func Function(in *tfprotov5.Function) *tfprotov6.Function { + if in == nil { + return nil + } + + out := &tfprotov6.Function{ + DeprecationMessage: in.DeprecationMessage, + Description: in.Description, + DescriptionKind: StringKind(in.DescriptionKind), + Parameters: make([]*tfprotov6.FunctionParameter, 0, len(in.Parameters)), + Return: FunctionReturn(in.Return), + Summary: in.Summary, + VariadicParameter: FunctionParameter(in.VariadicParameter), + } + + for _, parameter := range in.Parameters { + out.Parameters = append(out.Parameters, FunctionParameter(parameter)) + } + + return out +} + +func FunctionMetadata(in tfprotov5.FunctionMetadata) tfprotov6.FunctionMetadata { + return tfprotov6.FunctionMetadata{ + Name: in.Name, + } +} + +func FunctionParameter(in *tfprotov5.FunctionParameter) *tfprotov6.FunctionParameter { + if in == nil { + return nil + } + + return &tfprotov6.FunctionParameter{ + AllowNullValue: in.AllowNullValue, + AllowUnknownValues: in.AllowUnknownValues, + Description: in.Description, + DescriptionKind: StringKind(in.DescriptionKind), + Name: in.Name, + Type: in.Type, + } +} + +func FunctionReturn(in *tfprotov5.FunctionReturn) *tfprotov6.FunctionReturn { + if in == nil { + return nil + } + + return &tfprotov6.FunctionReturn{ + Type: in.Type, + } +} + +func GetFunctionsRequest(in *tfprotov5.GetFunctionsRequest) *tfprotov6.GetFunctionsRequest { + if in == nil { + return nil + } + + return &tfprotov6.GetFunctionsRequest{} +} + +func GetFunctionsResponse(in *tfprotov5.GetFunctionsResponse) *tfprotov6.GetFunctionsResponse { + if in == nil { + return nil + } + + functions := make(map[string]*tfprotov6.Function, len(in.Functions)) + + for name, function := range in.Functions { + functions[name] = Function(function) + } + + return &tfprotov6.GetFunctionsResponse{ + Diagnostics: Diagnostics(in.Diagnostics), + Functions: functions, + } +} + +func GetMetadataRequest(in *tfprotov5.GetMetadataRequest) *tfprotov6.GetMetadataRequest { + if in == nil { + return nil + } + + return &tfprotov6.GetMetadataRequest{} +} + +func GetMetadataResponse(in *tfprotov5.GetMetadataResponse) *tfprotov6.GetMetadataResponse { + if in == nil { + return nil + } + + resp := &tfprotov6.GetMetadataResponse{ + DataSources: make([]tfprotov6.DataSourceMetadata, 0, len(in.DataSources)), + Diagnostics: Diagnostics(in.Diagnostics), + Functions: make([]tfprotov6.FunctionMetadata, 0, len(in.Functions)), + Resources: make([]tfprotov6.ResourceMetadata, 0, len(in.Resources)), + ServerCapabilities: ServerCapabilities(in.ServerCapabilities), + } + + for _, datasource := range in.DataSources { + resp.DataSources = append(resp.DataSources, DataSourceMetadata(datasource)) + } + + for _, function := range in.Functions { + resp.Functions = append(resp.Functions, FunctionMetadata(function)) + } + + for _, resource := range in.Resources { + resp.Resources = append(resp.Resources, ResourceMetadata(resource)) + } + + return resp +} + +func GetProviderSchemaRequest(in *tfprotov5.GetProviderSchemaRequest) *tfprotov6.GetProviderSchemaRequest { + if in == nil { + return nil + } + + return &tfprotov6.GetProviderSchemaRequest{} +} + +func GetProviderSchemaResponse(in *tfprotov5.GetProviderSchemaResponse) *tfprotov6.GetProviderSchemaResponse { + if in == nil { + return nil + } + + dataSourceSchemas := make(map[string]*tfprotov6.Schema, len(in.DataSourceSchemas)) + + for k, v := range in.DataSourceSchemas { + dataSourceSchemas[k] = Schema(v) + } + + functions := make(map[string]*tfprotov6.Function, len(in.Functions)) + + for name, function := range in.Functions { + functions[name] = Function(function) + } + + resourceSchemas := make(map[string]*tfprotov6.Schema, len(in.ResourceSchemas)) + + for k, v := range in.ResourceSchemas { + resourceSchemas[k] = Schema(v) + } + + return &tfprotov6.GetProviderSchemaResponse{ + DataSourceSchemas: dataSourceSchemas, + Diagnostics: Diagnostics(in.Diagnostics), + Functions: functions, + Provider: Schema(in.Provider), + ProviderMeta: Schema(in.ProviderMeta), + ResourceSchemas: resourceSchemas, + ServerCapabilities: ServerCapabilities(in.ServerCapabilities), + } +} + +func ImportResourceStateRequest(in *tfprotov5.ImportResourceStateRequest) *tfprotov6.ImportResourceStateRequest { + if in == nil { + return nil + } + + return &tfprotov6.ImportResourceStateRequest{ + ID: in.ID, + TypeName: in.TypeName, + } +} + +func ImportResourceStateResponse(in *tfprotov5.ImportResourceStateResponse) *tfprotov6.ImportResourceStateResponse { + if in == nil { + return nil + } + + return &tfprotov6.ImportResourceStateResponse{ + Diagnostics: Diagnostics(in.Diagnostics), + ImportedResources: ImportedResources(in.ImportedResources), + } +} + +func ImportedResources(in []*tfprotov5.ImportedResource) []*tfprotov6.ImportedResource { + if in == nil { + return nil + } + + res := make([]*tfprotov6.ImportedResource, 0, len(in)) + + for _, imp := range in { + if imp == nil { + res = append(res, nil) + continue + } + + res = append(res, &tfprotov6.ImportedResource{ + Private: imp.Private, + State: DynamicValue(imp.State), + TypeName: imp.TypeName, + }) + } + + return res +} + +func PlanResourceChangeRequest(in *tfprotov5.PlanResourceChangeRequest) *tfprotov6.PlanResourceChangeRequest { + if in == nil { + return nil + } + + return &tfprotov6.PlanResourceChangeRequest{ + Config: DynamicValue(in.Config), + PriorPrivate: in.PriorPrivate, + PriorState: DynamicValue(in.PriorState), + ProposedNewState: DynamicValue(in.ProposedNewState), + ProviderMeta: DynamicValue(in.ProviderMeta), + TypeName: in.TypeName, + } +} + +func PlanResourceChangeResponse(in *tfprotov5.PlanResourceChangeResponse) *tfprotov6.PlanResourceChangeResponse { + if in == nil { + return nil + } + + return &tfprotov6.PlanResourceChangeResponse{ + Diagnostics: Diagnostics(in.Diagnostics), + PlannedPrivate: in.PlannedPrivate, + PlannedState: DynamicValue(in.PlannedState), + RequiresReplace: in.RequiresReplace, + UnsafeToUseLegacyTypeSystem: in.UnsafeToUseLegacyTypeSystem, //nolint:staticcheck + } +} + +func RawState(in *tfprotov5.RawState) *tfprotov6.RawState { + if in == nil { + return nil + } + + return &tfprotov6.RawState{ + Flatmap: in.Flatmap, + JSON: in.JSON, + } +} + +func ReadDataSourceRequest(in *tfprotov5.ReadDataSourceRequest) *tfprotov6.ReadDataSourceRequest { + if in == nil { + return nil + } + return &tfprotov6.ReadDataSourceRequest{ + Config: DynamicValue(in.Config), + ProviderMeta: DynamicValue(in.ProviderMeta), + TypeName: in.TypeName, + } +} + +func ReadDataSourceResponse(in *tfprotov5.ReadDataSourceResponse) *tfprotov6.ReadDataSourceResponse { + if in == nil { + return nil + } + + return &tfprotov6.ReadDataSourceResponse{ + Diagnostics: Diagnostics(in.Diagnostics), + State: DynamicValue(in.State), + } +} + +func ReadResourceRequest(in *tfprotov5.ReadResourceRequest) *tfprotov6.ReadResourceRequest { + if in == nil { + return nil + } + + return &tfprotov6.ReadResourceRequest{ + CurrentState: DynamicValue(in.CurrentState), + Private: in.Private, + ProviderMeta: DynamicValue(in.ProviderMeta), + TypeName: in.TypeName, + } +} + +func ReadResourceResponse(in *tfprotov5.ReadResourceResponse) *tfprotov6.ReadResourceResponse { + if in == nil { + return nil + } + + return &tfprotov6.ReadResourceResponse{ + Diagnostics: Diagnostics(in.Diagnostics), + NewState: DynamicValue(in.NewState), + Private: in.Private, + } +} + +func ResourceMetadata(in tfprotov5.ResourceMetadata) tfprotov6.ResourceMetadata { + return tfprotov6.ResourceMetadata{ + TypeName: in.TypeName, + } +} + +func Schema(in *tfprotov5.Schema) *tfprotov6.Schema { + if in == nil { + return nil + } + + return &tfprotov6.Schema{ + Block: SchemaBlock(in.Block), + Version: in.Version, + } +} + +func SchemaAttribute(in *tfprotov5.SchemaAttribute) *tfprotov6.SchemaAttribute { + if in == nil { + return nil + } + + return &tfprotov6.SchemaAttribute{ + Computed: in.Computed, + Deprecated: in.Deprecated, + Description: in.Description, + DescriptionKind: StringKind(in.DescriptionKind), + Name: in.Name, + Optional: in.Optional, + Required: in.Required, + Sensitive: in.Sensitive, + Type: in.Type, + } +} + +func SchemaBlock(in *tfprotov5.SchemaBlock) *tfprotov6.SchemaBlock { + if in == nil { + return nil + } + + var attrs []*tfprotov6.SchemaAttribute + + if in.Attributes != nil { + attrs = make([]*tfprotov6.SchemaAttribute, 0, len(in.Attributes)) + + for _, attr := range in.Attributes { + attrs = append(attrs, SchemaAttribute(attr)) + } + } + + var nestedBlocks []*tfprotov6.SchemaNestedBlock + + if in.BlockTypes != nil { + nestedBlocks = make([]*tfprotov6.SchemaNestedBlock, 0, len(in.BlockTypes)) + + for _, block := range in.BlockTypes { + nestedBlocks = append(nestedBlocks, SchemaNestedBlock(block)) + } + } + + return &tfprotov6.SchemaBlock{ + Attributes: attrs, + BlockTypes: nestedBlocks, + Deprecated: in.Deprecated, + Description: in.Description, + DescriptionKind: StringKind(in.DescriptionKind), + Version: in.Version, + } +} + +func SchemaNestedBlock(in *tfprotov5.SchemaNestedBlock) *tfprotov6.SchemaNestedBlock { + if in == nil { + return nil + } + + return &tfprotov6.SchemaNestedBlock{ + Block: SchemaBlock(in.Block), + MaxItems: in.MaxItems, + MinItems: in.MinItems, + Nesting: tfprotov6.SchemaNestedBlockNestingMode(in.Nesting), + TypeName: in.TypeName, + } +} + +func ServerCapabilities(in *tfprotov5.ServerCapabilities) *tfprotov6.ServerCapabilities { + if in == nil { + return nil + } + + return &tfprotov6.ServerCapabilities{ + GetProviderSchemaOptional: in.GetProviderSchemaOptional, + PlanDestroy: in.PlanDestroy, + } +} + +func StopProviderRequest(in *tfprotov5.StopProviderRequest) *tfprotov6.StopProviderRequest { + if in == nil { + return nil + } + + return &tfprotov6.StopProviderRequest{} +} + +func StopProviderResponse(in *tfprotov5.StopProviderResponse) *tfprotov6.StopProviderResponse { + if in == nil { + return nil + } + + return &tfprotov6.StopProviderResponse{ + Error: in.Error, + } +} + +func StringKind(in tfprotov5.StringKind) tfprotov6.StringKind { + return tfprotov6.StringKind(in) +} + +func UpgradeResourceStateRequest(in *tfprotov5.UpgradeResourceStateRequest) *tfprotov6.UpgradeResourceStateRequest { + if in == nil { + return nil + } + + return &tfprotov6.UpgradeResourceStateRequest{ + RawState: RawState(in.RawState), + TypeName: in.TypeName, + Version: in.Version, + } +} + +func UpgradeResourceStateResponse(in *tfprotov5.UpgradeResourceStateResponse) *tfprotov6.UpgradeResourceStateResponse { + if in == nil { + return nil + } + + return &tfprotov6.UpgradeResourceStateResponse{ + Diagnostics: Diagnostics(in.Diagnostics), + UpgradedState: DynamicValue(in.UpgradedState), + } +} + +func ValidateDataResourceConfigRequest(in *tfprotov5.ValidateDataSourceConfigRequest) *tfprotov6.ValidateDataResourceConfigRequest { + if in == nil { + return nil + } + + return &tfprotov6.ValidateDataResourceConfigRequest{ + Config: DynamicValue(in.Config), + TypeName: in.TypeName, + } +} + +func ValidateDataResourceConfigResponse(in *tfprotov5.ValidateDataSourceConfigResponse) *tfprotov6.ValidateDataResourceConfigResponse { + if in == nil { + return nil + } + + return &tfprotov6.ValidateDataResourceConfigResponse{ + Diagnostics: Diagnostics(in.Diagnostics), + } +} + +func ValidateProviderConfigRequest(in *tfprotov5.PrepareProviderConfigRequest) *tfprotov6.ValidateProviderConfigRequest { + if in == nil { + return nil + } + + return &tfprotov6.ValidateProviderConfigRequest{ + Config: DynamicValue(in.Config), + } +} + +func ValidateProviderConfigResponse(in *tfprotov5.PrepareProviderConfigResponse) *tfprotov6.ValidateProviderConfigResponse { + if in == nil { + return nil + } + + return &tfprotov6.ValidateProviderConfigResponse{ + Diagnostics: Diagnostics(in.Diagnostics), + PreparedConfig: DynamicValue(in.PreparedConfig), + } +} + +func ValidateResourceConfigRequest(in *tfprotov5.ValidateResourceTypeConfigRequest) *tfprotov6.ValidateResourceConfigRequest { + if in == nil { + return nil + } + + return &tfprotov6.ValidateResourceConfigRequest{ + Config: DynamicValue(in.Config), + TypeName: in.TypeName, + } +} + +func ValidateResourceConfigResponse(in *tfprotov5.ValidateResourceTypeConfigResponse) *tfprotov6.ValidateResourceConfigResponse { + if in == nil { + return nil + } + + return &tfprotov6.ValidateResourceConfigResponse{ + Diagnostics: Diagnostics(in.Diagnostics), + } +} diff --git a/vendor/github.com/hashicorp/terraform-plugin-mux/internal/tfprotov6tov5/tfprotov6tov5.go b/vendor/github.com/hashicorp/terraform-plugin-mux/internal/tfprotov6tov5/tfprotov6tov5.go new file mode 100644 index 000000000..53751b404 --- /dev/null +++ b/vendor/github.com/hashicorp/terraform-plugin-mux/internal/tfprotov6tov5/tfprotov6tov5.go @@ -0,0 +1,673 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + +package tfprotov6tov5 + +import ( + "errors" + "fmt" + + "github.com/hashicorp/terraform-plugin-go/tfprotov5" + "github.com/hashicorp/terraform-plugin-go/tfprotov6" +) + +var ErrSchemaAttributeNestedTypeNotImplemented error = errors.New("SchemaAttribute NestedType is not implemented in protocol version 5") + +func ApplyResourceChangeRequest(in *tfprotov6.ApplyResourceChangeRequest) *tfprotov5.ApplyResourceChangeRequest { + if in == nil { + return nil + } + + return &tfprotov5.ApplyResourceChangeRequest{ + Config: DynamicValue(in.Config), + PlannedPrivate: in.PlannedPrivate, + PlannedState: DynamicValue(in.PlannedState), + PriorState: DynamicValue(in.PriorState), + ProviderMeta: DynamicValue(in.ProviderMeta), + TypeName: in.TypeName, + } +} + +func ApplyResourceChangeResponse(in *tfprotov6.ApplyResourceChangeResponse) *tfprotov5.ApplyResourceChangeResponse { + if in == nil { + return nil + } + + return &tfprotov5.ApplyResourceChangeResponse{ + Diagnostics: Diagnostics(in.Diagnostics), + NewState: DynamicValue(in.NewState), + Private: in.Private, + UnsafeToUseLegacyTypeSystem: in.UnsafeToUseLegacyTypeSystem, //nolint:staticcheck + } +} + +func CallFunctionRequest(in *tfprotov6.CallFunctionRequest) *tfprotov5.CallFunctionRequest { + if in == nil { + return nil + } + + out := &tfprotov5.CallFunctionRequest{ + Arguments: make([]*tfprotov5.DynamicValue, 0, len(in.Arguments)), + Name: in.Name, + } + + for _, argument := range in.Arguments { + out.Arguments = append(out.Arguments, DynamicValue(argument)) + } + + return out +} + +func CallFunctionResponse(in *tfprotov6.CallFunctionResponse) *tfprotov5.CallFunctionResponse { + if in == nil { + return nil + } + + return &tfprotov5.CallFunctionResponse{ + Diagnostics: Diagnostics(in.Diagnostics), + Result: DynamicValue(in.Result), + } +} + +func ConfigureProviderRequest(in *tfprotov6.ConfigureProviderRequest) *tfprotov5.ConfigureProviderRequest { + if in == nil { + return nil + } + + return &tfprotov5.ConfigureProviderRequest{ + Config: DynamicValue(in.Config), + TerraformVersion: in.TerraformVersion, + } +} + +func ConfigureProviderResponse(in *tfprotov6.ConfigureProviderResponse) *tfprotov5.ConfigureProviderResponse { + if in == nil { + return nil + } + + return &tfprotov5.ConfigureProviderResponse{ + Diagnostics: Diagnostics(in.Diagnostics), + } +} + +func DataSourceMetadata(in tfprotov6.DataSourceMetadata) tfprotov5.DataSourceMetadata { + return tfprotov5.DataSourceMetadata{ + TypeName: in.TypeName, + } +} + +func Diagnostics(in []*tfprotov6.Diagnostic) []*tfprotov5.Diagnostic { + if in == nil { + return nil + } + + diags := make([]*tfprotov5.Diagnostic, 0, len(in)) + + for _, diag := range in { + if diag == nil { + diags = append(diags, nil) + continue + } + + diags = append(diags, &tfprotov5.Diagnostic{ + Attribute: diag.Attribute, + Detail: diag.Detail, + Severity: tfprotov5.DiagnosticSeverity(diag.Severity), + Summary: diag.Summary, + }) + } + + return diags +} + +func DynamicValue(in *tfprotov6.DynamicValue) *tfprotov5.DynamicValue { + if in == nil { + return nil + } + + return &tfprotov5.DynamicValue{ + JSON: in.JSON, + MsgPack: in.MsgPack, + } +} + +func Function(in *tfprotov6.Function) *tfprotov5.Function { + if in == nil { + return nil + } + + out := &tfprotov5.Function{ + DeprecationMessage: in.DeprecationMessage, + Description: in.Description, + DescriptionKind: StringKind(in.DescriptionKind), + Parameters: make([]*tfprotov5.FunctionParameter, 0, len(in.Parameters)), + Return: FunctionReturn(in.Return), + Summary: in.Summary, + VariadicParameter: FunctionParameter(in.VariadicParameter), + } + + for _, parameter := range in.Parameters { + out.Parameters = append(out.Parameters, FunctionParameter(parameter)) + } + + return out +} + +func FunctionMetadata(in tfprotov6.FunctionMetadata) tfprotov5.FunctionMetadata { + return tfprotov5.FunctionMetadata{ + Name: in.Name, + } +} + +func FunctionParameter(in *tfprotov6.FunctionParameter) *tfprotov5.FunctionParameter { + if in == nil { + return nil + } + + return &tfprotov5.FunctionParameter{ + AllowNullValue: in.AllowNullValue, + AllowUnknownValues: in.AllowUnknownValues, + Description: in.Description, + DescriptionKind: StringKind(in.DescriptionKind), + Name: in.Name, + Type: in.Type, + } +} + +func FunctionReturn(in *tfprotov6.FunctionReturn) *tfprotov5.FunctionReturn { + if in == nil { + return nil + } + + return &tfprotov5.FunctionReturn{ + Type: in.Type, + } +} + +func GetFunctionsRequest(in *tfprotov6.GetFunctionsRequest) *tfprotov5.GetFunctionsRequest { + if in == nil { + return nil + } + + return &tfprotov5.GetFunctionsRequest{} +} + +func GetFunctionsResponse(in *tfprotov6.GetFunctionsResponse) *tfprotov5.GetFunctionsResponse { + if in == nil { + return nil + } + + functions := make(map[string]*tfprotov5.Function, len(in.Functions)) + + for name, function := range in.Functions { + functions[name] = Function(function) + } + + return &tfprotov5.GetFunctionsResponse{ + Diagnostics: Diagnostics(in.Diagnostics), + Functions: functions, + } +} + +func GetMetadataRequest(in *tfprotov6.GetMetadataRequest) *tfprotov5.GetMetadataRequest { + if in == nil { + return nil + } + + return &tfprotov5.GetMetadataRequest{} +} + +func GetMetadataResponse(in *tfprotov6.GetMetadataResponse) *tfprotov5.GetMetadataResponse { + if in == nil { + return nil + } + + resp := &tfprotov5.GetMetadataResponse{ + DataSources: make([]tfprotov5.DataSourceMetadata, 0, len(in.DataSources)), + Diagnostics: Diagnostics(in.Diagnostics), + Functions: make([]tfprotov5.FunctionMetadata, 0, len(in.Functions)), + Resources: make([]tfprotov5.ResourceMetadata, 0, len(in.Resources)), + ServerCapabilities: ServerCapabilities(in.ServerCapabilities), + } + + for _, datasource := range in.DataSources { + resp.DataSources = append(resp.DataSources, DataSourceMetadata(datasource)) + } + + for _, function := range in.Functions { + resp.Functions = append(resp.Functions, FunctionMetadata(function)) + } + + for _, resource := range in.Resources { + resp.Resources = append(resp.Resources, ResourceMetadata(resource)) + } + + return resp +} + +func GetProviderSchemaRequest(in *tfprotov6.GetProviderSchemaRequest) *tfprotov5.GetProviderSchemaRequest { + if in == nil { + return nil + } + + return &tfprotov5.GetProviderSchemaRequest{} +} + +func GetProviderSchemaResponse(in *tfprotov6.GetProviderSchemaResponse) (*tfprotov5.GetProviderSchemaResponse, error) { + if in == nil { + return nil, nil + } + + dataSourceSchemas := make(map[string]*tfprotov5.Schema, len(in.DataSourceSchemas)) + + for k, v := range in.DataSourceSchemas { + v5Schema, err := Schema(v) + + if err != nil { + return nil, fmt.Errorf("unable to convert data source %q schema: %w", k, err) + } + + dataSourceSchemas[k] = v5Schema + } + + functions := make(map[string]*tfprotov5.Function, len(in.Functions)) + + for name, function := range in.Functions { + functions[name] = Function(function) + } + + provider, err := Schema(in.Provider) + + if err != nil { + return nil, fmt.Errorf("unable to convert provider schema: %w", err) + } + + providerMeta, err := Schema(in.ProviderMeta) + + if err != nil { + return nil, fmt.Errorf("unable to convert provider meta schema: %w", err) + } + + resourceSchemas := make(map[string]*tfprotov5.Schema, len(in.ResourceSchemas)) + + for k, v := range in.ResourceSchemas { + v5Schema, err := Schema(v) + + if err != nil { + return nil, fmt.Errorf("unable to convert resource %q schema: %w", k, err) + } + + resourceSchemas[k] = v5Schema + } + + return &tfprotov5.GetProviderSchemaResponse{ + DataSourceSchemas: dataSourceSchemas, + Diagnostics: Diagnostics(in.Diagnostics), + Functions: functions, + Provider: provider, + ProviderMeta: providerMeta, + ResourceSchemas: resourceSchemas, + }, nil +} + +func ImportResourceStateRequest(in *tfprotov6.ImportResourceStateRequest) *tfprotov5.ImportResourceStateRequest { + if in == nil { + return nil + } + + return &tfprotov5.ImportResourceStateRequest{ + ID: in.ID, + TypeName: in.TypeName, + } +} + +func ImportResourceStateResponse(in *tfprotov6.ImportResourceStateResponse) *tfprotov5.ImportResourceStateResponse { + if in == nil { + return nil + } + + return &tfprotov5.ImportResourceStateResponse{ + Diagnostics: Diagnostics(in.Diagnostics), + ImportedResources: ImportedResources(in.ImportedResources), + } +} + +func ImportedResources(in []*tfprotov6.ImportedResource) []*tfprotov5.ImportedResource { + if in == nil { + return nil + } + + res := make([]*tfprotov5.ImportedResource, 0, len(in)) + + for _, imp := range in { + if imp == nil { + res = append(res, nil) + continue + } + + res = append(res, &tfprotov5.ImportedResource{ + Private: imp.Private, + State: DynamicValue(imp.State), + TypeName: imp.TypeName, + }) + } + + return res +} + +func PlanResourceChangeRequest(in *tfprotov6.PlanResourceChangeRequest) *tfprotov5.PlanResourceChangeRequest { + if in == nil { + return nil + } + return &tfprotov5.PlanResourceChangeRequest{ + Config: DynamicValue(in.Config), + PriorPrivate: in.PriorPrivate, + PriorState: DynamicValue(in.PriorState), + ProposedNewState: DynamicValue(in.ProposedNewState), + ProviderMeta: DynamicValue(in.ProviderMeta), + TypeName: in.TypeName, + } +} + +func PlanResourceChangeResponse(in *tfprotov6.PlanResourceChangeResponse) *tfprotov5.PlanResourceChangeResponse { + if in == nil { + return nil + } + + return &tfprotov5.PlanResourceChangeResponse{ + Diagnostics: Diagnostics(in.Diagnostics), + PlannedPrivate: in.PlannedPrivate, + PlannedState: DynamicValue(in.PlannedState), + RequiresReplace: in.RequiresReplace, + UnsafeToUseLegacyTypeSystem: in.UnsafeToUseLegacyTypeSystem, //nolint:staticcheck + } +} + +func PrepareProviderConfigRequest(in *tfprotov6.ValidateProviderConfigRequest) *tfprotov5.PrepareProviderConfigRequest { + if in == nil { + return nil + } + + return &tfprotov5.PrepareProviderConfigRequest{ + Config: DynamicValue(in.Config), + } +} + +func PrepareProviderConfigResponse(in *tfprotov6.ValidateProviderConfigResponse) *tfprotov5.PrepareProviderConfigResponse { + if in == nil { + return nil + } + + return &tfprotov5.PrepareProviderConfigResponse{ + Diagnostics: Diagnostics(in.Diagnostics), + PreparedConfig: DynamicValue(in.PreparedConfig), + } +} + +func RawState(in *tfprotov6.RawState) *tfprotov5.RawState { + if in == nil { + return nil + } + + return &tfprotov5.RawState{ + Flatmap: in.Flatmap, + JSON: in.JSON, + } +} + +func ReadDataSourceRequest(in *tfprotov6.ReadDataSourceRequest) *tfprotov5.ReadDataSourceRequest { + if in == nil { + return nil + } + return &tfprotov5.ReadDataSourceRequest{ + Config: DynamicValue(in.Config), + ProviderMeta: DynamicValue(in.ProviderMeta), + TypeName: in.TypeName, + } +} + +func ReadDataSourceResponse(in *tfprotov6.ReadDataSourceResponse) *tfprotov5.ReadDataSourceResponse { + if in == nil { + return nil + } + + return &tfprotov5.ReadDataSourceResponse{ + Diagnostics: Diagnostics(in.Diagnostics), + State: DynamicValue(in.State), + } +} + +func ReadResourceRequest(in *tfprotov6.ReadResourceRequest) *tfprotov5.ReadResourceRequest { + if in == nil { + return nil + } + + return &tfprotov5.ReadResourceRequest{ + CurrentState: DynamicValue(in.CurrentState), + Private: in.Private, + ProviderMeta: DynamicValue(in.ProviderMeta), + TypeName: in.TypeName, + } +} + +func ReadResourceResponse(in *tfprotov6.ReadResourceResponse) *tfprotov5.ReadResourceResponse { + if in == nil { + return nil + } + + return &tfprotov5.ReadResourceResponse{ + Diagnostics: Diagnostics(in.Diagnostics), + NewState: DynamicValue(in.NewState), + Private: in.Private, + } +} + +func ResourceMetadata(in tfprotov6.ResourceMetadata) tfprotov5.ResourceMetadata { + return tfprotov5.ResourceMetadata{ + TypeName: in.TypeName, + } +} + +func Schema(in *tfprotov6.Schema) (*tfprotov5.Schema, error) { + if in == nil { + return nil, nil + } + + block, err := SchemaBlock(in.Block) + + if err != nil { + return nil, err + } + + return &tfprotov5.Schema{ + Block: block, + Version: in.Version, + }, nil +} + +func SchemaAttribute(in *tfprotov6.SchemaAttribute) (*tfprotov5.SchemaAttribute, error) { + if in == nil { + return nil, nil + } + + if in.NestedType != nil { + return nil, fmt.Errorf("unable to convert attribute %q schema: %w", in.Name, ErrSchemaAttributeNestedTypeNotImplemented) + } + + return &tfprotov5.SchemaAttribute{ + Computed: in.Computed, + Deprecated: in.Deprecated, + Description: in.Description, + DescriptionKind: StringKind(in.DescriptionKind), + Name: in.Name, + Optional: in.Optional, + Required: in.Required, + Sensitive: in.Sensitive, + Type: in.Type, + }, nil +} + +func SchemaBlock(in *tfprotov6.SchemaBlock) (*tfprotov5.SchemaBlock, error) { + if in == nil { + return nil, nil + } + + var attrs []*tfprotov5.SchemaAttribute + + if in.Attributes != nil { + attrs = make([]*tfprotov5.SchemaAttribute, 0, len(in.Attributes)) + + for _, attr := range in.Attributes { + v5Attr, err := SchemaAttribute(attr) + + if err != nil { + return nil, err + } + + attrs = append(attrs, v5Attr) + } + } + + var nestedBlocks []*tfprotov5.SchemaNestedBlock + + if in.BlockTypes != nil { + nestedBlocks = make([]*tfprotov5.SchemaNestedBlock, 0, len(in.BlockTypes)) + + for _, block := range in.BlockTypes { + v5Block, err := SchemaNestedBlock(block) + + if err != nil { + return nil, err + } + + nestedBlocks = append(nestedBlocks, v5Block) + } + } + + return &tfprotov5.SchemaBlock{ + Attributes: attrs, + BlockTypes: nestedBlocks, + Deprecated: in.Deprecated, + Description: in.Description, + DescriptionKind: StringKind(in.DescriptionKind), + Version: in.Version, + }, nil +} + +func SchemaNestedBlock(in *tfprotov6.SchemaNestedBlock) (*tfprotov5.SchemaNestedBlock, error) { + if in == nil { + return nil, nil + } + + block, err := SchemaBlock(in.Block) + + if err != nil { + return nil, fmt.Errorf("unable to convert block %q schema: %w", in.TypeName, err) + } + + return &tfprotov5.SchemaNestedBlock{ + Block: block, + MaxItems: in.MaxItems, + MinItems: in.MinItems, + Nesting: tfprotov5.SchemaNestedBlockNestingMode(in.Nesting), + TypeName: in.TypeName, + }, nil +} + +func ServerCapabilities(in *tfprotov6.ServerCapabilities) *tfprotov5.ServerCapabilities { + if in == nil { + return nil + } + + return &tfprotov5.ServerCapabilities{ + GetProviderSchemaOptional: in.GetProviderSchemaOptional, + PlanDestroy: in.PlanDestroy, + } +} + +func StopProviderRequest(in *tfprotov6.StopProviderRequest) *tfprotov5.StopProviderRequest { + if in == nil { + return nil + } + + return &tfprotov5.StopProviderRequest{} +} + +func StopProviderResponse(in *tfprotov6.StopProviderResponse) *tfprotov5.StopProviderResponse { + if in == nil { + return nil + } + + return &tfprotov5.StopProviderResponse{ + Error: in.Error, + } +} + +func StringKind(in tfprotov6.StringKind) tfprotov5.StringKind { + return tfprotov5.StringKind(in) +} + +func UpgradeResourceStateRequest(in *tfprotov6.UpgradeResourceStateRequest) *tfprotov5.UpgradeResourceStateRequest { + if in == nil { + return nil + } + + return &tfprotov5.UpgradeResourceStateRequest{ + RawState: RawState(in.RawState), + TypeName: in.TypeName, + Version: in.Version, + } +} + +func UpgradeResourceStateResponse(in *tfprotov6.UpgradeResourceStateResponse) *tfprotov5.UpgradeResourceStateResponse { + if in == nil { + return nil + } + + return &tfprotov5.UpgradeResourceStateResponse{ + Diagnostics: Diagnostics(in.Diagnostics), + UpgradedState: DynamicValue(in.UpgradedState), + } +} + +func ValidateDataSourceConfigRequest(in *tfprotov6.ValidateDataResourceConfigRequest) *tfprotov5.ValidateDataSourceConfigRequest { + if in == nil { + return nil + } + + return &tfprotov5.ValidateDataSourceConfigRequest{ + Config: DynamicValue(in.Config), + TypeName: in.TypeName, + } +} + +func ValidateDataSourceConfigResponse(in *tfprotov6.ValidateDataResourceConfigResponse) *tfprotov5.ValidateDataSourceConfigResponse { + if in == nil { + return nil + } + + return &tfprotov5.ValidateDataSourceConfigResponse{ + Diagnostics: Diagnostics(in.Diagnostics), + } +} + +func ValidateResourceTypeConfigRequest(in *tfprotov6.ValidateResourceConfigRequest) *tfprotov5.ValidateResourceTypeConfigRequest { + if in == nil { + return nil + } + + return &tfprotov5.ValidateResourceTypeConfigRequest{ + Config: DynamicValue(in.Config), + TypeName: in.TypeName, + } +} + +func ValidateResourceTypeConfigResponse(in *tfprotov6.ValidateResourceConfigResponse) *tfprotov5.ValidateResourceTypeConfigResponse { + if in == nil { + return nil + } + + return &tfprotov5.ValidateResourceTypeConfigResponse{ + Diagnostics: Diagnostics(in.Diagnostics), + } +} diff --git a/vendor/github.com/hashicorp/terraform-plugin-mux/tf5muxserver/doc.go b/vendor/github.com/hashicorp/terraform-plugin-mux/tf5to6server/doc.go similarity index 69% rename from vendor/github.com/hashicorp/terraform-plugin-mux/tf5muxserver/doc.go rename to vendor/github.com/hashicorp/terraform-plugin-mux/tf5to6server/doc.go index 2a52b8c65..4b531ddd9 100644 --- a/vendor/github.com/hashicorp/terraform-plugin-mux/tf5muxserver/doc.go +++ b/vendor/github.com/hashicorp/terraform-plugin-mux/tf5to6server/doc.go @@ -1,15 +1,15 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -// Package tf5muxserver combines multiple provider servers that implement protocol version 5, into a single server. +// Package tf5to6server translates a provider that implements protocol version 5, into one that implements protocol version 6. // // Supported protocol version 5 provider servers include any which implement // the tfprotov5.ProviderServer (https://pkg.go.dev/github.com/hashicorp/terraform-plugin-go/tfprotov5#ProviderServer) // interface, such as: // // - https://pkg.go.dev/github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server -// - https://pkg.go.dev/github.com/hashicorp/terraform-plugin-mux/tf6to5server +// - https://pkg.go.dev/github.com/hashicorp/terraform-plugin-mux/tf5muxserver // - https://pkg.go.dev/github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema // -// Refer to the NewMuxServer() function for creating a combined server. -package tf5muxserver +// Refer to the UpgradeServer() function for wrapping a server. +package tf5to6server diff --git a/vendor/github.com/hashicorp/terraform-plugin-mux/tf5to6server/tf5to6server.go b/vendor/github.com/hashicorp/terraform-plugin-mux/tf5to6server/tf5to6server.go new file mode 100644 index 000000000..8fae458ce --- /dev/null +++ b/vendor/github.com/hashicorp/terraform-plugin-mux/tf5to6server/tf5to6server.go @@ -0,0 +1,238 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + +package tf5to6server + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-go/tfprotov5" + "github.com/hashicorp/terraform-plugin-go/tfprotov6" + "github.com/hashicorp/terraform-plugin-mux/internal/tfprotov5tov6" + "github.com/hashicorp/terraform-plugin-mux/internal/tfprotov6tov5" +) + +// UpgradeServer wraps a protocol version 5 ProviderServer in a protocol +// version 6 server. Protocol version 6 is fully forwards compatible with +// protocol version 5, so no additional validation is performed. +// +// Protocol version 6 servers require Terraform CLI 1.0 or later. +// +// Terraform CLI 1.1.5 or later is required for terraform-provider-sdk based +// protocol version 5 servers to properly upgrade to protocol version 6. +func UpgradeServer(_ context.Context, v5server func() tfprotov5.ProviderServer) (tfprotov6.ProviderServer, error) { + return v5tov6Server{ + v5Server: v5server(), + }, nil +} + +var _ tfprotov6.ProviderServer = v5tov6Server{} + +type v5tov6Server struct { + v5Server tfprotov5.ProviderServer +} + +func (s v5tov6Server) ApplyResourceChange(ctx context.Context, req *tfprotov6.ApplyResourceChangeRequest) (*tfprotov6.ApplyResourceChangeResponse, error) { + v5Req := tfprotov6tov5.ApplyResourceChangeRequest(req) + v5Resp, err := s.v5Server.ApplyResourceChange(ctx, v5Req) + + if err != nil { + return nil, err + } + + return tfprotov5tov6.ApplyResourceChangeResponse(v5Resp), nil +} + +func (s v5tov6Server) CallFunction(ctx context.Context, req *tfprotov6.CallFunctionRequest) (*tfprotov6.CallFunctionResponse, error) { + // Remove and call s.v5Server.CallFunction below directly. + // Reference: https://github.com/hashicorp/terraform-plugin-mux/issues/210 + functionServer, ok := s.v5Server.(tfprotov5.FunctionServer) + + if !ok { + v6Resp := &tfprotov6.CallFunctionResponse{ + Diagnostics: []*tfprotov6.Diagnostic{ + { + Severity: tfprotov6.DiagnosticSeverityError, + Summary: "Provider Functions Not Implemented", + Detail: "A provider-defined function call was received by the provider, however the provider does not implement functions. " + + "Either upgrade the provider to a version that implements provider-defined functions or this is a bug in Terraform that should be reported to the Terraform maintainers.", + }, + }, + } + + return v6Resp, nil + } + + v5Req := tfprotov6tov5.CallFunctionRequest(req) + // Reference: https://github.com/hashicorp/terraform-plugin-mux/issues/210 + // v5Resp, err := s.v5Server.CallFunction(ctx, v5Req) + v5Resp, err := functionServer.CallFunction(ctx, v5Req) + + if err != nil { + return nil, err + } + + return tfprotov5tov6.CallFunctionResponse(v5Resp), nil +} + +func (s v5tov6Server) ConfigureProvider(ctx context.Context, req *tfprotov6.ConfigureProviderRequest) (*tfprotov6.ConfigureProviderResponse, error) { + v5Req := tfprotov6tov5.ConfigureProviderRequest(req) + v5Resp, err := s.v5Server.ConfigureProvider(ctx, v5Req) + + if err != nil { + return nil, err + } + + return tfprotov5tov6.ConfigureProviderResponse(v5Resp), nil +} + +func (s v5tov6Server) GetFunctions(ctx context.Context, req *tfprotov6.GetFunctionsRequest) (*tfprotov6.GetFunctionsResponse, error) { + // Remove and call s.v5Server.GetFunctions below directly. + // Reference: https://github.com/hashicorp/terraform-plugin-mux/issues/210 + functionServer, ok := s.v5Server.(tfprotov5.FunctionServer) + + if !ok { + v6Resp := &tfprotov6.GetFunctionsResponse{ + Functions: map[string]*tfprotov6.Function{}, + } + + return v6Resp, nil + } + + v5Req := tfprotov6tov5.GetFunctionsRequest(req) + // Reference: https://github.com/hashicorp/terraform-plugin-mux/issues/210 + // v5Resp, err := s.v5Server.GetFunctions(ctx, v5Req) + v5Resp, err := functionServer.GetFunctions(ctx, v5Req) + + if err != nil { + return nil, err + } + + return tfprotov5tov6.GetFunctionsResponse(v5Resp), nil +} + +func (s v5tov6Server) GetMetadata(ctx context.Context, req *tfprotov6.GetMetadataRequest) (*tfprotov6.GetMetadataResponse, error) { + v5Req := tfprotov6tov5.GetMetadataRequest(req) + v5Resp, err := s.v5Server.GetMetadata(ctx, v5Req) + + if err != nil { + return nil, err + } + + return tfprotov5tov6.GetMetadataResponse(v5Resp), nil +} + +func (s v5tov6Server) GetProviderSchema(ctx context.Context, req *tfprotov6.GetProviderSchemaRequest) (*tfprotov6.GetProviderSchemaResponse, error) { + v5Req := tfprotov6tov5.GetProviderSchemaRequest(req) + v5Resp, err := s.v5Server.GetProviderSchema(ctx, v5Req) + + if err != nil { + return nil, err + } + + return tfprotov5tov6.GetProviderSchemaResponse(v5Resp), nil +} + +func (s v5tov6Server) ImportResourceState(ctx context.Context, req *tfprotov6.ImportResourceStateRequest) (*tfprotov6.ImportResourceStateResponse, error) { + v5Req := tfprotov6tov5.ImportResourceStateRequest(req) + v5Resp, err := s.v5Server.ImportResourceState(ctx, v5Req) + + if err != nil { + return nil, err + } + + return tfprotov5tov6.ImportResourceStateResponse(v5Resp), nil +} + +func (s v5tov6Server) PlanResourceChange(ctx context.Context, req *tfprotov6.PlanResourceChangeRequest) (*tfprotov6.PlanResourceChangeResponse, error) { + v5Req := tfprotov6tov5.PlanResourceChangeRequest(req) + v5Resp, err := s.v5Server.PlanResourceChange(ctx, v5Req) + + if err != nil { + return nil, err + } + + return tfprotov5tov6.PlanResourceChangeResponse(v5Resp), nil +} + +// ProviderServer is a function compatible with tf6server.Serve. +func (s v5tov6Server) ProviderServer() tfprotov6.ProviderServer { + return s +} + +func (s v5tov6Server) ReadDataSource(ctx context.Context, req *tfprotov6.ReadDataSourceRequest) (*tfprotov6.ReadDataSourceResponse, error) { + v5Req := tfprotov6tov5.ReadDataSourceRequest(req) + v5Resp, err := s.v5Server.ReadDataSource(ctx, v5Req) + + if err != nil { + return nil, err + } + + return tfprotov5tov6.ReadDataSourceResponse(v5Resp), nil +} + +func (s v5tov6Server) ReadResource(ctx context.Context, req *tfprotov6.ReadResourceRequest) (*tfprotov6.ReadResourceResponse, error) { + v5Req := tfprotov6tov5.ReadResourceRequest(req) + v5Resp, err := s.v5Server.ReadResource(ctx, v5Req) + + if err != nil { + return nil, err + } + + return tfprotov5tov6.ReadResourceResponse(v5Resp), nil +} + +func (s v5tov6Server) StopProvider(ctx context.Context, req *tfprotov6.StopProviderRequest) (*tfprotov6.StopProviderResponse, error) { + v5Req := tfprotov6tov5.StopProviderRequest(req) + v5Resp, err := s.v5Server.StopProvider(ctx, v5Req) + + if err != nil { + return nil, err + } + + return tfprotov5tov6.StopProviderResponse(v5Resp), nil +} + +func (s v5tov6Server) UpgradeResourceState(ctx context.Context, req *tfprotov6.UpgradeResourceStateRequest) (*tfprotov6.UpgradeResourceStateResponse, error) { + v5Req := tfprotov6tov5.UpgradeResourceStateRequest(req) + v5Resp, err := s.v5Server.UpgradeResourceState(ctx, v5Req) + + if err != nil { + return nil, err + } + + return tfprotov5tov6.UpgradeResourceStateResponse(v5Resp), nil +} + +func (s v5tov6Server) ValidateDataResourceConfig(ctx context.Context, req *tfprotov6.ValidateDataResourceConfigRequest) (*tfprotov6.ValidateDataResourceConfigResponse, error) { + v5Req := tfprotov6tov5.ValidateDataSourceConfigRequest(req) + v5Resp, err := s.v5Server.ValidateDataSourceConfig(ctx, v5Req) + + if err != nil { + return nil, err + } + + return tfprotov5tov6.ValidateDataResourceConfigResponse(v5Resp), nil +} + +func (s v5tov6Server) ValidateProviderConfig(ctx context.Context, req *tfprotov6.ValidateProviderConfigRequest) (*tfprotov6.ValidateProviderConfigResponse, error) { + v5Req := tfprotov6tov5.PrepareProviderConfigRequest(req) + v5Resp, err := s.v5Server.PrepareProviderConfig(ctx, v5Req) + + if err != nil { + return nil, err + } + + return tfprotov5tov6.ValidateProviderConfigResponse(v5Resp), nil +} + +func (s v5tov6Server) ValidateResourceConfig(ctx context.Context, req *tfprotov6.ValidateResourceConfigRequest) (*tfprotov6.ValidateResourceConfigResponse, error) { + v5Req := tfprotov6tov5.ValidateResourceTypeConfigRequest(req) + v5Resp, err := s.v5Server.ValidateResourceTypeConfig(ctx, v5Req) + + if err != nil { + return nil, err + } + + return tfprotov5tov6.ValidateResourceConfigResponse(v5Resp), nil +} diff --git a/vendor/github.com/hashicorp/terraform-plugin-mux/tf5muxserver/diagnostics.go b/vendor/github.com/hashicorp/terraform-plugin-mux/tf6muxserver/diagnostics.go similarity index 68% rename from vendor/github.com/hashicorp/terraform-plugin-mux/tf5muxserver/diagnostics.go rename to vendor/github.com/hashicorp/terraform-plugin-mux/tf6muxserver/diagnostics.go index 4348d239f..80572fcb5 100644 --- a/vendor/github.com/hashicorp/terraform-plugin-mux/tf5muxserver/diagnostics.go +++ b/vendor/github.com/hashicorp/terraform-plugin-mux/tf6muxserver/diagnostics.go @@ -1,13 +1,15 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -package tf5muxserver +package tf6muxserver -import "github.com/hashicorp/terraform-plugin-go/tfprotov5" +import ( + "github.com/hashicorp/terraform-plugin-go/tfprotov6" +) -func dataSourceDuplicateError(typeName string) *tfprotov5.Diagnostic { - return &tfprotov5.Diagnostic{ - Severity: tfprotov5.DiagnosticSeverityError, +func dataSourceDuplicateError(typeName string) *tfprotov6.Diagnostic { + return &tfprotov6.Diagnostic{ + Severity: tfprotov6.DiagnosticSeverityError, Summary: "Invalid Provider Server Combination", Detail: "The combined provider has multiple implementations of the same data source type across underlying providers. " + "Data source types must be implemented by only one underlying provider. " + @@ -16,9 +18,9 @@ func dataSourceDuplicateError(typeName string) *tfprotov5.Diagnostic { } } -func dataSourceMissingError(typeName string) *tfprotov5.Diagnostic { - return &tfprotov5.Diagnostic{ - Severity: tfprotov5.DiagnosticSeverityError, +func dataSourceMissingError(typeName string) *tfprotov6.Diagnostic { + return &tfprotov6.Diagnostic{ + Severity: tfprotov6.DiagnosticSeverityError, Summary: "Data Source Not Implemented", Detail: "The combined provider does not implement the requested data source type. " + "This is always an issue in the provider implementation and should be reported to the provider developers.\n\n" + @@ -26,13 +28,13 @@ func dataSourceMissingError(typeName string) *tfprotov5.Diagnostic { } } -func diagnosticsHasError(diagnostics []*tfprotov5.Diagnostic) bool { +func diagnosticsHasError(diagnostics []*tfprotov6.Diagnostic) bool { for _, diagnostic := range diagnostics { if diagnostic == nil { continue } - if diagnostic.Severity == tfprotov5.DiagnosticSeverityError { + if diagnostic.Severity == tfprotov6.DiagnosticSeverityError { return true } } @@ -40,9 +42,9 @@ func diagnosticsHasError(diagnostics []*tfprotov5.Diagnostic) bool { return false } -func functionDuplicateError(name string) *tfprotov5.Diagnostic { - return &tfprotov5.Diagnostic{ - Severity: tfprotov5.DiagnosticSeverityError, +func functionDuplicateError(name string) *tfprotov6.Diagnostic { + return &tfprotov6.Diagnostic{ + Severity: tfprotov6.DiagnosticSeverityError, Summary: "Invalid Provider Server Combination", Detail: "The combined provider has multiple implementations of the same function name across underlying providers. " + "Functions must be implemented by only one underlying provider. " + @@ -51,9 +53,9 @@ func functionDuplicateError(name string) *tfprotov5.Diagnostic { } } -func functionMissingError(name string) *tfprotov5.Diagnostic { - return &tfprotov5.Diagnostic{ - Severity: tfprotov5.DiagnosticSeverityError, +func functionMissingError(name string) *tfprotov6.Diagnostic { + return &tfprotov6.Diagnostic{ + Severity: tfprotov6.DiagnosticSeverityError, Summary: "Function Not Implemented", Detail: "The combined provider does not implement the requested function. " + "This is always an issue in the provider implementation and should be reported to the provider developers.\n\n" + @@ -61,9 +63,9 @@ func functionMissingError(name string) *tfprotov5.Diagnostic { } } -func resourceDuplicateError(typeName string) *tfprotov5.Diagnostic { - return &tfprotov5.Diagnostic{ - Severity: tfprotov5.DiagnosticSeverityError, +func resourceDuplicateError(typeName string) *tfprotov6.Diagnostic { + return &tfprotov6.Diagnostic{ + Severity: tfprotov6.DiagnosticSeverityError, Summary: "Invalid Provider Server Combination", Detail: "The combined provider has multiple implementations of the same resource type across underlying providers. " + "Resource types must be implemented by only one underlying provider. " + @@ -72,9 +74,9 @@ func resourceDuplicateError(typeName string) *tfprotov5.Diagnostic { } } -func resourceMissingError(typeName string) *tfprotov5.Diagnostic { - return &tfprotov5.Diagnostic{ - Severity: tfprotov5.DiagnosticSeverityError, +func resourceMissingError(typeName string) *tfprotov6.Diagnostic { + return &tfprotov6.Diagnostic{ + Severity: tfprotov6.DiagnosticSeverityError, Summary: "Resource Not Implemented", Detail: "The combined provider does not implement the requested resource type. " + "This is always an issue in the provider implementation and should be reported to the provider developers.\n\n" + diff --git a/vendor/github.com/hashicorp/terraform-plugin-mux/tf6muxserver/doc.go b/vendor/github.com/hashicorp/terraform-plugin-mux/tf6muxserver/doc.go new file mode 100644 index 000000000..7ec36d9e8 --- /dev/null +++ b/vendor/github.com/hashicorp/terraform-plugin-mux/tf6muxserver/doc.go @@ -0,0 +1,15 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + +// Package tf6muxserver combines multiple provider servers that implement protocol version 6, into a single server. +// +// Supported protocol version 6 provider servers include any which implement +// the tfprotov6.ProviderServer (https://pkg.go.dev/github.com/hashicorp/terraform-plugin-go/tfprotov6#ProviderServer) +// interface, such as: +// +// - https://pkg.go.dev/github.com/hashicorp/terraform-plugin-framework +// - https://pkg.go.dev/github.com/hashicorp/terraform-plugin-go/tfprotov6/tf6server +// - https://pkg.go.dev/github.com/hashicorp/terraform-plugin-mux/tf5to6server +// +// Refer to the NewMuxServer() function for creating a combined server. +package tf6muxserver diff --git a/vendor/github.com/hashicorp/terraform-plugin-mux/tf5muxserver/mux_server.go b/vendor/github.com/hashicorp/terraform-plugin-mux/tf6muxserver/mux_server.go similarity index 83% rename from vendor/github.com/hashicorp/terraform-plugin-mux/tf5muxserver/mux_server.go rename to vendor/github.com/hashicorp/terraform-plugin-mux/tf6muxserver/mux_server.go index 91137dbca..243f4c7b6 100644 --- a/vendor/github.com/hashicorp/terraform-plugin-mux/tf5muxserver/mux_server.go +++ b/vendor/github.com/hashicorp/terraform-plugin-mux/tf6muxserver/mux_server.go @@ -1,35 +1,35 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -package tf5muxserver +package tf6muxserver import ( "context" "sync" - "github.com/hashicorp/terraform-plugin-go/tfprotov5" + "github.com/hashicorp/terraform-plugin-go/tfprotov6" "github.com/hashicorp/terraform-plugin-mux/internal/logging" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" ) -var _ tfprotov5.ProviderServer = &muxServer{} +var _ tfprotov6.ProviderServer = &muxServer{} // muxServer is a gRPC server implementation that stands in front of other // gRPC servers, routing requests to them as if they were a single server. It // should always be instantiated by calling NewMuxServer(). type muxServer struct { // Routing for data source types - dataSources map[string]tfprotov5.ProviderServer + dataSources map[string]tfprotov6.ProviderServer // Routing for functions - functions map[string]tfprotov5.ProviderServer + functions map[string]tfprotov6.ProviderServer // Routing for resource types - resources map[string]tfprotov5.ProviderServer + resources map[string]tfprotov6.ProviderServer // Resource capabilities are cached during GetMetadata/GetProviderSchema - resourceCapabilities map[string]*tfprotov5.ServerCapabilities + resourceCapabilities map[string]*tfprotov6.ServerCapabilities // serverDiscoveryComplete is whether the mux server's underlying server // discovery of resource types has been completed against all servers. @@ -40,22 +40,22 @@ type muxServer struct { // serverDiscoveryDiagnostics caches diagnostics found during server // discovery so they can be returned for later requests if necessary. - serverDiscoveryDiagnostics []*tfprotov5.Diagnostic + serverDiscoveryDiagnostics []*tfprotov6.Diagnostic // serverDiscoveryMutex is a mutex to protect concurrent server discovery // access from race conditions. serverDiscoveryMutex sync.RWMutex // Underlying servers for requests that should be handled by all servers - servers []tfprotov5.ProviderServer + servers []tfprotov6.ProviderServer } // ProviderServer is a function compatible with tf6server.Serve. -func (s *muxServer) ProviderServer() tfprotov5.ProviderServer { +func (s *muxServer) ProviderServer() tfprotov6.ProviderServer { return s } -func (s *muxServer) getDataSourceServer(ctx context.Context, typeName string) (tfprotov5.ProviderServer, []*tfprotov5.Diagnostic, error) { +func (s *muxServer) getDataSourceServer(ctx context.Context, typeName string) (tfprotov6.ProviderServer, []*tfprotov6.Diagnostic, error) { s.serverDiscoveryMutex.RLock() server, ok := s.dataSources[typeName] discoveryComplete := s.serverDiscoveryComplete @@ -66,7 +66,7 @@ func (s *muxServer) getDataSourceServer(ctx context.Context, typeName string) (t return server, s.serverDiscoveryDiagnostics, nil } - return nil, []*tfprotov5.Diagnostic{ + return nil, []*tfprotov6.Diagnostic{ dataSourceMissingError(typeName), }, nil } @@ -82,7 +82,7 @@ func (s *muxServer) getDataSourceServer(ctx context.Context, typeName string) (t s.serverDiscoveryMutex.RUnlock() if !ok { - return nil, []*tfprotov5.Diagnostic{ + return nil, []*tfprotov6.Diagnostic{ dataSourceMissingError(typeName), }, nil } @@ -90,7 +90,7 @@ func (s *muxServer) getDataSourceServer(ctx context.Context, typeName string) (t return server, s.serverDiscoveryDiagnostics, nil } -func (s *muxServer) getFunctionServer(ctx context.Context, name string) (tfprotov5.ProviderServer, []*tfprotov5.Diagnostic, error) { +func (s *muxServer) getFunctionServer(ctx context.Context, name string) (tfprotov6.ProviderServer, []*tfprotov6.Diagnostic, error) { s.serverDiscoveryMutex.RLock() server, ok := s.functions[name] discoveryComplete := s.serverDiscoveryComplete @@ -101,7 +101,7 @@ func (s *muxServer) getFunctionServer(ctx context.Context, name string) (tfproto return server, s.serverDiscoveryDiagnostics, nil } - return nil, []*tfprotov5.Diagnostic{ + return nil, []*tfprotov6.Diagnostic{ functionMissingError(name), }, nil } @@ -117,7 +117,7 @@ func (s *muxServer) getFunctionServer(ctx context.Context, name string) (tfproto s.serverDiscoveryMutex.RUnlock() if !ok { - return nil, []*tfprotov5.Diagnostic{ + return nil, []*tfprotov6.Diagnostic{ functionMissingError(name), }, nil } @@ -125,7 +125,7 @@ func (s *muxServer) getFunctionServer(ctx context.Context, name string) (tfproto return server, s.serverDiscoveryDiagnostics, nil } -func (s *muxServer) getResourceServer(ctx context.Context, typeName string) (tfprotov5.ProviderServer, []*tfprotov5.Diagnostic, error) { +func (s *muxServer) getResourceServer(ctx context.Context, typeName string) (tfprotov6.ProviderServer, []*tfprotov6.Diagnostic, error) { s.serverDiscoveryMutex.RLock() server, ok := s.resources[typeName] discoveryComplete := s.serverDiscoveryComplete @@ -136,7 +136,7 @@ func (s *muxServer) getResourceServer(ctx context.Context, typeName string) (tfp return server, s.serverDiscoveryDiagnostics, nil } - return nil, []*tfprotov5.Diagnostic{ + return nil, []*tfprotov6.Diagnostic{ resourceMissingError(typeName), }, nil } @@ -152,7 +152,7 @@ func (s *muxServer) getResourceServer(ctx context.Context, typeName string) (tfp s.serverDiscoveryMutex.RUnlock() if !ok { - return nil, []*tfprotov5.Diagnostic{ + return nil, []*tfprotov6.Diagnostic{ resourceMissingError(typeName), }, nil } @@ -179,11 +179,11 @@ func (s *muxServer) serverDiscovery(ctx context.Context) error { logging.MuxTrace(ctx, "starting underlying server discovery via GetMetadata or GetProviderSchema") for _, server := range s.servers { - ctx := logging.Tfprotov5ProviderServerContext(ctx, server) + ctx := logging.Tfprotov6ProviderServerContext(ctx, server) ctx = logging.RpcContext(ctx, "GetMetadata") logging.MuxTrace(ctx, "calling GetMetadata for discovery") - metadataResp, err := server.GetMetadata(ctx, &tfprotov5.GetMetadataRequest{}) + metadataResp, err := server.GetMetadata(ctx, &tfprotov6.GetMetadataRequest{}) // GetMetadata call was successful, populate caches and move on to next // underlying server. @@ -234,7 +234,7 @@ func (s *muxServer) serverDiscovery(ctx context.Context) error { } logging.MuxTrace(ctx, "calling GetProviderSchema for discovery") - providerSchemaResp, err := server.GetProviderSchema(ctx, &tfprotov5.GetProviderSchemaRequest{}) + providerSchemaResp, err := server.GetProviderSchema(ctx, &tfprotov6.GetProviderSchemaRequest{}) if err != nil { return err @@ -281,20 +281,22 @@ func (s *muxServer) serverDiscovery(ctx context.Context) error { } // NewMuxServer returns a muxed server that will route gRPC requests between -// tfprotov5.ProviderServers specified. The GetProviderSchema method of each -// is called to verify that the overall muxed server is compatible by ensuring: +// tfprotov6.ProviderServers specified. When the GetProviderSchema RPC of each +// is called, there is verification that the overall muxed server is compatible +// by ensuring: // // - All provider schemas exactly match // - All provider meta schemas exactly match // - Only one provider implements each managed resource // - Only one provider implements each data source // - Only one provider implements each function -func NewMuxServer(_ context.Context, servers ...func() tfprotov5.ProviderServer) (*muxServer, error) { +func NewMuxServer(_ context.Context, servers ...func() tfprotov6.ProviderServer) (*muxServer, error) { result := muxServer{ - dataSources: make(map[string]tfprotov5.ProviderServer), - functions: make(map[string]tfprotov5.ProviderServer), - resources: make(map[string]tfprotov5.ProviderServer), - resourceCapabilities: make(map[string]*tfprotov5.ServerCapabilities), + dataSources: make(map[string]tfprotov6.ProviderServer), + functions: make(map[string]tfprotov6.ProviderServer), + resources: make(map[string]tfprotov6.ProviderServer), + resourceCapabilities: make(map[string]*tfprotov6.ServerCapabilities), + servers: make([]tfprotov6.ProviderServer, 0, len(servers)), } for _, server := range servers { diff --git a/vendor/github.com/hashicorp/terraform-plugin-mux/tf5muxserver/mux_server_ApplyResourceChange.go b/vendor/github.com/hashicorp/terraform-plugin-mux/tf6muxserver/mux_server_ApplyResourceChange.go similarity index 76% rename from vendor/github.com/hashicorp/terraform-plugin-mux/tf5muxserver/mux_server_ApplyResourceChange.go rename to vendor/github.com/hashicorp/terraform-plugin-mux/tf6muxserver/mux_server_ApplyResourceChange.go index 42ef05208..e59d919ff 100644 --- a/vendor/github.com/hashicorp/terraform-plugin-mux/tf5muxserver/mux_server_ApplyResourceChange.go +++ b/vendor/github.com/hashicorp/terraform-plugin-mux/tf6muxserver/mux_server_ApplyResourceChange.go @@ -1,19 +1,19 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -package tf5muxserver +package tf6muxserver import ( "context" - "github.com/hashicorp/terraform-plugin-go/tfprotov5" + "github.com/hashicorp/terraform-plugin-go/tfprotov6" "github.com/hashicorp/terraform-plugin-mux/internal/logging" ) // ApplyResourceChange calls the ApplyResourceChange method, passing `req`, on // the provider that returned the resource specified by req.TypeName in its // schema. -func (s *muxServer) ApplyResourceChange(ctx context.Context, req *tfprotov5.ApplyResourceChangeRequest) (*tfprotov5.ApplyResourceChangeResponse, error) { +func (s *muxServer) ApplyResourceChange(ctx context.Context, req *tfprotov6.ApplyResourceChangeRequest) (*tfprotov6.ApplyResourceChangeResponse, error) { rpc := "ApplyResourceChange" ctx = logging.InitContext(ctx) ctx = logging.RpcContext(ctx, rpc) @@ -25,12 +25,12 @@ func (s *muxServer) ApplyResourceChange(ctx context.Context, req *tfprotov5.Appl } if diagnosticsHasError(diags) { - return &tfprotov5.ApplyResourceChangeResponse{ + return &tfprotov6.ApplyResourceChangeResponse{ Diagnostics: diags, }, nil } - ctx = logging.Tfprotov5ProviderServerContext(ctx, server) + ctx = logging.Tfprotov6ProviderServerContext(ctx, server) logging.MuxTrace(ctx, "calling downstream server") return server.ApplyResourceChange(ctx, req) diff --git a/vendor/github.com/hashicorp/terraform-plugin-mux/tf5muxserver/mux_server_CallFunction.go b/vendor/github.com/hashicorp/terraform-plugin-mux/tf6muxserver/mux_server_CallFunction.go similarity index 74% rename from vendor/github.com/hashicorp/terraform-plugin-mux/tf5muxserver/mux_server_CallFunction.go rename to vendor/github.com/hashicorp/terraform-plugin-mux/tf6muxserver/mux_server_CallFunction.go index 7e4ec8cab..b600d498c 100644 --- a/vendor/github.com/hashicorp/terraform-plugin-mux/tf5muxserver/mux_server_CallFunction.go +++ b/vendor/github.com/hashicorp/terraform-plugin-mux/tf6muxserver/mux_server_CallFunction.go @@ -1,18 +1,18 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -package tf5muxserver +package tf6muxserver import ( "context" - "github.com/hashicorp/terraform-plugin-go/tfprotov5" + "github.com/hashicorp/terraform-plugin-go/tfprotov6" "github.com/hashicorp/terraform-plugin-mux/internal/logging" ) // CallFunction calls the CallFunction method of the underlying provider // serving the function. -func (s *muxServer) CallFunction(ctx context.Context, req *tfprotov5.CallFunctionRequest) (*tfprotov5.CallFunctionResponse, error) { +func (s *muxServer) CallFunction(ctx context.Context, req *tfprotov6.CallFunctionRequest) (*tfprotov6.CallFunctionResponse, error) { rpc := "CallFunction" ctx = logging.InitContext(ctx) ctx = logging.RpcContext(ctx, rpc) @@ -24,22 +24,22 @@ func (s *muxServer) CallFunction(ctx context.Context, req *tfprotov5.CallFunctio } if diagnosticsHasError(diags) { - return &tfprotov5.CallFunctionResponse{ + return &tfprotov6.CallFunctionResponse{ Diagnostics: diags, }, nil } - ctx = logging.Tfprotov5ProviderServerContext(ctx, server) + ctx = logging.Tfprotov6ProviderServerContext(ctx, server) // Remove and call server.CallFunction below directly. // Reference: https://github.com/hashicorp/terraform-plugin-mux/issues/210 - functionServer, ok := server.(tfprotov5.FunctionServer) + functionServer, ok := server.(tfprotov6.FunctionServer) if !ok { - resp := &tfprotov5.CallFunctionResponse{ - Diagnostics: []*tfprotov5.Diagnostic{ + resp := &tfprotov6.CallFunctionResponse{ + Diagnostics: []*tfprotov6.Diagnostic{ { - Severity: tfprotov5.DiagnosticSeverityError, + Severity: tfprotov6.DiagnosticSeverityError, Summary: "Provider Functions Not Implemented", Detail: "A provider-defined function call was received by the provider, however the provider does not implement functions. " + "Either upgrade the provider to a version that implements provider-defined functions or this is a bug in Terraform that should be reported to the Terraform maintainers.", diff --git a/vendor/github.com/hashicorp/terraform-plugin-mux/tf5muxserver/mux_server_ConfigureProvider.go b/vendor/github.com/hashicorp/terraform-plugin-mux/tf6muxserver/mux_server_ConfigureProvider.go similarity index 74% rename from vendor/github.com/hashicorp/terraform-plugin-mux/tf5muxserver/mux_server_ConfigureProvider.go rename to vendor/github.com/hashicorp/terraform-plugin-mux/tf6muxserver/mux_server_ConfigureProvider.go index 9490cee18..a34184889 100644 --- a/vendor/github.com/hashicorp/terraform-plugin-mux/tf5muxserver/mux_server_ConfigureProvider.go +++ b/vendor/github.com/hashicorp/terraform-plugin-mux/tf6muxserver/mux_server_ConfigureProvider.go @@ -1,13 +1,13 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -package tf5muxserver +package tf6muxserver import ( "context" "fmt" - "github.com/hashicorp/terraform-plugin-go/tfprotov5" + "github.com/hashicorp/terraform-plugin-go/tfprotov6" "github.com/hashicorp/terraform-plugin-mux/internal/logging" ) @@ -15,14 +15,14 @@ import ( // time, passing `req`. Any Diagnostic with severity error will abort the // process and return immediately; non-Error severity Diagnostics will be // combined and returned. -func (s *muxServer) ConfigureProvider(ctx context.Context, req *tfprotov5.ConfigureProviderRequest) (*tfprotov5.ConfigureProviderResponse, error) { +func (s *muxServer) ConfigureProvider(ctx context.Context, req *tfprotov6.ConfigureProviderRequest) (*tfprotov6.ConfigureProviderResponse, error) { rpc := "ConfigureProvider" ctx = logging.InitContext(ctx) ctx = logging.RpcContext(ctx, rpc) - var diags []*tfprotov5.Diagnostic + var diags []*tfprotov6.Diagnostic for _, server := range s.servers { - ctx = logging.Tfprotov5ProviderServerContext(ctx, server) + ctx = logging.Tfprotov6ProviderServerContext(ctx, server) logging.MuxTrace(ctx, "calling downstream server") resp, err := server.ConfigureProvider(ctx, req) @@ -38,7 +38,7 @@ func (s *muxServer) ConfigureProvider(ctx context.Context, req *tfprotov5.Config diags = append(diags, diag) - if diag.Severity != tfprotov5.DiagnosticSeverityError { + if diag.Severity != tfprotov6.DiagnosticSeverityError { continue } @@ -48,5 +48,5 @@ func (s *muxServer) ConfigureProvider(ctx context.Context, req *tfprotov5.Config } } - return &tfprotov5.ConfigureProviderResponse{Diagnostics: diags}, nil + return &tfprotov6.ConfigureProviderResponse{Diagnostics: diags}, nil } diff --git a/vendor/github.com/hashicorp/terraform-plugin-mux/tf5muxserver/mux_server_GetFunctions.go b/vendor/github.com/hashicorp/terraform-plugin-mux/tf6muxserver/mux_server_GetFunctions.go similarity index 72% rename from vendor/github.com/hashicorp/terraform-plugin-mux/tf5muxserver/mux_server_GetFunctions.go rename to vendor/github.com/hashicorp/terraform-plugin-mux/tf6muxserver/mux_server_GetFunctions.go index c8927fc0d..cbb484e2b 100644 --- a/vendor/github.com/hashicorp/terraform-plugin-mux/tf5muxserver/mux_server_GetFunctions.go +++ b/vendor/github.com/hashicorp/terraform-plugin-mux/tf6muxserver/mux_server_GetFunctions.go @@ -1,21 +1,21 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -package tf5muxserver +package tf6muxserver import ( "context" "fmt" - "github.com/hashicorp/terraform-plugin-go/tfprotov5" + "github.com/hashicorp/terraform-plugin-go/tfprotov6" "github.com/hashicorp/terraform-plugin-mux/internal/logging" ) -// GetFunctions merges the functions returned by the tfprotov5.ProviderServers +// GetFunctions merges the functions returned by the tfprotov6.ProviderServers // associated with muxServer into a single response. Functions must be returned // from only one server or an error diagnostic is returned. -func (s *muxServer) GetFunctions(ctx context.Context, req *tfprotov5.GetFunctionsRequest) (*tfprotov5.GetFunctionsResponse, error) { +func (s *muxServer) GetFunctions(ctx context.Context, req *tfprotov6.GetFunctionsRequest) (*tfprotov6.GetFunctionsResponse, error) { rpc := "GetFunctions" ctx = logging.InitContext(ctx) ctx = logging.RpcContext(ctx, rpc) @@ -23,16 +23,16 @@ func (s *muxServer) GetFunctions(ctx context.Context, req *tfprotov5.GetFunction s.serverDiscoveryMutex.Lock() defer s.serverDiscoveryMutex.Unlock() - resp := &tfprotov5.GetFunctionsResponse{ - Functions: make(map[string]*tfprotov5.Function), + resp := &tfprotov6.GetFunctionsResponse{ + Functions: make(map[string]*tfprotov6.Function), } for _, server := range s.servers { - ctx := logging.Tfprotov5ProviderServerContext(ctx, server) + ctx := logging.Tfprotov6ProviderServerContext(ctx, server) // Remove and call server.GetFunctions below directly. // Reference: https://github.com/hashicorp/terraform-plugin-mux/issues/210 - functionServer, ok := server.(tfprotov5.FunctionServer) + functionServer, ok := server.(tfprotov6.FunctionServer) if !ok { continue @@ -40,8 +40,8 @@ func (s *muxServer) GetFunctions(ctx context.Context, req *tfprotov5.GetFunction logging.MuxTrace(ctx, "calling downstream server") - // serverResp, err := server.GetFunctions(ctx, &tfprotov5.GetFunctionsRequest{}) - serverResp, err := functionServer.GetFunctions(ctx, &tfprotov5.GetFunctionsRequest{}) + // serverResp, err := server.GetFunctions(ctx, &tfprotov6.GetFunctionsRequest{}) + serverResp, err := functionServer.GetFunctions(ctx, &tfprotov6.GetFunctionsRequest{}) if err != nil { return resp, fmt.Errorf("error calling GetFunctions for %T: %w", server, err) diff --git a/vendor/github.com/hashicorp/terraform-plugin-mux/tf5muxserver/mux_server_GetMetadata.go b/vendor/github.com/hashicorp/terraform-plugin-mux/tf6muxserver/mux_server_GetMetadata.go similarity index 76% rename from vendor/github.com/hashicorp/terraform-plugin-mux/tf5muxserver/mux_server_GetMetadata.go rename to vendor/github.com/hashicorp/terraform-plugin-mux/tf6muxserver/mux_server_GetMetadata.go index bd3e1b444..a181654ae 100644 --- a/vendor/github.com/hashicorp/terraform-plugin-mux/tf5muxserver/mux_server_GetMetadata.go +++ b/vendor/github.com/hashicorp/terraform-plugin-mux/tf6muxserver/mux_server_GetMetadata.go @@ -1,22 +1,22 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -package tf5muxserver +package tf6muxserver import ( "context" "fmt" - "github.com/hashicorp/terraform-plugin-go/tfprotov5" + "github.com/hashicorp/terraform-plugin-go/tfprotov6" "github.com/hashicorp/terraform-plugin-mux/internal/logging" ) // GetMetadata merges the metadata returned by the -// tfprotov5.ProviderServers associated with muxServer into a single response. +// tfprotov6.ProviderServers associated with muxServer into a single response. // Resources and data sources must be returned from only one server or an error // diagnostic is returned. -func (s *muxServer) GetMetadata(ctx context.Context, req *tfprotov5.GetMetadataRequest) (*tfprotov5.GetMetadataResponse, error) { +func (s *muxServer) GetMetadata(ctx context.Context, req *tfprotov6.GetMetadataRequest) (*tfprotov6.GetMetadataResponse, error) { rpc := "GetMetadata" ctx = logging.InitContext(ctx) ctx = logging.RpcContext(ctx, rpc) @@ -24,18 +24,18 @@ func (s *muxServer) GetMetadata(ctx context.Context, req *tfprotov5.GetMetadataR s.serverDiscoveryMutex.Lock() defer s.serverDiscoveryMutex.Unlock() - resp := &tfprotov5.GetMetadataResponse{ - DataSources: make([]tfprotov5.DataSourceMetadata, 0), - Functions: make([]tfprotov5.FunctionMetadata, 0), - Resources: make([]tfprotov5.ResourceMetadata, 0), + resp := &tfprotov6.GetMetadataResponse{ + DataSources: make([]tfprotov6.DataSourceMetadata, 0), + Functions: make([]tfprotov6.FunctionMetadata, 0), + Resources: make([]tfprotov6.ResourceMetadata, 0), ServerCapabilities: serverCapabilities, } for _, server := range s.servers { - ctx := logging.Tfprotov5ProviderServerContext(ctx, server) + ctx := logging.Tfprotov6ProviderServerContext(ctx, server) logging.MuxTrace(ctx, "calling downstream server") - serverResp, err := server.GetMetadata(ctx, &tfprotov5.GetMetadataRequest{}) + serverResp, err := server.GetMetadata(ctx, &tfprotov6.GetMetadataRequest{}) if err != nil { return resp, fmt.Errorf("error calling GetMetadata for %T: %w", server, err) @@ -81,7 +81,7 @@ func (s *muxServer) GetMetadata(ctx context.Context, req *tfprotov5.GetMetadataR return resp, nil } -func datasourceMetadataContainsTypeName(metadatas []tfprotov5.DataSourceMetadata, typeName string) bool { +func datasourceMetadataContainsTypeName(metadatas []tfprotov6.DataSourceMetadata, typeName string) bool { for _, metadata := range metadatas { if typeName == metadata.TypeName { return true @@ -91,7 +91,7 @@ func datasourceMetadataContainsTypeName(metadatas []tfprotov5.DataSourceMetadata return false } -func functionMetadataContainsName(metadatas []tfprotov5.FunctionMetadata, name string) bool { +func functionMetadataContainsName(metadatas []tfprotov6.FunctionMetadata, name string) bool { for _, metadata := range metadatas { if name == metadata.Name { return true @@ -101,7 +101,7 @@ func functionMetadataContainsName(metadatas []tfprotov5.FunctionMetadata, name s return false } -func resourceMetadataContainsTypeName(metadatas []tfprotov5.ResourceMetadata, typeName string) bool { +func resourceMetadataContainsTypeName(metadatas []tfprotov6.ResourceMetadata, typeName string) bool { for _, metadata := range metadatas { if typeName == metadata.TypeName { return true diff --git a/vendor/github.com/hashicorp/terraform-plugin-mux/tf5muxserver/mux_server_GetProviderSchema.go b/vendor/github.com/hashicorp/terraform-plugin-mux/tf6muxserver/mux_server_GetProviderSchema.go similarity index 80% rename from vendor/github.com/hashicorp/terraform-plugin-mux/tf5muxserver/mux_server_GetProviderSchema.go rename to vendor/github.com/hashicorp/terraform-plugin-mux/tf6muxserver/mux_server_GetProviderSchema.go index 19bfd8781..e725dcc27 100644 --- a/vendor/github.com/hashicorp/terraform-plugin-mux/tf5muxserver/mux_server_GetProviderSchema.go +++ b/vendor/github.com/hashicorp/terraform-plugin-mux/tf6muxserver/mux_server_GetProviderSchema.go @@ -1,22 +1,22 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -package tf5muxserver +package tf6muxserver import ( "context" "fmt" - "github.com/hashicorp/terraform-plugin-go/tfprotov5" + "github.com/hashicorp/terraform-plugin-go/tfprotov6" "github.com/hashicorp/terraform-plugin-mux/internal/logging" ) // GetProviderSchema merges the schemas returned by the -// tfprotov5.ProviderServers associated with muxServer into a single schema. +// tfprotov6.ProviderServers associated with muxServer into a single schema. // Resources and data sources must be returned from only one server. Provider // and ProviderMeta schemas must be identical between all servers. -func (s *muxServer) GetProviderSchema(ctx context.Context, req *tfprotov5.GetProviderSchemaRequest) (*tfprotov5.GetProviderSchemaResponse, error) { +func (s *muxServer) GetProviderSchema(ctx context.Context, req *tfprotov6.GetProviderSchemaRequest) (*tfprotov6.GetProviderSchemaResponse, error) { rpc := "GetProviderSchema" ctx = logging.InitContext(ctx) ctx = logging.RpcContext(ctx, rpc) @@ -24,18 +24,18 @@ func (s *muxServer) GetProviderSchema(ctx context.Context, req *tfprotov5.GetPro s.serverDiscoveryMutex.Lock() defer s.serverDiscoveryMutex.Unlock() - resp := &tfprotov5.GetProviderSchemaResponse{ - DataSourceSchemas: make(map[string]*tfprotov5.Schema), - Functions: make(map[string]*tfprotov5.Function), - ResourceSchemas: make(map[string]*tfprotov5.Schema), + resp := &tfprotov6.GetProviderSchemaResponse{ + DataSourceSchemas: make(map[string]*tfprotov6.Schema), + Functions: make(map[string]*tfprotov6.Function), + ResourceSchemas: make(map[string]*tfprotov6.Schema), ServerCapabilities: serverCapabilities, } for _, server := range s.servers { - ctx := logging.Tfprotov5ProviderServerContext(ctx, server) + ctx := logging.Tfprotov6ProviderServerContext(ctx, server) logging.MuxTrace(ctx, "calling downstream server") - serverResp, err := server.GetProviderSchema(ctx, &tfprotov5.GetProviderSchemaRequest{}) + serverResp, err := server.GetProviderSchema(ctx, &tfprotov6.GetProviderSchemaRequest{}) if err != nil { return resp, fmt.Errorf("error calling GetProviderSchema for %T: %w", server, err) @@ -45,8 +45,8 @@ func (s *muxServer) GetProviderSchema(ctx context.Context, req *tfprotov5.GetPro if serverResp.Provider != nil { if resp.Provider != nil && !schemaEquals(serverResp.Provider, resp.Provider) { - resp.Diagnostics = append(resp.Diagnostics, &tfprotov5.Diagnostic{ - Severity: tfprotov5.DiagnosticSeverityError, + resp.Diagnostics = append(resp.Diagnostics, &tfprotov6.Diagnostic{ + Severity: tfprotov6.DiagnosticSeverityError, Summary: "Invalid Provider Server Combination", Detail: "The combined provider has differing provider schema implementations across providers. " + "Provider schemas must be identical across providers. " + @@ -60,8 +60,8 @@ func (s *muxServer) GetProviderSchema(ctx context.Context, req *tfprotov5.GetPro if serverResp.ProviderMeta != nil { if resp.ProviderMeta != nil && !schemaEquals(serverResp.ProviderMeta, resp.ProviderMeta) { - resp.Diagnostics = append(resp.Diagnostics, &tfprotov5.Diagnostic{ - Severity: tfprotov5.DiagnosticSeverityError, + resp.Diagnostics = append(resp.Diagnostics, &tfprotov6.Diagnostic{ + Severity: tfprotov6.DiagnosticSeverityError, Summary: "Invalid Provider Server Combination", Detail: "The combined provider has differing provider meta schema implementations across providers. " + "Provider meta schemas must be identical across providers. " + diff --git a/vendor/github.com/hashicorp/terraform-plugin-mux/tf5muxserver/mux_server_ImportResourceState.go b/vendor/github.com/hashicorp/terraform-plugin-mux/tf6muxserver/mux_server_ImportResourceState.go similarity index 76% rename from vendor/github.com/hashicorp/terraform-plugin-mux/tf5muxserver/mux_server_ImportResourceState.go rename to vendor/github.com/hashicorp/terraform-plugin-mux/tf6muxserver/mux_server_ImportResourceState.go index 969c638ae..e0da44eae 100644 --- a/vendor/github.com/hashicorp/terraform-plugin-mux/tf5muxserver/mux_server_ImportResourceState.go +++ b/vendor/github.com/hashicorp/terraform-plugin-mux/tf6muxserver/mux_server_ImportResourceState.go @@ -1,19 +1,19 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -package tf5muxserver +package tf6muxserver import ( "context" - "github.com/hashicorp/terraform-plugin-go/tfprotov5" + "github.com/hashicorp/terraform-plugin-go/tfprotov6" "github.com/hashicorp/terraform-plugin-mux/internal/logging" ) // ImportResourceState calls the ImportResourceState method, passing `req`, on // the provider that returned the resource specified by req.TypeName in its // schema. -func (s *muxServer) ImportResourceState(ctx context.Context, req *tfprotov5.ImportResourceStateRequest) (*tfprotov5.ImportResourceStateResponse, error) { +func (s *muxServer) ImportResourceState(ctx context.Context, req *tfprotov6.ImportResourceStateRequest) (*tfprotov6.ImportResourceStateResponse, error) { rpc := "ImportResourceState" ctx = logging.InitContext(ctx) ctx = logging.RpcContext(ctx, rpc) @@ -25,12 +25,12 @@ func (s *muxServer) ImportResourceState(ctx context.Context, req *tfprotov5.Impo } if diagnosticsHasError(diags) { - return &tfprotov5.ImportResourceStateResponse{ + return &tfprotov6.ImportResourceStateResponse{ Diagnostics: diags, }, nil } - ctx = logging.Tfprotov5ProviderServerContext(ctx, server) + ctx = logging.Tfprotov6ProviderServerContext(ctx, server) logging.MuxTrace(ctx, "calling downstream server") return server.ImportResourceState(ctx, req) diff --git a/vendor/github.com/hashicorp/terraform-plugin-mux/tf5muxserver/mux_server_PlanResourceChange.go b/vendor/github.com/hashicorp/terraform-plugin-mux/tf6muxserver/mux_server_PlanResourceChange.go similarity index 84% rename from vendor/github.com/hashicorp/terraform-plugin-mux/tf5muxserver/mux_server_PlanResourceChange.go rename to vendor/github.com/hashicorp/terraform-plugin-mux/tf6muxserver/mux_server_PlanResourceChange.go index 6454328aa..13a280b29 100644 --- a/vendor/github.com/hashicorp/terraform-plugin-mux/tf5muxserver/mux_server_PlanResourceChange.go +++ b/vendor/github.com/hashicorp/terraform-plugin-mux/tf6muxserver/mux_server_PlanResourceChange.go @@ -1,20 +1,20 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -package tf5muxserver +package tf6muxserver import ( "context" "fmt" - "github.com/hashicorp/terraform-plugin-go/tfprotov5" + "github.com/hashicorp/terraform-plugin-go/tfprotov6" "github.com/hashicorp/terraform-plugin-mux/internal/logging" ) // PlanResourceChange calls the PlanResourceChange method, passing `req`, on // the provider that returned the resource specified by req.TypeName in its // schema. -func (s *muxServer) PlanResourceChange(ctx context.Context, req *tfprotov5.PlanResourceChangeRequest) (*tfprotov5.PlanResourceChangeResponse, error) { +func (s *muxServer) PlanResourceChange(ctx context.Context, req *tfprotov6.PlanResourceChangeRequest) (*tfprotov6.PlanResourceChangeResponse, error) { rpc := "PlanResourceChange" ctx = logging.InitContext(ctx) ctx = logging.RpcContext(ctx, rpc) @@ -26,12 +26,12 @@ func (s *muxServer) PlanResourceChange(ctx context.Context, req *tfprotov5.PlanR } if diagnosticsHasError(diags) { - return &tfprotov5.PlanResourceChangeResponse{ + return &tfprotov6.PlanResourceChangeResponse{ Diagnostics: diags, }, nil } - ctx = logging.Tfprotov5ProviderServerContext(ctx, server) + ctx = logging.Tfprotov6ProviderServerContext(ctx, server) // Prevent ServerCapabilities.PlanDestroy from sending destroy plans to // servers which do not enable the capability. @@ -39,7 +39,7 @@ func (s *muxServer) PlanResourceChange(ctx context.Context, req *tfprotov5.PlanR if req.ProposedNewState == nil { logging.MuxTrace(ctx, "server does not enable destroy plans, returning without calling downstream server") - resp := &tfprotov5.PlanResourceChangeResponse{ + resp := &tfprotov6.PlanResourceChangeResponse{ // Presumably, we must preserve any prior private state so it // is still available during ApplyResourceChange. PlannedPrivate: req.PriorPrivate, @@ -57,7 +57,7 @@ func (s *muxServer) PlanResourceChange(ctx context.Context, req *tfprotov5.PlanR if isDestroyPlan { logging.MuxTrace(ctx, "server does not enable destroy plans, returning without calling downstream server") - resp := &tfprotov5.PlanResourceChangeResponse{ + resp := &tfprotov6.PlanResourceChangeResponse{ // Presumably, we must preserve any prior private state so it // is still available during ApplyResourceChange. PlannedPrivate: req.PriorPrivate, diff --git a/vendor/github.com/hashicorp/terraform-plugin-mux/tf5muxserver/mux_server_ReadDataSource.go b/vendor/github.com/hashicorp/terraform-plugin-mux/tf6muxserver/mux_server_ReadDataSource.go similarity index 75% rename from vendor/github.com/hashicorp/terraform-plugin-mux/tf5muxserver/mux_server_ReadDataSource.go rename to vendor/github.com/hashicorp/terraform-plugin-mux/tf6muxserver/mux_server_ReadDataSource.go index cacdae5c3..13f7990b4 100644 --- a/vendor/github.com/hashicorp/terraform-plugin-mux/tf5muxserver/mux_server_ReadDataSource.go +++ b/vendor/github.com/hashicorp/terraform-plugin-mux/tf6muxserver/mux_server_ReadDataSource.go @@ -1,19 +1,19 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -package tf5muxserver +package tf6muxserver import ( "context" - "github.com/hashicorp/terraform-plugin-go/tfprotov5" + "github.com/hashicorp/terraform-plugin-go/tfprotov6" "github.com/hashicorp/terraform-plugin-mux/internal/logging" ) // ReadDataSource calls the ReadDataSource method, passing `req`, on the // provider that returned the data source specified by req.TypeName in its // schema. -func (s *muxServer) ReadDataSource(ctx context.Context, req *tfprotov5.ReadDataSourceRequest) (*tfprotov5.ReadDataSourceResponse, error) { +func (s *muxServer) ReadDataSource(ctx context.Context, req *tfprotov6.ReadDataSourceRequest) (*tfprotov6.ReadDataSourceResponse, error) { rpc := "ReadDataSource" ctx = logging.InitContext(ctx) ctx = logging.RpcContext(ctx, rpc) @@ -25,12 +25,12 @@ func (s *muxServer) ReadDataSource(ctx context.Context, req *tfprotov5.ReadDataS } if diagnosticsHasError(diags) { - return &tfprotov5.ReadDataSourceResponse{ + return &tfprotov6.ReadDataSourceResponse{ Diagnostics: diags, }, nil } - ctx = logging.Tfprotov5ProviderServerContext(ctx, server) + ctx = logging.Tfprotov6ProviderServerContext(ctx, server) logging.MuxTrace(ctx, "calling downstream server") return server.ReadDataSource(ctx, req) diff --git a/vendor/github.com/hashicorp/terraform-plugin-mux/tf5muxserver/mux_server_ReadResource.go b/vendor/github.com/hashicorp/terraform-plugin-mux/tf6muxserver/mux_server_ReadResource.go similarity index 75% rename from vendor/github.com/hashicorp/terraform-plugin-mux/tf5muxserver/mux_server_ReadResource.go rename to vendor/github.com/hashicorp/terraform-plugin-mux/tf6muxserver/mux_server_ReadResource.go index b1c387700..1150920fb 100644 --- a/vendor/github.com/hashicorp/terraform-plugin-mux/tf5muxserver/mux_server_ReadResource.go +++ b/vendor/github.com/hashicorp/terraform-plugin-mux/tf6muxserver/mux_server_ReadResource.go @@ -1,18 +1,18 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -package tf5muxserver +package tf6muxserver import ( "context" - "github.com/hashicorp/terraform-plugin-go/tfprotov5" + "github.com/hashicorp/terraform-plugin-go/tfprotov6" "github.com/hashicorp/terraform-plugin-mux/internal/logging" ) // ReadResource calls the ReadResource method, passing `req`, on the provider // that returned the resource specified by req.TypeName in its schema. -func (s *muxServer) ReadResource(ctx context.Context, req *tfprotov5.ReadResourceRequest) (*tfprotov5.ReadResourceResponse, error) { +func (s *muxServer) ReadResource(ctx context.Context, req *tfprotov6.ReadResourceRequest) (*tfprotov6.ReadResourceResponse, error) { rpc := "ReadResource" ctx = logging.InitContext(ctx) ctx = logging.RpcContext(ctx, rpc) @@ -24,12 +24,12 @@ func (s *muxServer) ReadResource(ctx context.Context, req *tfprotov5.ReadResourc } if diagnosticsHasError(diags) { - return &tfprotov5.ReadResourceResponse{ + return &tfprotov6.ReadResourceResponse{ Diagnostics: diags, }, nil } - ctx = logging.Tfprotov5ProviderServerContext(ctx, server) + ctx = logging.Tfprotov6ProviderServerContext(ctx, server) logging.MuxTrace(ctx, "calling downstream server") return server.ReadResource(ctx, req) diff --git a/vendor/github.com/hashicorp/terraform-plugin-mux/tf5muxserver/mux_server_StopProvider.go b/vendor/github.com/hashicorp/terraform-plugin-mux/tf6muxserver/mux_server_StopProvider.go similarity index 79% rename from vendor/github.com/hashicorp/terraform-plugin-mux/tf5muxserver/mux_server_StopProvider.go rename to vendor/github.com/hashicorp/terraform-plugin-mux/tf6muxserver/mux_server_StopProvider.go index 9d165bf92..1d1243ed1 100644 --- a/vendor/github.com/hashicorp/terraform-plugin-mux/tf5muxserver/mux_server_StopProvider.go +++ b/vendor/github.com/hashicorp/terraform-plugin-mux/tf6muxserver/mux_server_StopProvider.go @@ -1,14 +1,14 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -package tf5muxserver +package tf6muxserver import ( "context" "fmt" "strings" - "github.com/hashicorp/terraform-plugin-go/tfprotov5" + "github.com/hashicorp/terraform-plugin-go/tfprotov6" "github.com/hashicorp/terraform-plugin-mux/internal/logging" ) @@ -16,14 +16,14 @@ import ( // with the muxServer, one at a time. All Error fields will be joined // together and returned, but will not prevent the rest of the providers' // StopProvider methods from being called. -func (s *muxServer) StopProvider(ctx context.Context, req *tfprotov5.StopProviderRequest) (*tfprotov5.StopProviderResponse, error) { +func (s *muxServer) StopProvider(ctx context.Context, req *tfprotov6.StopProviderRequest) (*tfprotov6.StopProviderResponse, error) { rpc := "StopProvider" ctx = logging.InitContext(ctx) ctx = logging.RpcContext(ctx, rpc) var errs []string for _, server := range s.servers { - ctx = logging.Tfprotov5ProviderServerContext(ctx, server) + ctx = logging.Tfprotov6ProviderServerContext(ctx, server) logging.MuxTrace(ctx, "calling downstream server") resp, err := server.StopProvider(ctx, req) @@ -37,7 +37,7 @@ func (s *muxServer) StopProvider(ctx context.Context, req *tfprotov5.StopProvide } } - return &tfprotov5.StopProviderResponse{ + return &tfprotov6.StopProviderResponse{ Error: strings.Join(errs, "\n"), }, nil } diff --git a/vendor/github.com/hashicorp/terraform-plugin-mux/tf5muxserver/mux_server_UpgradeResourceState.go b/vendor/github.com/hashicorp/terraform-plugin-mux/tf6muxserver/mux_server_UpgradeResourceState.go similarity index 76% rename from vendor/github.com/hashicorp/terraform-plugin-mux/tf5muxserver/mux_server_UpgradeResourceState.go rename to vendor/github.com/hashicorp/terraform-plugin-mux/tf6muxserver/mux_server_UpgradeResourceState.go index 5c40989be..f31df9493 100644 --- a/vendor/github.com/hashicorp/terraform-plugin-mux/tf5muxserver/mux_server_UpgradeResourceState.go +++ b/vendor/github.com/hashicorp/terraform-plugin-mux/tf6muxserver/mux_server_UpgradeResourceState.go @@ -1,19 +1,19 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -package tf5muxserver +package tf6muxserver import ( "context" - "github.com/hashicorp/terraform-plugin-go/tfprotov5" + "github.com/hashicorp/terraform-plugin-go/tfprotov6" "github.com/hashicorp/terraform-plugin-mux/internal/logging" ) // UpgradeResourceState calls the UpgradeResourceState method, passing `req`, // on the provider that returned the resource specified by req.TypeName in its // schema. -func (s *muxServer) UpgradeResourceState(ctx context.Context, req *tfprotov5.UpgradeResourceStateRequest) (*tfprotov5.UpgradeResourceStateResponse, error) { +func (s *muxServer) UpgradeResourceState(ctx context.Context, req *tfprotov6.UpgradeResourceStateRequest) (*tfprotov6.UpgradeResourceStateResponse, error) { rpc := "UpgradeResourceState" ctx = logging.InitContext(ctx) ctx = logging.RpcContext(ctx, rpc) @@ -25,12 +25,12 @@ func (s *muxServer) UpgradeResourceState(ctx context.Context, req *tfprotov5.Upg } if diagnosticsHasError(diags) { - return &tfprotov5.UpgradeResourceStateResponse{ + return &tfprotov6.UpgradeResourceStateResponse{ Diagnostics: diags, }, nil } - ctx = logging.Tfprotov5ProviderServerContext(ctx, server) + ctx = logging.Tfprotov6ProviderServerContext(ctx, server) logging.MuxTrace(ctx, "calling downstream server") return server.UpgradeResourceState(ctx, req) diff --git a/vendor/github.com/hashicorp/terraform-plugin-mux/tf5muxserver/mux_server_ValidateDataSourceConfig.go b/vendor/github.com/hashicorp/terraform-plugin-mux/tf6muxserver/mux_server_ValidateDataResourceConfig.go similarity index 50% rename from vendor/github.com/hashicorp/terraform-plugin-mux/tf5muxserver/mux_server_ValidateDataSourceConfig.go rename to vendor/github.com/hashicorp/terraform-plugin-mux/tf6muxserver/mux_server_ValidateDataResourceConfig.go index cf8d2e035..8c8940805 100644 --- a/vendor/github.com/hashicorp/terraform-plugin-mux/tf5muxserver/mux_server_ValidateDataSourceConfig.go +++ b/vendor/github.com/hashicorp/terraform-plugin-mux/tf6muxserver/mux_server_ValidateDataResourceConfig.go @@ -1,20 +1,20 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -package tf5muxserver +package tf6muxserver import ( "context" - "github.com/hashicorp/terraform-plugin-go/tfprotov5" + "github.com/hashicorp/terraform-plugin-go/tfprotov6" "github.com/hashicorp/terraform-plugin-mux/internal/logging" ) -// ValidateDataSourceConfig calls the ValidateDataSourceConfig method, passing +// ValidateDataResourceConfig calls the ValidateDataResourceConfig method, passing // `req`, on the provider that returned the data source specified by // req.TypeName in its schema. -func (s *muxServer) ValidateDataSourceConfig(ctx context.Context, req *tfprotov5.ValidateDataSourceConfigRequest) (*tfprotov5.ValidateDataSourceConfigResponse, error) { - rpc := "ValidateDataSourceConfig" +func (s *muxServer) ValidateDataResourceConfig(ctx context.Context, req *tfprotov6.ValidateDataResourceConfigRequest) (*tfprotov6.ValidateDataResourceConfigResponse, error) { + rpc := "ValidateDataResourceConfig" ctx = logging.InitContext(ctx) ctx = logging.RpcContext(ctx, rpc) @@ -25,13 +25,13 @@ func (s *muxServer) ValidateDataSourceConfig(ctx context.Context, req *tfprotov5 } if diagnosticsHasError(diags) { - return &tfprotov5.ValidateDataSourceConfigResponse{ + return &tfprotov6.ValidateDataResourceConfigResponse{ Diagnostics: diags, }, nil } - ctx = logging.Tfprotov5ProviderServerContext(ctx, server) + ctx = logging.Tfprotov6ProviderServerContext(ctx, server) logging.MuxTrace(ctx, "calling downstream server") - return server.ValidateDataSourceConfig(ctx, req) + return server.ValidateDataResourceConfig(ctx, req) } diff --git a/vendor/github.com/hashicorp/terraform-plugin-mux/tf5muxserver/mux_server_PrepareProviderConfig.go b/vendor/github.com/hashicorp/terraform-plugin-mux/tf6muxserver/mux_server_ValidateProviderConfig.go similarity index 60% rename from vendor/github.com/hashicorp/terraform-plugin-mux/tf5muxserver/mux_server_PrepareProviderConfig.go rename to vendor/github.com/hashicorp/terraform-plugin-mux/tf6muxserver/mux_server_ValidateProviderConfig.go index d0f601440..33c2a83e5 100644 --- a/vendor/github.com/hashicorp/terraform-plugin-mux/tf5muxserver/mux_server_PrepareProviderConfig.go +++ b/vendor/github.com/hashicorp/terraform-plugin-mux/tf6muxserver/mux_server_ValidateProviderConfig.go @@ -1,34 +1,34 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -package tf5muxserver +package tf6muxserver import ( "context" "fmt" - "github.com/hashicorp/terraform-plugin-go/tfprotov5" + "github.com/hashicorp/terraform-plugin-go/tfprotov6" "github.com/hashicorp/terraform-plugin-mux/internal/logging" ) -// PrepareProviderConfig calls the PrepareProviderConfig method on each server +// ValidateProviderConfig calls the ValidateProviderConfig method on each server // in order, passing `req`. Response diagnostics are appended from all servers. // Response PreparedConfig must be equal across all servers with nil values // skipped. -func (s *muxServer) PrepareProviderConfig(ctx context.Context, req *tfprotov5.PrepareProviderConfigRequest) (*tfprotov5.PrepareProviderConfigResponse, error) { - rpc := "PrepareProviderConfig" +func (s *muxServer) ValidateProviderConfig(ctx context.Context, req *tfprotov6.ValidateProviderConfigRequest) (*tfprotov6.ValidateProviderConfigResponse, error) { + rpc := "ValidateProviderConfig" ctx = logging.InitContext(ctx) ctx = logging.RpcContext(ctx, rpc) - resp := &tfprotov5.PrepareProviderConfigResponse{ + resp := &tfprotov6.ValidateProviderConfigResponse{ PreparedConfig: req.Config, // ignored by Terraform anyways } for _, server := range s.servers { - ctx = logging.Tfprotov5ProviderServerContext(ctx, server) + ctx = logging.Tfprotov6ProviderServerContext(ctx, server) logging.MuxTrace(ctx, "calling downstream server") - res, err := server.PrepareProviderConfig(ctx, req) + res, err := server.ValidateProviderConfig(ctx, req) if err != nil { return resp, fmt.Errorf("error from %T validating provider config: %w", server, err) diff --git a/vendor/github.com/hashicorp/terraform-plugin-mux/tf5muxserver/mux_server_ValidateResourceTypeConfig.go b/vendor/github.com/hashicorp/terraform-plugin-mux/tf6muxserver/mux_server_ValidateResourceConfig.go similarity index 51% rename from vendor/github.com/hashicorp/terraform-plugin-mux/tf5muxserver/mux_server_ValidateResourceTypeConfig.go rename to vendor/github.com/hashicorp/terraform-plugin-mux/tf6muxserver/mux_server_ValidateResourceConfig.go index fcb263068..025a78d2e 100644 --- a/vendor/github.com/hashicorp/terraform-plugin-mux/tf5muxserver/mux_server_ValidateResourceTypeConfig.go +++ b/vendor/github.com/hashicorp/terraform-plugin-mux/tf6muxserver/mux_server_ValidateResourceConfig.go @@ -1,20 +1,20 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -package tf5muxserver +package tf6muxserver import ( "context" - "github.com/hashicorp/terraform-plugin-go/tfprotov5" + "github.com/hashicorp/terraform-plugin-go/tfprotov6" "github.com/hashicorp/terraform-plugin-mux/internal/logging" ) -// ValidateResourceTypeConfig calls the ValidateResourceTypeConfig method, +// ValidateResourceConfig calls the ValidateResourceConfig method, // passing `req`, on the provider that returned the resource specified by // req.TypeName in its schema. -func (s *muxServer) ValidateResourceTypeConfig(ctx context.Context, req *tfprotov5.ValidateResourceTypeConfigRequest) (*tfprotov5.ValidateResourceTypeConfigResponse, error) { - rpc := "ValidateResourceTypeConfig" +func (s *muxServer) ValidateResourceConfig(ctx context.Context, req *tfprotov6.ValidateResourceConfigRequest) (*tfprotov6.ValidateResourceConfigResponse, error) { + rpc := "ValidateResourceConfig" ctx = logging.InitContext(ctx) ctx = logging.RpcContext(ctx, rpc) @@ -25,13 +25,13 @@ func (s *muxServer) ValidateResourceTypeConfig(ctx context.Context, req *tfproto } if diagnosticsHasError(diags) { - return &tfprotov5.ValidateResourceTypeConfigResponse{ + return &tfprotov6.ValidateResourceConfigResponse{ Diagnostics: diags, }, nil } - ctx = logging.Tfprotov5ProviderServerContext(ctx, server) + ctx = logging.Tfprotov6ProviderServerContext(ctx, server) logging.MuxTrace(ctx, "calling downstream server") - return server.ValidateResourceTypeConfig(ctx, req) + return server.ValidateResourceConfig(ctx, req) } diff --git a/vendor/github.com/hashicorp/terraform-plugin-mux/tf5muxserver/schema_equality.go b/vendor/github.com/hashicorp/terraform-plugin-mux/tf6muxserver/schema_equality.go similarity index 69% rename from vendor/github.com/hashicorp/terraform-plugin-mux/tf5muxserver/schema_equality.go rename to vendor/github.com/hashicorp/terraform-plugin-mux/tf6muxserver/schema_equality.go index 9e798a840..a44a6587a 100644 --- a/vendor/github.com/hashicorp/terraform-plugin-mux/tf5muxserver/schema_equality.go +++ b/vendor/github.com/hashicorp/terraform-plugin-mux/tf6muxserver/schema_equality.go @@ -1,35 +1,35 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -package tf5muxserver +package tf6muxserver import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" - "github.com/hashicorp/terraform-plugin-go/tfprotov5" + "github.com/hashicorp/terraform-plugin-go/tfprotov6" ) // schemaCmpOptions ensures comparisons of SchemaAttribute and // SchemaNestedBlock slices are considered equal despite ordering differences. var schemaCmpOptions = []cmp.Option{ - cmpopts.SortSlices(func(i, j *tfprotov5.SchemaAttribute) bool { + cmpopts.SortSlices(func(i, j *tfprotov6.SchemaAttribute) bool { return i.Name < j.Name }), - cmpopts.SortSlices(func(i, j *tfprotov5.SchemaNestedBlock) bool { + cmpopts.SortSlices(func(i, j *tfprotov6.SchemaNestedBlock) bool { return i.TypeName < j.TypeName }), - cmpopts.IgnoreFields(tfprotov5.SchemaNestedBlock{}, "MinItems", "MaxItems"), + cmpopts.IgnoreFields(tfprotov6.SchemaNestedBlock{}, "MinItems", "MaxItems"), } // schemaDiff outputs the difference between schemas while accounting for // inconsequential ordering differences in SchemaAttribute and // SchemaNestedBlock slices. -func schemaDiff(i, j *tfprotov5.Schema) string { +func schemaDiff(i, j *tfprotov6.Schema) string { return cmp.Diff(i, j, schemaCmpOptions...) } // schemaEquals asserts equality between schemas by normalizing inconsequential // ordering differences in SchemaAttribute and SchemaNestedBlock slices. -func schemaEquals(i, j *tfprotov5.Schema) bool { +func schemaEquals(i, j *tfprotov6.Schema) bool { return cmp.Equal(i, j, schemaCmpOptions...) } diff --git a/vendor/github.com/hashicorp/terraform-plugin-mux/tf5muxserver/server_capabilities.go b/vendor/github.com/hashicorp/terraform-plugin-mux/tf6muxserver/server_capabilities.go similarity index 74% rename from vendor/github.com/hashicorp/terraform-plugin-mux/tf5muxserver/server_capabilities.go rename to vendor/github.com/hashicorp/terraform-plugin-mux/tf6muxserver/server_capabilities.go index 3385d4682..7490e47c9 100644 --- a/vendor/github.com/hashicorp/terraform-plugin-mux/tf5muxserver/server_capabilities.go +++ b/vendor/github.com/hashicorp/terraform-plugin-mux/tf6muxserver/server_capabilities.go @@ -1,21 +1,21 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -package tf5muxserver +package tf6muxserver -import "github.com/hashicorp/terraform-plugin-go/tfprotov5" +import "github.com/hashicorp/terraform-plugin-go/tfprotov6" // serverCapabilities always announces all ServerCapabilities. Individual // capabilities are handled in their respective RPCs to protect downstream // servers if they are not compatible with a capability. -var serverCapabilities = &tfprotov5.ServerCapabilities{ +var serverCapabilities = &tfprotov6.ServerCapabilities{ GetProviderSchemaOptional: true, PlanDestroy: true, } // serverSupportsPlanDestroy returns true if the given ServerCapabilities is not // nil and enables the PlanDestroy capability. -func serverSupportsPlanDestroy(capabilities *tfprotov5.ServerCapabilities) bool { +func serverSupportsPlanDestroy(capabilities *tfprotov6.ServerCapabilities) bool { if capabilities == nil { return false } diff --git a/vendor/modules.txt b/vendor/modules.txt index c5341e271..c121ee61c 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -204,7 +204,10 @@ github.com/hashicorp/terraform-plugin-log/tfsdklog # github.com/hashicorp/terraform-plugin-mux v0.13.0 ## explicit; go 1.20 github.com/hashicorp/terraform-plugin-mux/internal/logging -github.com/hashicorp/terraform-plugin-mux/tf5muxserver +github.com/hashicorp/terraform-plugin-mux/internal/tfprotov5tov6 +github.com/hashicorp/terraform-plugin-mux/internal/tfprotov6tov5 +github.com/hashicorp/terraform-plugin-mux/tf5to6server +github.com/hashicorp/terraform-plugin-mux/tf6muxserver # github.com/hashicorp/terraform-plugin-sdk/v2 v2.31.0 ## explicit; go 1.20 github.com/hashicorp/terraform-plugin-sdk/v2/diag