Skip to content

Commit f14bae6

Browse files
committed
reduce complexity of nested if block
1 parent af43a4a commit f14bae6

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

internal/provider/resource_tfe_workspace_settings.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -515,13 +515,16 @@ func (r *workspaceSettings) updateSettings(ctx context.Context, data *modelWorks
515515

516516
if !data.Tags.IsNull() && !data.Tags.IsUnknown() {
517517
tags := data.Tags.Elements()
518-
if len(tags) == 0 {
518+
519+
switch {
520+
case len(tags) == 0:
519521
if err := r.config.Client.Workspaces.DeleteAllTagBindings(ctx, workspaceID); err != nil {
520522
return fmt.Errorf("error removing tag bindings from workspace %s: %w", workspaceID, err)
521523
}
522-
} else {
524+
default:
523525
for key, val := range tags {
524-
if strVal, ok := val.(types.String); ok && !strVal.IsNull() && !strVal.IsUnknown() {
526+
strVal, ok := val.(types.String)
527+
if ok && !strVal.IsNull() && !strVal.IsUnknown() {
525528
updateOptions.TagBindings = append(updateOptions.TagBindings, &tfe.TagBinding{
526529
Key: key,
527530
Value: strVal.ValueString(),

0 commit comments

Comments
 (0)