Skip to content

Commit

Permalink
update based on review
Browse files Browse the repository at this point in the history
  • Loading branch information
corymhall committed Dec 11, 2024
1 parent 736e570 commit b7c6613
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 13 deletions.
35 changes: 24 additions & 11 deletions provider/pkg/metadata/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
4 changes: 2 additions & 2 deletions provider/pkg/schema/resource_props.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 4 additions & 0 deletions provider/pkg/schema/resource_props_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit b7c6613

Please sign in to comment.