Skip to content

Commit

Permalink
linting!
Browse files Browse the repository at this point in the history
  • Loading branch information
manicminer committed Oct 19, 2023
1 parent 20a10e4 commit 2c0407d
Show file tree
Hide file tree
Showing 75 changed files with 458 additions and 460 deletions.
4 changes: 2 additions & 2 deletions internal/helpers/applications.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func ApplicationFlattenAppRoleIDs(in *[]msgraph.AppRole) map[string]string {

func ApplicationFlattenAppRoles(in *[]msgraph.AppRole) (result []map[string]interface{}) {
if in == nil {
return
return //nolint:nakedret
}

for _, role := range *in {
Expand Down Expand Up @@ -177,7 +177,7 @@ func ApplicationFlattenOAuth2PermissionScopeIDs(in *[]msgraph.PermissionScope) m

func ApplicationFlattenOAuth2PermissionScopes(in *[]msgraph.PermissionScope) (result []map[string]interface{}) {
if in == nil {
return
return //nolint:nakedret
}

for _, p := range *in {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ import (
"net/http"
"time"

"github.com/hashicorp/go-azure-helpers/lang/pointer"
"github.com/hashicorp/go-azure-sdk/sdk/odata"
"github.com/hashicorp/terraform-provider-azuread/internal/clients"
"github.com/hashicorp/terraform-provider-azuread/internal/helpers"
"github.com/hashicorp/terraform-provider-azuread/internal/services/administrativeunits/parse"
"github.com/hashicorp/terraform-provider-azuread/internal/tf"
"github.com/hashicorp/terraform-provider-azuread/internal/tf/pluginsdk"
"github.com/hashicorp/terraform-provider-azuread/internal/tf/validation"
"github.com/hashicorp/terraform-provider-azuread/internal/utils"
"github.com/manicminer/hamilton/msgraph"
)

Expand Down Expand Up @@ -93,7 +93,7 @@ func administrativeUnitMemberResourceCreate(ctx context.Context, d *pluginsdk.Re
if memberObject == nil {
return tf.ErrorDiagF(errors.New("returned memberObject was nil"), "Could not retrieve member principal object %q", id.MemberId)
}
memberObject.ODataId = (*odata.Id)(utils.String(fmt.Sprintf("%s/v1.0/%s/directoryObjects/%s",
memberObject.ODataId = (*odata.Id)(pointer.To(fmt.Sprintf("%s/v1.0/%s/directoryObjects/%s",
client.BaseClient.Endpoint, tenantId, id.MemberId)))

members := &msgraph.Members{*memberObject}
Expand Down Expand Up @@ -178,11 +178,11 @@ func administrativeUnitMemberResourceDelete(ctx context.Context, d *pluginsdk.Re
client.BaseClient.DisableRetries = true
if _, status, err := client.GetMember(ctx, id.AdministrativeUnitId, id.MemberId); err != nil {
if status == http.StatusNotFound {
return utils.Bool(false), nil
return pointer.To(false), nil
}
return nil, err
}
return utils.Bool(true), nil
return pointer.To(true), nil
}); err != nil {
return tf.ErrorDiagF(err, "Waiting for removal of member %q from administrative unit with object ID %q", id.MemberId, id.AdministrativeUnitId)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import (
"net/http"
"testing"

"github.com/hashicorp/go-azure-helpers/lang/pointer"
"github.com/hashicorp/terraform-plugin-testing/terraform"
"github.com/hashicorp/terraform-provider-azuread/internal/acceptance"
"github.com/hashicorp/terraform-provider-azuread/internal/acceptance/check"
"github.com/hashicorp/terraform-provider-azuread/internal/clients"
"github.com/hashicorp/terraform-provider-azuread/internal/services/administrativeunits/parse"
"github.com/hashicorp/terraform-provider-azuread/internal/utils"
)

type AdministrativeUnitMemberResource struct{}
Expand Down Expand Up @@ -120,12 +120,12 @@ func (r AdministrativeUnitMemberResource) Exists(ctx context.Context, clients *c

if _, status, err := client.GetMember(ctx, id.AdministrativeUnitId, id.MemberId); err != nil {
if status == http.StatusNotFound {
return utils.Bool(false), nil
return pointer.To(false), nil
}
return nil, fmt.Errorf("failed to retrieve administrative unit member %q (administrative unit ID: %q): %+v", id.MemberId, id.AdministrativeUnitId, err)
}

return utils.Bool(true), nil
return pointer.To(true), nil
}

func (AdministrativeUnitMemberResource) templateThreeUsers(data acceptance.TestData) string {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"net/http"
"time"

"github.com/hashicorp/go-azure-helpers/lang/pointer"
"github.com/hashicorp/go-azure-sdk/sdk/odata"
"github.com/hashicorp/go-uuid"
"github.com/hashicorp/terraform-provider-azuread/internal/clients"
Expand Down Expand Up @@ -151,13 +152,13 @@ func administrativeUnitResourceCreate(ctx context.Context, d *pluginsdk.Resource
tempDisplayName := fmt.Sprintf("TERRAFORM_UPDATE_%s", uuid)

properties := msgraph.AdministrativeUnit{
Description: utils.NullableString(d.Get("description").(string)),
DisplayName: utils.String(tempDisplayName),
Visibility: utils.String(msgraph.AdministrativeUnitVisibilityPublic),
Description: tf.NullableString(d.Get("description").(string)),
DisplayName: pointer.To(tempDisplayName),
Visibility: pointer.To(msgraph.AdministrativeUnitVisibilityPublic),
}

if d.Get("hidden_membership_enabled").(bool) {
properties.Visibility = utils.String(msgraph.AdministrativeUnitVisibilityHiddenMembership)
properties.Visibility = pointer.To(msgraph.AdministrativeUnitVisibilityHiddenMembership)
}

administrativeUnit, _, err := client.Create(ctx, properties)
Expand All @@ -175,7 +176,7 @@ func administrativeUnitResourceCreate(ctx context.Context, d *pluginsdk.Resource
// The SDK handles retries for us here in the event of 404, 429 or 5xx, then returns after giving up
status, err := client.Update(ctx, msgraph.AdministrativeUnit{
ID: administrativeUnit.ID,
DisplayName: utils.String(displayName),
DisplayName: pointer.To(displayName),
})
if err != nil {
if status == http.StatusNotFound {
Expand All @@ -195,7 +196,7 @@ func administrativeUnitResourceCreate(ctx context.Context, d *pluginsdk.Resource
if memberObject == nil {
return tf.ErrorDiagF(errors.New("memberObject was nil"), "Could not retrieve member principal object %q", memberId)
}
memberObject.ODataId = (*odata.Id)(utils.String(fmt.Sprintf("%s/v1.0/%s/directoryObjects/%s",
memberObject.ODataId = (*odata.Id)(pointer.To(fmt.Sprintf("%s/v1.0/%s/directoryObjects/%s",
client.BaseClient.Endpoint, tenantId, memberId)))

members = append(members, *memberObject)
Expand Down Expand Up @@ -241,14 +242,14 @@ func administrativeUnitResourceUpdate(ctx context.Context, d *pluginsdk.Resource
}

administrativeUnit := msgraph.AdministrativeUnit{
ID: utils.String(administrativeUnitId),
Description: utils.NullableString(d.Get("description").(string)),
DisplayName: utils.String(displayName),
Visibility: utils.String(msgraph.AdministrativeUnitVisibilityPublic),
ID: pointer.To(administrativeUnitId),
Description: tf.NullableString(d.Get("description").(string)),
DisplayName: pointer.To(displayName),
Visibility: pointer.To(msgraph.AdministrativeUnitVisibilityPublic),
}

if d.Get("hidden_membership_enabled").(bool) {
administrativeUnit.Visibility = utils.String(msgraph.AdministrativeUnitVisibilityHiddenMembership)
administrativeUnit.Visibility = pointer.To(msgraph.AdministrativeUnitVisibilityHiddenMembership)
}

if _, err := client.Update(ctx, administrativeUnit); err != nil {
Expand Down Expand Up @@ -282,7 +283,7 @@ func administrativeUnitResourceUpdate(ctx context.Context, d *pluginsdk.Resource
if memberObject == nil {
return tf.ErrorDiagF(errors.New("returned memberObject was nil"), "Could not retrieve member principal object %q", memberId)
}
memberObject.ODataId = (*odata.Id)(utils.String(fmt.Sprintf("%s/v1.0/%s/directoryObjects/%s",
memberObject.ODataId = (*odata.Id)(pointer.To(fmt.Sprintf("%s/v1.0/%s/directoryObjects/%s",
client.BaseClient.Endpoint, tenantId, memberId)))

newMembers = append(newMembers, *memberObject)
Expand Down Expand Up @@ -354,11 +355,11 @@ func administrativeUnitResourceDelete(ctx context.Context, d *pluginsdk.Resource
client.BaseClient.DisableRetries = true
if _, status, err := client.Get(ctx, administrativeUnitId, odata.Query{}); err != nil {
if status == http.StatusNotFound {
return utils.Bool(false), nil
return pointer.To(false), nil
}
return nil, err
}
return utils.Bool(true), nil
return pointer.To(true), nil
}); err != nil {
return tf.ErrorDiagF(err, "Waiting for deletion of administrative unit with object ID %q", administrativeUnitId)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import (
"net/http"
"testing"

"github.com/hashicorp/go-azure-helpers/lang/pointer"
"github.com/hashicorp/go-azure-sdk/sdk/odata"
"github.com/hashicorp/terraform-plugin-testing/terraform"
"github.com/hashicorp/terraform-provider-azuread/internal/acceptance"
"github.com/hashicorp/terraform-provider-azuread/internal/acceptance/check"
"github.com/hashicorp/terraform-provider-azuread/internal/clients"
"github.com/hashicorp/terraform-provider-azuread/internal/utils"
)

type AdministrativeUnitResource struct{}
Expand Down Expand Up @@ -103,7 +103,7 @@ func (r AdministrativeUnitResource) Exists(ctx context.Context, clients *clients
}
return nil, fmt.Errorf("failed to retrieve Administratove Unit with object ID %q: %+v", state.ID, err)
}
return utils.Bool(role.ID != nil && *role.ID == state.ID), nil
return pointer.To(role.ID != nil && *role.ID == state.ID), nil
}

func (AdministrativeUnitResource) basic(data acceptance.TestData) string {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ import (
"net/http"
"time"

"github.com/hashicorp/go-azure-helpers/lang/pointer"
"github.com/hashicorp/go-azure-sdk/sdk/odata"
"github.com/hashicorp/terraform-provider-azuread/internal/clients"
"github.com/hashicorp/terraform-provider-azuread/internal/services/administrativeunits/parse"
"github.com/hashicorp/terraform-provider-azuread/internal/tf"
"github.com/hashicorp/terraform-provider-azuread/internal/tf/pluginsdk"
"github.com/hashicorp/terraform-provider-azuread/internal/tf/validation"
"github.com/hashicorp/terraform-provider-azuread/internal/utils"
"github.com/manicminer/hamilton/msgraph"
)

Expand Down Expand Up @@ -68,12 +68,12 @@ func administrativeUnitRoleMemberResource() *pluginsdk.Resource {
func administrativeUnitRoleMemberResourceCreate(ctx context.Context, d *pluginsdk.ResourceData, meta interface{}) pluginsdk.Diagnostics {
client := meta.(*clients.Client).AdministrativeUnits.AdministrativeUnitsClient

memberID := utils.String(d.Get("member_object_id").(string))
adminUnitID := utils.String(d.Get("administrative_unit_object_id").(string))
memberID := pointer.To(d.Get("member_object_id").(string))
adminUnitID := pointer.To(d.Get("administrative_unit_object_id").(string))

properties := msgraph.ScopedRoleMembership{
AdministrativeUnitId: adminUnitID,
RoleId: utils.String(d.Get("role_object_id").(string)),
RoleId: pointer.To(d.Get("role_object_id").(string)),
RoleMemberInfo: &msgraph.Identity{
Id: memberID,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ import (
"net/http"
"testing"

"github.com/hashicorp/go-azure-helpers/lang/pointer"
"github.com/hashicorp/go-azure-sdk/sdk/odata"
"github.com/hashicorp/terraform-plugin-testing/terraform"
"github.com/hashicorp/terraform-provider-azuread/internal/acceptance"
"github.com/hashicorp/terraform-provider-azuread/internal/acceptance/check"
"github.com/hashicorp/terraform-provider-azuread/internal/clients"
"github.com/hashicorp/terraform-provider-azuread/internal/services/administrativeunits/parse"
"github.com/hashicorp/terraform-provider-azuread/internal/utils"
)

type AdministrativeUnitRoleMemberResource struct{}
Expand Down Expand Up @@ -109,12 +109,12 @@ func (r AdministrativeUnitRoleMemberResource) Exists(ctx context.Context, client

if _, status, err := client.GetScopedRoleMember(ctx, id.AdministrativeUnitId, id.ScopedRoleMembershipId, odata.Query{}); err != nil {
if status == http.StatusNotFound {
return utils.Bool(false), nil
return pointer.To(false), nil
}
return nil, fmt.Errorf("failed to retrieve administrative unit role membership %q (AU ID: %q): %+v", id.ScopedRoleMembershipId, id.AdministrativeUnitId, err)
}

return utils.Bool(true), nil
return pointer.To(true), nil
}

func (AdministrativeUnitRoleMemberResource) templateThreeUsers(data acceptance.TestData) string {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"github.com/hashicorp/terraform-provider-azuread/internal/tf"
"github.com/hashicorp/terraform-provider-azuread/internal/tf/pluginsdk"
"github.com/hashicorp/terraform-provider-azuread/internal/tf/validation"
"github.com/hashicorp/terraform-provider-azuread/internal/utils"
"github.com/manicminer/hamilton/msgraph"
)

Expand Down Expand Up @@ -151,7 +150,7 @@ func applicationFederatedIdentityCredentialResourceCreate(ctx context.Context, d

credential := msgraph.FederatedIdentityCredential{
Audiences: tf.ExpandStringSlicePtr(d.Get("audiences").([]interface{})),
Description: utils.NullableString(d.Get("description").(string)),
Description: tf.NullableString(d.Get("description").(string)),
Issuer: pointer.To(d.Get("issuer").(string)),
Name: pointer.To(d.Get("display_name").(string)),
Subject: pointer.To(d.Get("subject").(string)),
Expand Down Expand Up @@ -221,7 +220,7 @@ func applicationFederatedIdentityCredentialResourceUpdate(ctx context.Context, d
credential := msgraph.FederatedIdentityCredential{
ID: pointer.To(id.KeyId),
Audiences: tf.ExpandStringSlicePtr(d.Get("audiences").([]interface{})),
Description: utils.NullableString(d.Get("description").(string)),
Description: tf.NullableString(d.Get("description").(string)),
Issuer: pointer.To(d.Get("issuer").(string)),
Subject: pointer.To(d.Get("subject").(string)),
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
"github.com/hashicorp/terraform-provider-azuread/internal/tf"
"github.com/hashicorp/terraform-provider-azuread/internal/tf/pluginsdk"
"github.com/hashicorp/terraform-provider-azuread/internal/tf/validation"
"github.com/hashicorp/terraform-provider-azuread/internal/utils"
"github.com/manicminer/hamilton/msgraph"
)

Expand Down Expand Up @@ -137,7 +136,7 @@ func (r ApplicationFromTemplateResource) Create() sdk.ResourceFunc {
result, status, err := client.Get(ctx, *result.Application.ID(), odata.Query{})
if err != nil {
if status == http.StatusNotFound {
return utils.Bool(false), nil
return pointer.To(false), nil
}
return nil, err
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"context"
"encoding/base64"
"fmt"
"github.com/manicminer/hamilton/msgraph"
"net/http"
"time"

Expand All @@ -17,6 +16,7 @@ import (
"github.com/hashicorp/terraform-provider-azuread/internal/tf"
"github.com/hashicorp/terraform-provider-azuread/internal/tf/pluginsdk"
"github.com/hashicorp/terraform-provider-azuread/internal/tf/validation"
"github.com/manicminer/hamilton/msgraph"
)

type ApplicationIdentifierUriModel struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
"github.com/hashicorp/terraform-provider-azuread/internal/tf"
"github.com/hashicorp/terraform-provider-azuread/internal/tf/pluginsdk"
"github.com/hashicorp/terraform-provider-azuread/internal/tf/validation"
"github.com/hashicorp/terraform-provider-azuread/internal/utils"
"github.com/manicminer/hamilton/msgraph"
)

Expand Down Expand Up @@ -467,11 +466,11 @@ func (r ApplicationRegistrationResource) Delete() sdk.ResourceFunc {
client.BaseClient.DisableRetries = true
if _, status, err := client.Get(ctx, id.ApplicationId, odata.Query{}); err != nil {
if status == http.StatusNotFound {
return utils.Bool(false), nil
return pointer.To(false), nil
}
return nil, err
}
return utils.Bool(true), nil
return pointer.To(true), nil
}); err != nil {
return fmt.Errorf("waiting for deletion of %s: %q", id, err)
}
Expand Down
Loading

0 comments on commit 2c0407d

Please sign in to comment.