Skip to content

Commit

Permalink
fix: use switch instead of if else
Browse files Browse the repository at this point in the history
  • Loading branch information
rmocanu-ionos committed Jan 30, 2025
1 parent e4f7c5a commit 93e1125
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
7 changes: 4 additions & 3 deletions ionoscloud/data_source_dbaas_mongo_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,11 +289,12 @@ func dataSourceDbaasMongoReadCluster(ctx context.Context, d *schema.ResourceData
}
}

if len(results) == 0 {
switch {
case len(results) == 0:
return diag.FromErr(fmt.Errorf("no DBaaS mongo cluster found with the specified name = %s", name))
} else if len(results) > 1 {
case len(results) > 1:
return diag.FromErr(fmt.Errorf("more than one DBaaS mongo cluster found with the specified criteria name = %s", name))
} else {
default:
cluster = results[0]
}

Expand Down
7 changes: 4 additions & 3 deletions ionoscloud/data_source_dbaas_mongo_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,12 @@ func dataSourceDbaasMongoReadUser(ctx context.Context, d *schema.ResourceData, m
}
}

if len(results) == 0 {
switch {
case len(results) == 0:
return diag.FromErr(fmt.Errorf("no DBaaS mongo user found with the specified username = %s and cluster_id = %s", username, clusterId))
} else if len(results) > 1 {
case len(results) > 1:
return diag.FromErr(fmt.Errorf("more than one DBaaS mongo user found with the specified criteria username = %s and cluster_id = %s", username, clusterId))
} else {
default:
user = results[0]
}

Expand Down

0 comments on commit 93e1125

Please sign in to comment.