Skip to content
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
6 changes: 1 addition & 5 deletions pkg/pf/internal/pfutils/attr.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,13 @@ type AttrLike interface {
IsOptional() bool
IsRequired() bool
IsSensitive() bool
IsWriteOnly() bool
GetDeprecationMessage() string
GetDescription() string
GetMarkdownDescription() string
GetType() attr.Type
}

type AttrLikeWithWriteOnly interface {
AttrLike
IsWriteOnly() bool
}

func FromProviderAttribute(x pschema.Attribute) Attr {
return FromAttrLike(x)
}
Expand Down
6 changes: 1 addition & 5 deletions pkg/pf/internal/schemashim/attr_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,7 @@ func (s *attrSchema) Sensitive() bool {
}

func (s *attrSchema) WriteOnly() bool {
schema, ok := s.attr.(pfutils.AttrLikeWithWriteOnly)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the source of the bug - the type assert here is wrong as attr never implemented that interface.

if ok {
return schema.IsWriteOnly()
}
return false
return s.attr.IsWriteOnly()
}

func (*attrSchema) SetElement(config interface{}) (interface{}, error) {
Expand Down
1 change: 1 addition & 0 deletions pkg/pf/internal/schemashim/object_pseudoresource.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ func (tupElementAttr) IsOptional() bool { return false }
func (tupElementAttr) IsRequired() bool { return true }
func (tupElementAttr) IsSensitive() bool { return false }
func (tupElementAttr) IsComputed() bool { return false }
func (tupElementAttr) IsWriteOnly() bool { return false }

func (t tupElementAttr) GetType() attr.Type { return t.e }

Expand Down
15 changes: 0 additions & 15 deletions pkg/pf/tfgen/testdata/TestWriteOnlyOmit.golden
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,8 @@
},
"resources": {
"testprovider:index:Res": {
"properties": {
"a1": {
"type": "string"
}
},
"inputProperties": {
"a1": {
"type": "string"
}
},
"stateInputs": {
"description": "Input properties used for looking up and filtering Res resources.\n",
"properties": {
"a1": {
"type": "string"
}
},
"type": "object"
}
}
Expand Down
Loading