Skip to content

Commit

Permalink
Skip template detachment when already detached
Browse files Browse the repository at this point in the history
  • Loading branch information
danischm committed Nov 23, 2023
1 parent a763bb7 commit f9fb96f
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- Add `base_action` attribute to `sdwan_traffic_data_policy_definition` resource and data source
- Allow full path variables in `sdwan_attach_feature_device_template` resource `variables` section
- Always include empty lists in payloads to fix various GUI compatibility issues
- Skip `sdwan_attach_feature_device_template` template detachment when device template is no longer attached

## 0.2.10

Expand Down
1 change: 1 addition & 0 deletions docs/guides/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ description: |-
- Add `base_action` attribute to `sdwan_traffic_data_policy_definition` resource and data source
- Allow full path variables in `sdwan_attach_feature_device_template` resource `variables` section
- Always include empty lists in payloads to fix various GUI compatibility issues
- Skip `sdwan_attach_feature_device_template` template detachment when device template is no longer attached

## 0.2.10

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,11 +215,12 @@ func (r *AttachFeatureDeviceTemplateResource) Delete(ctx context.Context, req re
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve currently attached devices, got error: %s", err))
return
}
actionId := res.Get("id").String()
err = helpers.WaitForActionToComplete(ctx, r.client, actionId)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to detach device template, got error: %s", err))
return
if res.Get("id").Exists() {
err = helpers.WaitForActionToComplete(ctx, r.client, res.Get("id").String())
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to detach device template, got error: %s", err))
return
}
}

tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Id.ValueString()))
Expand Down
1 change: 1 addition & 0 deletions templates/guides/changelog.md.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ description: |-
- Add `base_action` attribute to `sdwan_traffic_data_policy_definition` resource and data source
- Allow full path variables in `sdwan_attach_feature_device_template` resource `variables` section
- Always include empty lists in payloads to fix various GUI compatibility issues
- Skip `sdwan_attach_feature_device_template` template detachment when device template is no longer attached

## 0.2.10

Expand Down

0 comments on commit f9fb96f

Please sign in to comment.