From b7c66130b770c8ae4e3006c96a8a549ea509676c Mon Sep 17 00:00:00 2001 From: corymhall <43035978+corymhall@users.noreply.github.com> Date: Wed, 11 Dec 2024 10:12:20 -0500 Subject: [PATCH] update based on review --- provider/pkg/metadata/metadata.go | 35 +++++++++++++++------- provider/pkg/schema/resource_props.go | 4 +-- provider/pkg/schema/resource_props_test.go | 4 +++ 3 files changed, 30 insertions(+), 13 deletions(-) diff --git a/provider/pkg/metadata/metadata.go b/provider/pkg/metadata/metadata.go index 7aa59b2e91..5bba56a18a 100644 --- a/provider/pkg/metadata/metadata.go +++ b/provider/pkg/metadata/metadata.go @@ -16,17 +16,30 @@ type CloudAPIMetadata struct { // CloudAPIResource contains metadata for a single AWS Resource. type CloudAPIResource struct { - CfType string `json:"cf"` - Inputs map[string]pschema.PropertySpec `json:"inputs"` - Outputs map[string]pschema.PropertySpec `json:"outputs"` - AutoNamingSpec *AutoNamingSpec `json:"autoNamingSpec,omitempty"` - Required []string `json:"required,omitempty"` - CreateOnly []string `json:"createOnly,omitempty"` - ReadOnly []string `json:"readOnly,omitempty"` - WriteOnly []string `json:"writeOnly,omitempty"` - IrreversibleNames map[string]string `json:"irreversibleNames,omitempty"` - TagsProperty string `json:"tagsProperty,omitempty"` - TagsStyle default_tags.TagsStyle `json:"tagsStyle,omitempty"` + CfType string `json:"cf"` + Inputs map[string]pschema.PropertySpec `json:"inputs"` + Outputs map[string]pschema.PropertySpec `json:"outputs"` + AutoNamingSpec *AutoNamingSpec `json:"autoNamingSpec,omitempty"` + Required []string `json:"required,omitempty"` + CreateOnly []string `json:"createOnly,omitempty"` + // ReadOnly properties are properties that only exist as output values + // The properties can be top level properties or can be nested within object or array + // properties. + // '/' is used to denote a nested object property + // '/*/' is used to denote a nested array property + // e.g. + // - ReadOnly: [ + // 'arn', // top level + // 'someObjectProp/arn', // the arn value of someObjectProp is an output (but not the other properties of someObjectProp) + // 'someArrayProp/*/someObjectProp/arn' + // ] + // + // NOTE: The values in this property will have been converted from CFN casing to pulumi sdk casing + ReadOnly []string `json:"readOnly,omitempty"` + WriteOnly []string `json:"writeOnly,omitempty"` + IrreversibleNames map[string]string `json:"irreversibleNames,omitempty"` + TagsProperty string `json:"tagsProperty,omitempty"` + TagsStyle default_tags.TagsStyle `json:"tagsStyle,omitempty"` // Describes the behavior of the CF Ref intrinsic for this resource. CfRef *CfRefBehavior `json:"cfRef,omitempty"` diff --git a/provider/pkg/schema/resource_props.go b/provider/pkg/schema/resource_props.go index ab0fb1da54..20caadd08f 100644 --- a/provider/pkg/schema/resource_props.go +++ b/provider/pkg/schema/resource_props.go @@ -18,8 +18,8 @@ type ResourceProperty string // e.g. // - `Foo/Bar/Baz` => `foo/bar/baz` // - `Foo/*/BarBaz` => `foo/*/barBaz` -func (r *ResourceProperty) ToSdkName() string { - arrayProps := strings.Split(string(*r), "/*/") +func (r ResourceProperty) ToSdkName() string { + arrayProps := strings.Split(string(r), "/*/") for i, p := range arrayProps { nested := strings.Split(p, "/") for idx, n := range nested { diff --git a/provider/pkg/schema/resource_props_test.go b/provider/pkg/schema/resource_props_test.go index f0aa518a4e..9f8598a5a3 100644 --- a/provider/pkg/schema/resource_props_test.go +++ b/provider/pkg/schema/resource_props_test.go @@ -23,6 +23,10 @@ func TestToSdkName(t *testing.T) { input: "Foo/*/Bar/Baz", expected: "foo/*/bar/baz", }, + "multiNestedArrayObject": { + input: "Foo/*/Bar/*/Baz/Hello", + expected: "foo/*/bar/*/baz/hello", + }, } for name, tc := range cases {