Skip to content

Commit

Permalink
enhance datasource user group
Browse files Browse the repository at this point in the history
  • Loading branch information
cheelim1 committed May 25, 2023
1 parent 8174944 commit 345526d
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions jumpcloud/data_source_user_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,12 @@ func dataSourceJumpCloudUserGroupRead(d *schema.ResourceData, m interface{}) err
return err
}

if len(userGroups) == 0 {
return fmt.Errorf("No user group found with name: %s", groupName)
} else if len(userGroups) > 1 {
return fmt.Errorf("Multiple user groups found with name: %s", groupName)
for _, userGroup := range userGroups {
if userGroup.Name == groupName {
d.SetId(userGroup.Id)
return nil
}
}

d.SetId(userGroups[0].Id)

return nil
return fmt.Errorf("No user group found with name: %s", groupName)
}

0 comments on commit 345526d

Please sign in to comment.