Skip to content

Commit

Permalink
Merge pull request #553 from hashicorp/bugfix/group-owner-duplication
Browse files Browse the repository at this point in the history
Bugfix: only specify the calling principal ID once when creating a group
  • Loading branch information
manicminer authored Sep 6, 2021
2 parents 1589287 + f996396 commit c412460
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions internal/services/groups/group_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"log"
"net/http"
"strings"
"time"

"github.com/hashicorp/go-uuid"
Expand Down Expand Up @@ -439,7 +440,7 @@ func groupResourceCreate(ctx context.Context, d *schema.ResourceData, meta inter
if err != nil {
return tf.ErrorDiagF(err, "Could not retrieve owner principal object %q", id)
}
if *ownerObject.ID == callerId {
if strings.EqualFold(*ownerObject.ID, callerId) {
if ownerObject.ODataId == nil {
return tf.ErrorDiagF(errors.New("ODataId was nil"), "Could not retrieve owner principal object %q", id)
}
Expand All @@ -459,7 +460,7 @@ func groupResourceCreate(ctx context.Context, d *schema.ResourceData, meta inter
if err != nil {
return tf.ErrorDiagF(err, "Could not retrieve owner principal object %q", id)
}
if *ownerObject.ODataType == t {
if *ownerObject.ODataType == t && !strings.EqualFold(*ownerObject.ID, callerId) {
if ownerCount < 20 {
ownersFirst20 = append(ownersFirst20, *ownerObject)
} else {
Expand Down

0 comments on commit c412460

Please sign in to comment.