Skip to content

hclwrite: body.SetAttribute* return new attribute#806

Open
bbasata wants to merge 2 commits into
mainfrom
bbasata/set
Open

hclwrite: body.SetAttribute* return new attribute#806
bbasata wants to merge 2 commits into
mainfrom
bbasata/set

Conversation

@bbasata

@bbasata bbasata commented Jun 15, 2026

Copy link
Copy Markdown
Collaborator

Description

This change updates hclwrite.Body.SetAttribute* to return the new attribute rather than return nil.

This matches the intent in the documentation comments that indicate:

The return value is the attribute that was either modified in-place or created.

An available workaround:

body.SetAttributeRaw(name, tokens)
attr := body.GetAttribute(name)

Open question: I'm considering whether to check the return value of Body.SetAttribute* in hclwrite/ast_body_test.go.

bbasata added 2 commits June 15, 2026 17:58
This change updates Body.SetAttribute* to return the new attribute
rather than return nil.

This matches the intent in the documentation comments that indicate:

The return value is the attribute that was either modified in-place or
created.
@bbasata bbasata marked this pull request as ready for review June 15, 2026 22:04
@bbasata bbasata requested a review from a team as a code owner June 15, 2026 22:04
@bbasata

bbasata commented Jun 15, 2026

Copy link
Copy Markdown
Collaborator Author

TIL: #613

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant