Skip to content

Commit

Permalink
Merge pull request #150 from nathanbartlett/check_group_data_source_m…
Browse files Browse the repository at this point in the history
…atch

Check for exact group name match on group data source.
  • Loading branch information
bogdanprodan-okta authored Dec 17, 2020
2 parents 20e6c0d + 2f79b47 commit dec6f51
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions okta/data_source_okta_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ func findGroup(ctx context.Context, name string, d *schema.ResourceData, m inter
return diag.Errorf("group with name '%s' and type '%s' does not exist", name, d.Get("type").(string))
}
return diag.Errorf("group with name '%s' does not exist", name)
} else if len(groups) > 1 {
logger(m).Warn("Found multiple groups with the supplied parameters: using the first one which may only be a partial match", "name", groups[0].Profile.Name)
} else if len(groups[0].Profile.Name) != len(name) {
logger(m).Warn("The group with an exact match to the supplied name was not found: using partial match which contains name as a substring", "name", groups[0].Profile.Name)
}
d.SetId(groups[0].Id)
_ = d.Set("description", groups[0].Profile.Description)
Expand Down

0 comments on commit dec6f51

Please sign in to comment.