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

bugfix: ignore_body_changes incorrectly removes tags #390

Merged
merged 1 commit into from
Jan 2, 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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## v1.12.0 (Unreleased)
BUG FIXES:
- Fix a bug that `ignore_body_changes` incorrectly removes tags.

## v1.11.0
ENHANCEMENTS:
- `azapi_resource_action` resource: Support `HEAD` method.
Expand Down
4 changes: 2 additions & 2 deletions internal/services/azapi_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ func resourceAzApiResourceCreateUpdate(d *schema.ResourceData, meta interface{})
}

if id.ResourceDef != nil {
merged = (*id.ResourceDef).GetWriteOnly(merged.(map[string]interface{}))
merged = (*id.ResourceDef).GetWriteOnly(utils.NormalizeObject(merged))
}

body = merged.(map[string]interface{})
Expand Down Expand Up @@ -458,7 +458,7 @@ func resourceAzApiResourceRead(d *schema.ResourceData, meta interface{}) error {
// if it's imported
if len(d.Get("name").(string)) == 0 {
if id.ResourceDef != nil {
writeOnlyBody := (*id.ResourceDef).GetWriteOnly(responseBody)
writeOnlyBody := (*id.ResourceDef).GetWriteOnly(utils.NormalizeObject(responseBody))
if bodyMap, ok := writeOnlyBody.(map[string]interface{}); ok {
delete(bodyMap, "location")
delete(bodyMap, "tags")
Expand Down
2 changes: 1 addition & 1 deletion internal/services/azapi_update_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ func resourceAzApiUpdateResourceCreateUpdate(d *schema.ResourceData, meta interf
}

if id.ResourceDef != nil {
requestBody = (*id.ResourceDef).GetWriteOnly(requestBody)
requestBody = (*id.ResourceDef).GetWriteOnly(utils.NormalizeObject(requestBody))
}
j, _ := json.Marshal(requestBody)
log.Printf("[INFO] request body: %v\n", string(j))
Expand Down
Loading