diff --git a/pkg/config/provider.go b/pkg/config/provider.go index ee03b5f0..b9848919 100644 --- a/pkg/config/provider.go +++ b/pkg/config/provider.go @@ -351,6 +351,7 @@ func NewProvider(schema []byte, prefix string, modulePath string, metadata []byt p.Resources[name] = DefaultResource(name, terraformResource, terraformPluginFrameworkResource, providerMetadata.Resources[name], p.DefaultResourceOptions...) p.Resources[name].useTerraformPluginSDKClient = isTerraformPluginSDK p.Resources[name].useTerraformPluginFrameworkClient = isPluginFrameworkResource + p.Resources[name].tfjsonSchema = rs[name] } for i, refInjector := range p.refInjectors { if err := refInjector.InjectReferences(p.Resources); err != nil { diff --git a/pkg/config/resource.go b/pkg/config/resource.go index f45a2f96..6049eeed 100644 --- a/pkg/config/resource.go +++ b/pkg/config/resource.go @@ -13,6 +13,7 @@ import ( "github.com/crossplane/crossplane-runtime/pkg/fieldpath" "github.com/crossplane/crossplane-runtime/pkg/reconciler/managed" xpresource "github.com/crossplane/crossplane-runtime/pkg/resource" + tfjson "github.com/hashicorp/terraform-json" fwresource "github.com/hashicorp/terraform-plugin-framework/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" @@ -453,17 +454,11 @@ type Resource struct { // index notation (i.e., array/map components do not need indices). ServerSideApplyMergeStrategies ServerSideApplyMergeStrategies + // Conversions is a list of API conversion functions to be invoked by a + // conversion webhook to convert between the different API versions of a + // managed resource. Conversions []conversion.Conversion - // useTerraformPluginSDKClient indicates that a plugin SDK external client should - // be generated instead of the Terraform CLI-forking client. - useTerraformPluginSDKClient bool - - // useTerraformPluginFrameworkClient indicates that a Terraform - // Plugin Framework external client should be generated instead of - // the Terraform Plugin SDKv2 client. - useTerraformPluginFrameworkClient bool - // OverrideFieldNames allows to manually override the relevant field name to // avoid possible Go struct name conflicts that may occur after Multiversion // CRDs support. During field generation, there may be fields with the same @@ -489,6 +484,17 @@ type Resource struct { // the value of the generated Kind, for example: // "TagParameters": "ClusterTagParameters" OverrideFieldNames map[string]string + + // useTerraformPluginSDKClient indicates that a plugin SDK external client should + // be generated instead of the Terraform CLI-forking client. + useTerraformPluginSDKClient bool + + // useTerraformPluginFrameworkClient indicates that a Terraform + // Plugin Framework external client should be generated instead of + // the Terraform Plugin SDKv2 client. + useTerraformPluginFrameworkClient bool + + tfjsonSchema *tfjson.Schema } // ShouldUseTerraformPluginSDKClient returns whether to generate an SDKv2-based