Skip to content

Commit

Permalink
Rename some arguments in Terraform
Browse files Browse the repository at this point in the history
Introduce codegen overrides for terraform argument names, and update
CopyToPango() and CopyFromPang() code to properly handle name differences
between Terraform and Pango.
  • Loading branch information
kklimonda-cl committed Oct 9, 2024
1 parent be08ef1 commit 7537a99
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 83 deletions.
18 changes: 15 additions & 3 deletions pkg/properties/normalized.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,11 @@ type SpecParam struct {
}

type SpecParamTerraformProviderConfig struct {
Private bool `json:"ignored" yaml:"private"`
Sensitive bool `json:"sensitive" yaml:"sensitive"`
Computed bool `json:"computed" yaml:"computed"`
Name string `json:"name" yaml:"name"`
Type string `json:"type" yaml:"type"`
Private bool `json:"ignored" yaml:"private"`
Sensitive bool `json:"sensitive" yaml:"sensitive"`
Computed bool `json:"computed" yaml:"computed"`
}

type SpecParamLength struct {
Expand Down Expand Up @@ -210,6 +212,14 @@ type SpecParamProfile struct {
FromVersion string `json:"from_version" yaml:"from_version"`
}

func (o *SpecParam) NameVariant() *NameVariant {
if o.TerraformProviderConfig != nil && o.TerraformProviderConfig.Name != "" {
return NewNameVariant(o.TerraformProviderConfig.Name)
}

return o.Name
}

func hasChildEncryptedResources(param *SpecParam) bool {
if param.Hashing != nil {
return true
Expand Down Expand Up @@ -448,6 +458,8 @@ func schemaParameterToSpecParameter(schemaSpec *parameter.Parameter) (*SpecParam
if schemaSpec.CodegenOverrides != nil {
sensitive = schemaSpec.CodegenOverrides.Terraform.Sensitive
terraformProviderConfig = &SpecParamTerraformProviderConfig{
Name: schemaSpec.CodegenOverrides.Terraform.Name,
Type: schemaSpec.CodegenOverrides.Terraform.Type,
Private: schemaSpec.CodegenOverrides.Terraform.Private,
Sensitive: schemaSpec.CodegenOverrides.Terraform.Sensitive,
Computed: schemaSpec.CodegenOverrides.Terraform.Computed,
Expand Down
8 changes: 5 additions & 3 deletions pkg/schema/parameter/parameter.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,11 @@ type EnumSpecValue struct {
}

type CodegenOverridesTerraform struct {
Private bool `yaml:"private"`
Sensitive bool `yaml:"sensitive"`
Computed bool `yaml:"computed"`
Name string `yaml:"name"`
Type string `yaml:"type"`
Private bool `yaml:"private"`
Sensitive bool `yaml:"sensitive"`
Computed bool `yaml:"computed"`
}

type CodegenOverrides struct {
Expand Down
Loading

0 comments on commit 7537a99

Please sign in to comment.