Skip to content

Commit

Permalink
Add a list/map description for list resources. (#180)
Browse files Browse the repository at this point in the history
When creating list resources (e.g. panos_addresses, panos_security_policy), PANOS
objects are nested within a list/map attribute, but this attribute has no description.
This PR allows us to add descriptions to those attributes.
  • Loading branch information
kklimonda-cl authored Oct 24, 2024
1 parent 1f4e1d5 commit 8f8cfa7
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
2 changes: 2 additions & 0 deletions pkg/properties/normalized.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ type TerraformProviderConfig struct {
Suffix string `json:"suffix" yaml:"suffix"`
PluralSuffix string `json:"plural_suffix" yaml:"plural_suffix"`
PluralName string `json:"plural_name" yaml:"plural_name"`
PluralDescription string `json:"plural_description" yaml:"plural_description"`
}

type NameVariant struct {
Expand Down Expand Up @@ -555,6 +556,7 @@ func schemaToSpec(object object.Object) (*Normalization, error) {
Suffix: object.TerraformConfig.Suffix,
PluralSuffix: object.TerraformConfig.PluralSuffix,
PluralName: object.TerraformConfig.PluralName,
PluralDescription: object.TerraformConfig.PluralDescription,
},
Locations: make(map[string]*Location),
GoSdkSkip: object.GoSdkConfig.Skip,
Expand Down
1 change: 1 addition & 0 deletions pkg/schema/object/object.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ type TerraformConfig struct {
Suffix string `yaml:"suffix"`
PluralSuffix string `yaml:"plural_suffix"`
PluralName string `yaml:"plural_name"`
PluralDescription string `yaml:"plural_description"`
}

type GoSdkConfig struct {
Expand Down
18 changes: 10 additions & 8 deletions pkg/translate/terraform_provider/funcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -1181,10 +1181,11 @@ func createSchemaSpecForUuidModel(resourceTyp properties.ResourceType, schemaTyp
}

attributes = append(attributes, attributeCtx{
Package: packageName,
Name: listName,
Required: true,
SchemaType: "ListNestedAttribute",
Package: packageName,
Name: listName,
Required: true,
Description: spec.TerraformProviderConfig.PluralDescription,
SchemaType: "ListNestedAttribute",
})

var isResource bool
Expand Down Expand Up @@ -1302,10 +1303,11 @@ func createSchemaSpecForEntryListModel(resourceTyp properties.ResourceType, sche
}

attributes = append(attributes, attributeCtx{
Package: packageName,
Name: listName,
Required: true,
SchemaType: "MapNestedAttribute",
Package: packageName,
Name: listName,
Description: spec.TerraformProviderConfig.PluralDescription,
Required: true,
SchemaType: "MapNestedAttribute",
})

var isResource bool
Expand Down
3 changes: 2 additions & 1 deletion specs/schema/object.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@
"type": "string"
},
"plural_suffix": { "type": "string" },
"plural_name": { "type": "string" }
"plural_name": { "type": "string" },
"plural_description": { "type": "string" }
}
},
"go_sdk_config": {
Expand Down

0 comments on commit 8f8cfa7

Please sign in to comment.