diff --git a/go.mod b/go.mod index 33fe908f1..ce7f0461a 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,9 @@ require ( github.com/mitchellh/go-homedir v1.1.0 github.com/newrelic/go-agent/v3 v3.27.0 github.com/newrelic/go-insights v1.0.3 - github.com/newrelic/newrelic-client-go/v2 v2.23.0 + // TEMPORARILY POINTING TO THE LATEST COMMIT OF https://github.com/newrelic/newrelic-client-go/pull/981/commits + // TO BE DISCARDED BEFORE MERGE + github.com/newrelic/newrelic-client-go/v2 v2.23.1-0.20240106031842-ca20407fc56f github.com/stretchr/testify v1.8.4 golang.org/x/exp v0.0.0-20231006140011-7918f672742d ) diff --git a/go.sum b/go.sum index d17570eb0..dcfc177bb 100644 --- a/go.sum +++ b/go.sum @@ -267,8 +267,10 @@ github.com/newrelic/go-agent/v3 v3.27.0 h1:Z3XB49d8FKjRcGzCyViCO9itBxiLPSpwjY1Hl github.com/newrelic/go-agent/v3 v3.27.0/go.mod h1:TUzePinDc0BMH4Sui66rl4SBe6yOKJ5X/bRJekwuAtM= github.com/newrelic/go-insights v1.0.3 h1:zSNp1CEZnXktzSIEsbHJk8v6ZihdPFP2WsO/fzau3OQ= github.com/newrelic/go-insights v1.0.3/go.mod h1:A20BoT8TNkqPGX2nS/Z2fYmKl3Cqa3iKZd4whzedCY4= -github.com/newrelic/newrelic-client-go/v2 v2.23.0 h1:ULqiPv4Z0QVLjMjX6uP13wSxPDL3uiKTt5U8vFsvpCQ= -github.com/newrelic/newrelic-client-go/v2 v2.23.0/go.mod h1:VPWTvEfKvnTZLunAC7fiW33y4e0srznNfN5HJH2cOp8= +github.com/newrelic/newrelic-client-go/v2 v2.23.1-0.20240105192613-7907c0bd50e3 h1:YkAH35QuPwQsaI83F5sYNnW68bWY1k16u3Ouq1/1JeU= +github.com/newrelic/newrelic-client-go/v2 v2.23.1-0.20240105192613-7907c0bd50e3/go.mod h1:VPWTvEfKvnTZLunAC7fiW33y4e0srznNfN5HJH2cOp8= +github.com/newrelic/newrelic-client-go/v2 v2.23.1-0.20240106031842-ca20407fc56f h1:EQ0ZEbx+6v8/yjeubhj8qe1F7pjMe+q9ey5B07TUjw0= +github.com/newrelic/newrelic-client-go/v2 v2.23.1-0.20240106031842-ca20407fc56f/go.mod h1:VPWTvEfKvnTZLunAC7fiW33y4e0srznNfN5HJH2cOp8= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/oklog/run v1.0.0 h1:Ru7dDtJNOyC66gQ5dQmaCa0qIsAUFY3sFpK1Xk8igrw= github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= diff --git a/newrelic/resource_newrelic_user_group.go b/newrelic/resource_newrelic_user_group.go index 08321cec2..3805f0546 100644 --- a/newrelic/resource_newrelic_user_group.go +++ b/newrelic/resource_newrelic_user_group.go @@ -52,7 +52,6 @@ func resourceNewRelicUserGroupCreate(ctx context.Context, d *schema.ResourceData DisplayName: d.Get("name").(string), } created, err := client.UserManagement.UserManagementCreateGroupWithContext(ctx, createInput) - if err != nil { return diag.FromErr(err) } @@ -68,13 +67,14 @@ func resourceNewRelicUserGroupCreate(ctx context.Context, d *schema.ResourceData return resourceNewRelicUserGroupRead(ctx, d, meta) } +// Read a created group func resourceNewRelicUserGroupRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { providerConfig := meta.(*ProviderConfig) client := providerConfig.NewClient - groupId := d.Id() - authenticationDomainId := d.Get("authentication_domain_id").(string) - group, err := getUserGroupID(ctx, client, authenticationDomainId, groupId) + groupID := d.Id() + authenticationDomainID := d.Get("authentication_domain_id").(string) + group, err := getUserGroupID(ctx, client, authenticationDomainID, groupID) if err != nil && group == nil { d.SetId("") @@ -92,8 +92,9 @@ func resourceNewRelicUserGroupRead(ctx context.Context, d *schema.ResourceData, return nil } -func getUserGroupID(ctx context.Context, client *newrelic.NewRelic, authId string, groupId string) (groups *usermanagement.UserManagementGroup, err error) { - id := []string{authId} +// Iterate through groups associated with the authentication domain +func getUserGroupID(ctx context.Context, client *newrelic.NewRelic, authID string, groupID string) (groups *usermanagement.UserManagementGroup, err error) { + id := []string{authID} resp, err := client.UserManagement.GetAuthenticationDomainsWithContext(ctx, id) if err != nil { return nil, err @@ -101,16 +102,16 @@ func getUserGroupID(ctx context.Context, client *newrelic.NewRelic, authId strin for i, groupList := range *resp { if i == 0 { for _, group := range groupList.Groups.Groups { - if group.ID == groupId { + if group.ID == groupID { return &group, nil } } } } - return nil, errors.New("err: group is not found") + return nil, errors.New("error: group is not found") } -// Update the obfuscation expression +// Update a created group func resourceNewRelicUserGroupUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { client := meta.(*ProviderConfig).NewClient updateInput := usermanagement.UserManagementUpdateGroup{} @@ -129,10 +130,10 @@ func resourceNewRelicUserGroupUpdate(ctx context.Context, d *schema.ResourceData return diag.FromErr(err) } - return resourceNewRelicObfuscationExpressionRead(ctx, d, meta) + return resourceNewRelicUserGroupRead(ctx, d, meta) } -// Delete the UserGroup +// Delete a created group func resourceNewRelicUserGroupDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { providerConfig := meta.(*ProviderConfig) client := providerConfig.NewClient diff --git a/newrelic/structures_newrelic_workflow.go b/newrelic/structures_newrelic_workflow.go index 77a438c6e..dd4fecd7d 100644 --- a/newrelic/structures_newrelic_workflow.go +++ b/newrelic/structures_newrelic_workflow.go @@ -3,6 +3,7 @@ package newrelic import ( "context" "fmt" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/newrelic/newrelic-client-go/v2/pkg/ai" "github.com/newrelic/newrelic-client-go/v2/pkg/workflows"