Skip to content

Commit

Permalink
Generate embedded fields with single nesting mode as embedded objects
Browse files Browse the repository at this point in the history
Signed-off-by: Alper Rifat Ulucinar <[email protected]>
  • Loading branch information
ulucinar committed Feb 12, 2024
1 parent c589cdb commit 7c67d84
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
1 change: 1 addition & 0 deletions pkg/config/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
24 changes: 15 additions & 9 deletions pkg/config/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 7c67d84

Please sign in to comment.