Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add a list/map description for list resources. #180

Merged
merged 1 commit into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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