diff --git a/internal/helpers/applications.go b/internal/helpers/applications.go index 8f46e30ef2..96a5465f1b 100644 --- a/internal/helpers/applications.go +++ b/internal/helpers/applications.go @@ -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 { @@ -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 { diff --git a/internal/services/administrativeunits/administrative_unit_member_resource.go b/internal/services/administrativeunits/administrative_unit_member_resource.go index 5b426f6fb7..a87feec1be 100644 --- a/internal/services/administrativeunits/administrative_unit_member_resource.go +++ b/internal/services/administrativeunits/administrative_unit_member_resource.go @@ -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/terraform-provider-azuread/internal/clients" "github.com/hashicorp/terraform-provider-azuread/internal/helpers" @@ -18,7 +19,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" ) @@ -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} @@ -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) } diff --git a/internal/services/administrativeunits/administrative_unit_member_resource_test.go b/internal/services/administrativeunits/administrative_unit_member_resource_test.go index 670424aea1..67a7653c5f 100644 --- a/internal/services/administrativeunits/administrative_unit_member_resource_test.go +++ b/internal/services/administrativeunits/administrative_unit_member_resource_test.go @@ -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{} @@ -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 { diff --git a/internal/services/administrativeunits/administrative_unit_resource.go b/internal/services/administrativeunits/administrative_unit_resource.go index e397aa1317..84de7a56ab 100644 --- a/internal/services/administrativeunits/administrative_unit_resource.go +++ b/internal/services/administrativeunits/administrative_unit_resource.go @@ -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" @@ -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) @@ -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 { @@ -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) @@ -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 { @@ -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) @@ -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) } diff --git a/internal/services/administrativeunits/administrative_unit_resource_test.go b/internal/services/administrativeunits/administrative_unit_resource_test.go index 7551d343f1..d1cdb0fece 100644 --- a/internal/services/administrativeunits/administrative_unit_resource_test.go +++ b/internal/services/administrativeunits/administrative_unit_resource_test.go @@ -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{} @@ -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 { diff --git a/internal/services/administrativeunits/administrative_unit_role_member_resource.go b/internal/services/administrativeunits/administrative_unit_role_member_resource.go index eacee8b70f..534a3a2cb3 100644 --- a/internal/services/administrativeunits/administrative_unit_role_member_resource.go +++ b/internal/services/administrativeunits/administrative_unit_role_member_resource.go @@ -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" ) @@ -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, }, diff --git a/internal/services/administrativeunits/administrative_unit_role_member_resource_test.go b/internal/services/administrativeunits/administrative_unit_role_member_resource_test.go index 15c06b184b..cd7a8e7764 100644 --- a/internal/services/administrativeunits/administrative_unit_role_member_resource_test.go +++ b/internal/services/administrativeunits/administrative_unit_role_member_resource_test.go @@ -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{} @@ -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 { diff --git a/internal/services/applications/application_federated_identity_credential_resource.go b/internal/services/applications/application_federated_identity_credential_resource.go index adf74516ae..146e19723a 100644 --- a/internal/services/applications/application_federated_identity_credential_resource.go +++ b/internal/services/applications/application_federated_identity_credential_resource.go @@ -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" ) @@ -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)), @@ -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)), } diff --git a/internal/services/applications/application_from_template_resource.go b/internal/services/applications/application_from_template_resource.go index 0af4c8ac53..1a3d7ca951 100644 --- a/internal/services/applications/application_from_template_resource.go +++ b/internal/services/applications/application_from_template_resource.go @@ -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" ) @@ -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 } diff --git a/internal/services/applications/application_identifier_uri_resource.go b/internal/services/applications/application_identifier_uri_resource.go index b70a1917da..b0994836db 100644 --- a/internal/services/applications/application_identifier_uri_resource.go +++ b/internal/services/applications/application_identifier_uri_resource.go @@ -7,7 +7,6 @@ import ( "context" "encoding/base64" "fmt" - "github.com/manicminer/hamilton/msgraph" "net/http" "time" @@ -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 { diff --git a/internal/services/applications/application_registration_resource.go b/internal/services/applications/application_registration_resource.go index 8ae96c02d9..947bdc4fde 100644 --- a/internal/services/applications/application_registration_resource.go +++ b/internal/services/applications/application_registration_resource.go @@ -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" ) @@ -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) } diff --git a/internal/services/applications/application_resource.go b/internal/services/applications/application_resource.go index 730bed2ebe..72f338a357 100644 --- a/internal/services/applications/application_resource.go +++ b/internal/services/applications/application_resource.go @@ -989,24 +989,24 @@ func applicationResourceCreate(ctx context.Context, d *pluginsdk.ResourceData, m properties := msgraph.Application{ Api: api, AppRoles: expandApplicationAppRoles(d.Get("app_role").(*pluginsdk.Set).List()), - Description: utils.NullableString(d.Get("description").(string)), + Description: tf.NullableString(d.Get("description").(string)), DisplayName: pointer.To(displayName), GroupMembershipClaims: expandApplicationGroupMembershipClaims(d.Get("group_membership_claims").(*pluginsdk.Set).List()), IdentifierUris: tf.ExpandStringSlicePtr(d.Get("identifier_uris").(*pluginsdk.Set).List()), Info: &msgraph.InformationalUrl{ - MarketingUrl: utils.NullableString(d.Get("marketing_url").(string)), - PrivacyStatementUrl: utils.NullableString(d.Get("privacy_statement_url").(string)), - SupportUrl: utils.NullableString(d.Get("support_url").(string)), - TermsOfServiceUrl: utils.NullableString(d.Get("terms_of_service_url").(string)), + MarketingUrl: tf.NullableString(d.Get("marketing_url").(string)), + PrivacyStatementUrl: tf.NullableString(d.Get("privacy_statement_url").(string)), + SupportUrl: tf.NullableString(d.Get("support_url").(string)), + TermsOfServiceUrl: tf.NullableString(d.Get("terms_of_service_url").(string)), }, IsDeviceOnlyAuthSupported: pointer.To(d.Get("device_only_auth_enabled").(bool)), IsFallbackPublicClient: pointer.To(d.Get("fallback_public_client_enabled").(bool)), - Notes: utils.NullableString(d.Get("notes").(string)), + Notes: tf.NullableString(d.Get("notes").(string)), Oauth2RequirePostResponse: pointer.To(d.Get("oauth2_post_response_required").(bool)), OptionalClaims: expandApplicationOptionalClaims(d.Get("optional_claims").([]interface{})), PublicClient: expandApplicationPublicClient(d.Get("public_client").([]interface{})), RequiredResourceAccess: expandApplicationRequiredResourceAccess(d.Get("required_resource_access").(*pluginsdk.Set).List()), - ServiceManagementReference: utils.NullableString(d.Get("service_management_reference").(string)), + ServiceManagementReference: tf.NullableString(d.Get("service_management_reference").(string)), SignInAudience: pointer.To(d.Get("sign_in_audience").(string)), Spa: expandApplicationSpa(d.Get("single_page_application").([]interface{})), Tags: &tags, @@ -1190,24 +1190,24 @@ func applicationResourceUpdate(ctx context.Context, d *pluginsdk.ResourceData, m }, Api: expandApplicationApi(d.Get("api").([]interface{})), AppRoles: expandApplicationAppRoles(d.Get("app_role").(*pluginsdk.Set).List()), - Description: utils.NullableString(d.Get("description").(string)), + Description: tf.NullableString(d.Get("description").(string)), DisplayName: pointer.To(displayName), GroupMembershipClaims: expandApplicationGroupMembershipClaims(d.Get("group_membership_claims").(*pluginsdk.Set).List()), IdentifierUris: tf.ExpandStringSlicePtr(d.Get("identifier_uris").(*pluginsdk.Set).List()), Info: &msgraph.InformationalUrl{ - MarketingUrl: utils.NullableString(d.Get("marketing_url").(string)), - PrivacyStatementUrl: utils.NullableString(d.Get("privacy_statement_url").(string)), - SupportUrl: utils.NullableString(d.Get("support_url").(string)), - TermsOfServiceUrl: utils.NullableString(d.Get("terms_of_service_url").(string)), + MarketingUrl: tf.NullableString(d.Get("marketing_url").(string)), + PrivacyStatementUrl: tf.NullableString(d.Get("privacy_statement_url").(string)), + SupportUrl: tf.NullableString(d.Get("support_url").(string)), + TermsOfServiceUrl: tf.NullableString(d.Get("terms_of_service_url").(string)), }, IsDeviceOnlyAuthSupported: pointer.To(d.Get("device_only_auth_enabled").(bool)), IsFallbackPublicClient: pointer.To(d.Get("fallback_public_client_enabled").(bool)), - Notes: utils.NullableString(d.Get("notes").(string)), + Notes: tf.NullableString(d.Get("notes").(string)), Oauth2RequirePostResponse: pointer.To(d.Get("oauth2_post_response_required").(bool)), OptionalClaims: expandApplicationOptionalClaims(d.Get("optional_claims").([]interface{})), PublicClient: expandApplicationPublicClient(d.Get("public_client").([]interface{})), RequiredResourceAccess: expandApplicationRequiredResourceAccess(d.Get("required_resource_access").(*pluginsdk.Set).List()), - ServiceManagementReference: utils.NullableString(d.Get("service_management_reference").(string)), + ServiceManagementReference: tf.NullableString(d.Get("service_management_reference").(string)), SignInAudience: pointer.To(d.Get("sign_in_audience").(string)), Spa: expandApplicationSpa(d.Get("single_page_application").([]interface{})), Tags: &tags, diff --git a/internal/services/applications/application_resource_test.go b/internal/services/applications/application_resource_test.go index 2175afb531..4dedc02af1 100644 --- a/internal/services/applications/application_resource_test.go +++ b/internal/services/applications/application_resource_test.go @@ -10,12 +10,12 @@ import ( "regexp" "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 ApplicationResource struct{} @@ -604,7 +604,7 @@ func (r ApplicationResource) Exists(ctx context.Context, clients *clients.Client } return nil, fmt.Errorf("failed to retrieve Application with object ID %q: %+v", state.ID, err) } - return utils.Bool(app.ID() != nil && *app.ID() == state.ID), nil + return pointer.To(app.ID() != nil && *app.ID() == state.ID), nil } func (ApplicationResource) basic(data acceptance.TestData) string { diff --git a/internal/services/applications/applications.go b/internal/services/applications/applications.go index a98fb505c1..9059e080a0 100644 --- a/internal/services/applications/applications.go +++ b/internal/services/applications/applications.go @@ -12,11 +12,11 @@ import ( "strings" "time" + "github.com/hashicorp/go-azure-helpers/lang/pointer" "github.com/hashicorp/go-azure-sdk/sdk/odata" "github.com/hashicorp/terraform-provider-azuread/internal/helpers" "github.com/hashicorp/terraform-provider-azuread/internal/tf" "github.com/hashicorp/terraform-provider-azuread/internal/tf/pluginsdk" - "github.com/hashicorp/terraform-provider-azuread/internal/utils" "github.com/manicminer/hamilton/msgraph" ) @@ -380,10 +380,10 @@ func applicationValidateRolesScopes(appRoles, oauth2Permissions []interface{}) e func expandApplicationApi(input []interface{}) (result *msgraph.ApplicationApi) { result = &msgraph.ApplicationApi{ - AcceptMappedClaims: utils.Bool(false), + AcceptMappedClaims: pointer.To(false), KnownClientApplications: &[]string{}, OAuth2PermissionScopes: &[]msgraph.PermissionScope{}, - RequestedAccessTokenVersion: utils.Int32(int32(1)), + RequestedAccessTokenVersion: pointer.To(int32(1)), } if len(input) == 0 || input[0] == nil { @@ -392,14 +392,14 @@ func expandApplicationApi(input []interface{}) (result *msgraph.ApplicationApi) in := input[0].(map[string]interface{}) if v, ok := in["mapped_claims_enabled"]; ok { - result.AcceptMappedClaims = utils.Bool(v.(bool)) + result.AcceptMappedClaims = pointer.To(v.(bool)) } if v, ok := in["known_client_applications"]; ok { result.KnownClientApplications = tf.ExpandStringSlicePtr(v.(*pluginsdk.Set).List()) } result.OAuth2PermissionScopes = expandApplicationOAuth2PermissionScope(in["oauth2_permission_scope"].(*pluginsdk.Set).List()) if v, ok := in["requested_access_token_version"]; ok { - result.RequestedAccessTokenVersion = utils.Int32(int32(v.(int))) + result.RequestedAccessTokenVersion = pointer.To(int32(v.(int))) } return @@ -424,15 +424,15 @@ func expandApplicationAppRoles(input []interface{}) *[]msgraph.AppRole { } newAppRole := msgraph.AppRole{ - ID: utils.String(appRole["id"].(string)), + ID: pointer.To(appRole["id"].(string)), AllowedMemberTypes: &allowedMemberTypes, - Description: utils.String(appRole["description"].(string)), - DisplayName: utils.String(appRole["display_name"].(string)), - IsEnabled: utils.Bool(appRole["enabled"].(bool)), + Description: pointer.To(appRole["description"].(string)), + DisplayName: pointer.To(appRole["display_name"].(string)), + IsEnabled: pointer.To(appRole["enabled"].(bool)), } if v, ok := appRole["value"]; ok { - newAppRole.Value = utils.String(v.(string)) + newAppRole.Value = pointer.To(v.(string)) } result = append(result, newAppRole) @@ -462,8 +462,8 @@ func expandApplicationImplicitGrantSettings(input []interface{}) *msgraph.Implic } return &msgraph.ImplicitGrantSettings{ - EnableAccessTokenIssuance: utils.Bool(enableAccessTokenIssuance), - EnableIdTokenIssuance: utils.Bool(enableIdTokenIssuance), + EnableAccessTokenIssuance: pointer.To(enableAccessTokenIssuance), + EnableIdTokenIssuance: pointer.To(enableIdTokenIssuance), } } @@ -478,14 +478,14 @@ func expandApplicationOAuth2PermissionScope(in []interface{}) *[]msgraph.Permiss result = append(result, msgraph.PermissionScope{ - AdminConsentDescription: utils.String(oauth2Permissions["admin_consent_description"].(string)), - AdminConsentDisplayName: utils.String(oauth2Permissions["admin_consent_display_name"].(string)), - ID: utils.String(oauth2Permissions["id"].(string)), - IsEnabled: utils.Bool(oauth2Permissions["enabled"].(bool)), + AdminConsentDescription: pointer.To(oauth2Permissions["admin_consent_description"].(string)), + AdminConsentDisplayName: pointer.To(oauth2Permissions["admin_consent_display_name"].(string)), + ID: pointer.To(oauth2Permissions["id"].(string)), + IsEnabled: pointer.To(oauth2Permissions["enabled"].(bool)), Type: oauth2Permissions["type"].(string), - UserConsentDescription: utils.String(oauth2Permissions["user_consent_description"].(string)), - UserConsentDisplayName: utils.String(oauth2Permissions["user_consent_display_name"].(string)), - Value: utils.String(oauth2Permissions["value"].(string)), + UserConsentDescription: pointer.To(oauth2Permissions["user_consent_description"].(string)), + UserConsentDisplayName: pointer.To(oauth2Permissions["user_consent_display_name"].(string)), + Value: pointer.To(oauth2Permissions["value"].(string)), }, ) } @@ -526,8 +526,8 @@ func expandApplicationOptionalClaim(in []interface{}) *[]msgraph.OptionalClaim { } newClaim := msgraph.OptionalClaim{ - Name: utils.String(optionalClaim["name"].(string)), - Essential: utils.Bool(optionalClaim["essential"].(bool)), + Name: pointer.To(optionalClaim["name"].(string)), + Essential: pointer.To(optionalClaim["essential"].(bool)), AdditionalProperties: &additionalProps, } @@ -566,7 +566,7 @@ func expandApplicationRequiredResourceAccess(in []interface{}) *[]msgraph.Requir requiredResourceAccess := raw.(map[string]interface{}) result = append(result, msgraph.RequiredResourceAccess{ - ResourceAppId: utils.String(requiredResourceAccess["resource_app_id"].(string)), + ResourceAppId: pointer.To(requiredResourceAccess["resource_app_id"].(string)), ResourceAccess: expandApplicationResourceAccess( requiredResourceAccess["resource_access"].([]interface{}), ), @@ -586,7 +586,7 @@ func expandApplicationResourceAccess(in []interface{}) *[]msgraph.ResourceAccess resourceAccess := resourceAccessRaw.(map[string]interface{}) result = append(result, msgraph.ResourceAccess{ - ID: utils.String(resourceAccess["id"].(string)), + ID: pointer.To(resourceAccess["id"].(string)), Type: resourceAccess["type"].(string), }) } @@ -611,9 +611,9 @@ func expandApplicationSpa(input []interface{}) (result *msgraph.ApplicationSpa) func expandApplicationWeb(input []interface{}) (result *msgraph.ApplicationWeb) { result = &msgraph.ApplicationWeb{ - HomePageUrl: utils.NullableString(""), + HomePageUrl: tf.NullableString(""), ImplicitGrantSettings: expandApplicationImplicitGrantSettings(nil), - LogoutUrl: utils.NullableString(""), + LogoutUrl: tf.NullableString(""), RedirectUris: &[]string{}, } @@ -622,8 +622,8 @@ func expandApplicationWeb(input []interface{}) (result *msgraph.ApplicationWeb) } in := input[0].(map[string]interface{}) - result.HomePageUrl = utils.NullableString(in["homepage_url"].(string)) - result.LogoutUrl = utils.NullableString(in["logout_url"].(string)) + result.HomePageUrl = tf.NullableString(in["homepage_url"].(string)) + result.LogoutUrl = tf.NullableString(in["logout_url"].(string)) result.ImplicitGrantSettings = expandApplicationImplicitGrantSettings(in["implicit_grant"].([]interface{})) result.RedirectUris = tf.ExpandStringSlicePtr(in["redirect_uris"].(*pluginsdk.Set).List()) diff --git a/internal/services/applications/migrations/application_resource.go b/internal/services/applications/migrations/application_resource.go index 1e00ed7faf..7e9bda8a68 100644 --- a/internal/services/applications/migrations/application_resource.go +++ b/internal/services/applications/migrations/application_resource.go @@ -709,7 +709,7 @@ func ResourceApplicationInstanceResourceV1() *pluginsdk.Resource { MaxItems: 1, Elem: &pluginsdk.Resource{ Schema: map[string]*pluginsdk.Schema{ - "access_token": &pluginsdk.Schema{ + "access_token": { Type: pluginsdk.TypeList, Optional: true, Elem: &pluginsdk.Resource{ @@ -740,7 +740,7 @@ func ResourceApplicationInstanceResourceV1() *pluginsdk.Resource { }, }, }, - "id_token": &pluginsdk.Schema{ + "id_token": { Type: pluginsdk.TypeList, Optional: true, Elem: &pluginsdk.Resource{ @@ -771,7 +771,7 @@ func ResourceApplicationInstanceResourceV1() *pluginsdk.Resource { }, }, }, - "saml2_token": &pluginsdk.Schema{ + "saml2_token": { Type: pluginsdk.TypeList, Optional: true, Elem: &pluginsdk.Resource{ diff --git a/internal/services/applications/parse/application.go b/internal/services/applications/parse/application.go index 435ffa2cd3..95ba467043 100644 --- a/internal/services/applications/parse/application.go +++ b/internal/services/applications/parse/application.go @@ -2,6 +2,7 @@ package parse import ( "fmt" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" "github.com/hashicorp/terraform-provider-azuread/internal/tf/validation" ) diff --git a/internal/services/approleassignments/app_role_assignment_resource.go b/internal/services/approleassignments/app_role_assignment_resource.go index b60b8f2fa2..cc8015e18b 100644 --- a/internal/services/approleassignments/app_role_assignment_resource.go +++ b/internal/services/approleassignments/app_role_assignment_resource.go @@ -11,13 +11,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/approleassignments/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" ) @@ -98,9 +98,9 @@ func appRoleAssignmentResourceCreate(ctx context.Context, d *pluginsdk.ResourceD return tf.ErrorDiagF(err, "Could not retrieve service principal for resource (Object ID: %q)", resourceId) } properties := msgraph.AppRoleAssignment{ - AppRoleId: utils.String(appRoleId), - PrincipalId: utils.String(principalId), - ResourceId: utils.String(resourceId), + AppRoleId: pointer.To(appRoleId), + PrincipalId: pointer.To(principalId), + ResourceId: pointer.To(resourceId), } appRoleAssignment, _, err := client.Assign(ctx, properties) diff --git a/internal/services/approleassignments/app_role_assignment_resource_test.go b/internal/services/approleassignments/app_role_assignment_resource_test.go index 50ec3d0a8c..a199a3f523 100644 --- a/internal/services/approleassignments/app_role_assignment_resource_test.go +++ b/internal/services/approleassignments/app_role_assignment_resource_test.go @@ -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/approleassignments/parse" - "github.com/hashicorp/terraform-provider-azuread/internal/utils" ) type AppRoleAssignmentResource struct{} @@ -121,11 +121,11 @@ func (r AppRoleAssignmentResource) Exists(ctx context.Context, clients *clients. for _, assignment := range *appRoleAssignments { if assignment.Id != nil && *assignment.Id == id.AssignmentId { - return utils.Bool(true), nil + return pointer.To(true), nil } } - return utils.Bool(false), nil + return pointer.To(false), nil } func (AppRoleAssignmentResource) servicePrincipalForMsGraph(data acceptance.TestData) string { diff --git a/internal/services/conditionalaccess/conditional_access_policy_resource.go b/internal/services/conditionalaccess/conditional_access_policy_resource.go index a4d3d38479..8ca44d0fb6 100644 --- a/internal/services/conditionalaccess/conditional_access_policy_resource.go +++ b/internal/services/conditionalaccess/conditional_access_policy_resource.go @@ -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" @@ -18,7 +19,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" ) @@ -539,8 +539,8 @@ func conditionalAccessPolicyResourceCreate(ctx context.Context, d *pluginsdk.Res client := meta.(*clients.Client).ConditionalAccess.PoliciesClient properties := msgraph.ConditionalAccessPolicy{ - DisplayName: utils.String(d.Get("display_name").(string)), - State: utils.String(d.Get("state").(string)), + DisplayName: pointer.To(d.Get("display_name").(string)), + State: pointer.To(d.Get("state").(string)), Conditions: expandConditionalAccessConditionSet(d.Get("conditions").([]interface{})), } @@ -570,9 +570,9 @@ func conditionalAccessPolicyResourceUpdate(ctx context.Context, d *pluginsdk.Res client := meta.(*clients.Client).ConditionalAccess.PoliciesClient properties := msgraph.ConditionalAccessPolicy{ - ID: utils.String(d.Id()), - DisplayName: utils.String(d.Get("display_name").(string)), - State: utils.String(d.Get("state").(string)), + ID: pointer.To(d.Id()), + DisplayName: pointer.To(d.Get("display_name").(string)), + State: pointer.To(d.Get("state").(string)), Conditions: expandConditionalAccessConditionSet(d.Get("conditions").([]interface{})), } @@ -672,11 +672,11 @@ func conditionalAccessPolicyResourceDelete(ctx context.Context, d *pluginsdk.Res client.BaseClient.DisableRetries = true if _, status, err := client.Get(ctx, policyId, 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 conditional access policy with ID %q", policyId) } diff --git a/internal/services/conditionalaccess/conditional_access_policy_resource_test.go b/internal/services/conditionalaccess/conditional_access_policy_resource_test.go index 19bda5f9dd..afaa8bb4aa 100644 --- a/internal/services/conditionalaccess/conditional_access_policy_resource_test.go +++ b/internal/services/conditionalaccess/conditional_access_policy_resource_test.go @@ -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 ConditionalAccessPolicyResource struct{} @@ -309,7 +309,7 @@ func (r ConditionalAccessPolicyResource) Exists(ctx context.Context, clients *cl } id = app.ID - return utils.Bool(id != nil && *id == state.ID), nil + return pointer.To(id != nil && *id == state.ID), nil } func (ConditionalAccessPolicyResource) basic(data acceptance.TestData) string { diff --git a/internal/services/conditionalaccess/conditionalaccess.go b/internal/services/conditionalaccess/conditionalaccess.go index 0c08557abe..5ae3b43bc4 100644 --- a/internal/services/conditionalaccess/conditionalaccess.go +++ b/internal/services/conditionalaccess/conditionalaccess.go @@ -4,8 +4,8 @@ package conditionalaccess import ( + "github.com/hashicorp/go-azure-helpers/lang/pointer" "github.com/hashicorp/terraform-provider-azuread/internal/tf" - "github.com/hashicorp/terraform-provider-azuread/internal/utils" "github.com/manicminer/hamilton/msgraph" ) @@ -414,31 +414,31 @@ func expandConditionalAccessSessionControls(in []interface{}) *msgraph.Condition config := in[0].(map[string]interface{}) result.ApplicationEnforcedRestrictions = &msgraph.ApplicationEnforcedRestrictionsSessionControl{ - IsEnabled: utils.Bool(config["application_enforced_restrictions_enabled"].(bool)), + IsEnabled: pointer.To(config["application_enforced_restrictions_enabled"].(bool)), } if cloudAppSecurity := config["cloud_app_security_policy"].(string); cloudAppSecurity != "" { result.CloudAppSecurity = &msgraph.CloudAppSecurityControl{ - IsEnabled: utils.Bool(true), - CloudAppSecurityType: utils.String(cloudAppSecurity), + IsEnabled: pointer.To(true), + CloudAppSecurityType: pointer.To(cloudAppSecurity), } } DisableResilienceDefaults := config["disable_resilience_defaults"] - result.DisableResilienceDefaults = utils.Bool(DisableResilienceDefaults.(bool)) + result.DisableResilienceDefaults = pointer.To(DisableResilienceDefaults.(bool)) if persistentBrowserMode := config["persistent_browser_mode"].(string); persistentBrowserMode != "" { result.PersistentBrowser = &msgraph.PersistentBrowserSessionControl{ - IsEnabled: utils.Bool(true), - Mode: utils.String(persistentBrowserMode), + IsEnabled: pointer.To(true), + Mode: pointer.To(persistentBrowserMode), } } if signInFrequency := config["sign_in_frequency"].(int); signInFrequency > 0 { result.SignInFrequency = &msgraph.SignInFrequencySessionControl{ - IsEnabled: utils.Bool(true), - Type: utils.String(config["sign_in_frequency_period"].(string)), - Value: utils.Int32(int32(signInFrequency)), + IsEnabled: pointer.To(true), + Type: pointer.To(config["sign_in_frequency_period"].(string)), + Value: pointer.To(int32(signInFrequency)), } } @@ -454,8 +454,8 @@ func expandConditionalAccessFilter(in []interface{}) *msgraph.ConditionalAccessF config := in[0].(map[string]interface{}) - result.Mode = utils.String(config["mode"].(string)) - result.Rule = utils.String(config["rule"].(string)) + result.Mode = pointer.To(config["mode"].(string)) + result.Rule = pointer.To(config["rule"].(string)) return &result } @@ -472,7 +472,7 @@ func expandCountryNamedLocation(in []interface{}) *msgraph.CountryNamedLocation includeUnknown := config["include_unknown_countries_and_regions"] result.CountriesAndRegions = tf.ExpandStringSlicePtr(countriesAndRegions) - result.IncludeUnknownCountriesAndRegions = utils.Bool(includeUnknown.(bool)) + result.IncludeUnknownCountriesAndRegions = pointer.To(includeUnknown.(bool)) return &result } @@ -489,7 +489,7 @@ func expandIPNamedLocation(in []interface{}) *msgraph.IPNamedLocation { trusted := config["trusted"] result.IPRanges = expandIPNamedLocationIPRange(ipRanges) - result.IsTrusted = utils.Bool(trusted.(bool)) + result.IsTrusted = pointer.To(trusted.(bool)) return &result } @@ -502,7 +502,7 @@ func expandIPNamedLocationIPRange(in []interface{}) *[]msgraph.IPNamedLocationIP result := make([]msgraph.IPNamedLocationIPRange, 0) for _, cidr := range in { result = append(result, msgraph.IPNamedLocationIPRange{ - CIDRAddress: utils.String(cidr.(string)), + CIDRAddress: pointer.To(cidr.(string)), }) } diff --git a/internal/services/conditionalaccess/named_location_resource.go b/internal/services/conditionalaccess/named_location_resource.go index 04ad311e18..1de19bf9e0 100644 --- a/internal/services/conditionalaccess/named_location_resource.go +++ b/internal/services/conditionalaccess/named_location_resource.go @@ -12,6 +12,7 @@ import ( "reflect" "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" @@ -19,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" ) @@ -109,7 +109,7 @@ func namedLocationResourceCreate(ctx context.Context, d *pluginsdk.ResourceData, displayName := d.Get("display_name").(string) base := msgraph.BaseNamedLocation{ - DisplayName: utils.String(displayName), + DisplayName: pointer.To(displayName), } if v, ok := d.GetOk("ip"); ok { @@ -149,7 +149,7 @@ func namedLocationResourceUpdate(ctx context.Context, d *pluginsdk.ResourceData, client := meta.(*clients.Client).ConditionalAccess.NamedLocationsClient base := msgraph.BaseNamedLocation{ - ID: utils.String(d.Id()), + ID: pointer.To(d.Id()), } if d.HasChange("display_name") { @@ -291,7 +291,7 @@ func namedLocationResourceDelete(ctx context.Context, d *pluginsdk.ResourceData, BaseNamedLocation: &msgraph.BaseNamedLocation{ ID: &namedLocationId, }, - IsTrusted: utils.Bool(false), + IsTrusted: pointer.To(false), } if _, err := client.UpdateIP(ctx, properties); err != nil { return tf.ErrorDiagF(err, "Updating named location with ID %q", namedLocationId) @@ -320,11 +320,11 @@ func namedLocationResourceDelete(ctx context.Context, d *pluginsdk.ResourceData, client.BaseClient.DisableRetries = true if _, status, err := client.Get(ctx, namedLocationId, 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 named location with ID %q", namedLocationId) } diff --git a/internal/services/conditionalaccess/named_location_resource_test.go b/internal/services/conditionalaccess/named_location_resource_test.go index 844f11ab44..e728245189 100644 --- a/internal/services/conditionalaccess/named_location_resource_test.go +++ b/internal/services/conditionalaccess/named_location_resource_test.go @@ -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" "github.com/manicminer/hamilton/msgraph" ) @@ -149,10 +149,10 @@ func (r NamedLocationResource) Exists(ctx context.Context, clients *clients.Clie ipnl, ok1 := (*namedLocation).(msgraph.IPNamedLocation) cnl, ok2 := (*namedLocation).(msgraph.CountryNamedLocation) if ok1 { - return utils.Bool(ipnl.ID != nil && *ipnl.ID == state.ID), nil + return pointer.To(ipnl.ID != nil && *ipnl.ID == state.ID), nil } if ok2 { - return utils.Bool(cnl.ID != nil && *cnl.ID == state.ID), nil + return pointer.To(cnl.ID != nil && *cnl.ID == state.ID), nil } return nil, fmt.Errorf("Unable to match object ID %q to a known type", state.ID) } diff --git a/internal/services/directoryroles/custom_directory_role_resource.go b/internal/services/directoryroles/custom_directory_role_resource.go index 225ac03c7c..f850a257dd 100644 --- a/internal/services/directoryroles/custom_directory_role_resource.go +++ b/internal/services/directoryroles/custom_directory_role_resource.go @@ -11,13 +11,13 @@ 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" "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" ) @@ -115,12 +115,12 @@ func customDirectoryRoleResourceCreate(ctx context.Context, d *pluginsdk.Resourc displayName := d.Get("display_name").(string) properties := msgraph.UnifiedRoleDefinition{ - Description: utils.NullableString(d.Get("description").(string)), - DisplayName: utils.String(displayName), - IsEnabled: utils.Bool(d.Get("enabled").(bool)), + Description: tf.NullableString(d.Get("description").(string)), + DisplayName: pointer.To(displayName), + IsEnabled: pointer.To(d.Get("enabled").(bool)), RolePermissions: expandCustomRolePermissions(d.Get("permissions").(*pluginsdk.Set).List()), - TemplateId: utils.String(d.Get("template_id").(string)), - Version: utils.String(d.Get("version").(string)), + TemplateId: pointer.To(d.Get("template_id").(string)), + Version: pointer.To(d.Get("version").(string)), } role, _, err := client.Create(ctx, properties) @@ -147,12 +147,12 @@ func customDirectoryRoleResourceUpdate(ctx context.Context, d *pluginsdk.Resourc DirectoryObject: msgraph.DirectoryObject{ Id: &roleId, }, - Description: utils.NullableString(d.Get("description").(string)), - DisplayName: utils.String(displayName), - IsEnabled: utils.Bool(d.Get("enabled").(bool)), + Description: tf.NullableString(d.Get("description").(string)), + DisplayName: pointer.To(displayName), + IsEnabled: pointer.To(d.Get("enabled").(bool)), RolePermissions: expandCustomRolePermissions(d.Get("permissions").(*pluginsdk.Set).List()), - TemplateId: utils.String(d.Get("template_id").(string)), - Version: utils.String(d.Get("version").(string)), + TemplateId: pointer.To(d.Get("template_id").(string)), + Version: pointer.To(d.Get("version").(string)), } _, err := client.Update(ctx, properties) diff --git a/internal/services/directoryroles/custom_directory_role_resource_test.go b/internal/services/directoryroles/custom_directory_role_resource_test.go index 92f13df411..b2afac4eb5 100644 --- a/internal/services/directoryroles/custom_directory_role_resource_test.go +++ b/internal/services/directoryroles/custom_directory_role_resource_test.go @@ -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 CustomDirectoryRoleResource struct{} @@ -141,7 +141,7 @@ func (r CustomDirectoryRoleResource) Exists(ctx context.Context, clients *client return nil, fmt.Errorf("failed to retrieve Custom Directory Role 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 (r CustomDirectoryRoleResource) basic(data acceptance.TestData) string { diff --git a/internal/services/directoryroles/directory_role_assignment_resource.go b/internal/services/directoryroles/directory_role_assignment_resource.go index e6404b180e..ff6b089dde 100644 --- a/internal/services/directoryroles/directory_role_assignment_resource.go +++ b/internal/services/directoryroles/directory_role_assignment_resource.go @@ -11,12 +11,12 @@ 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/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" ) @@ -132,7 +132,7 @@ func directoryRoleAssignmentResourceCreate(ctx context.Context, d *pluginsdk.Res case directoryScopeId != "": properties.DirectoryScopeId = &directoryScopeId default: - properties.DirectoryScopeId = utils.String("/") + properties.DirectoryScopeId = pointer.To("/") } assignment, status, err := client.Create(ctx, properties) diff --git a/internal/services/directoryroles/directory_role_assignment_resource_test.go b/internal/services/directoryroles/directory_role_assignment_resource_test.go index 8fa400deb3..c030dcc97a 100644 --- a/internal/services/directoryroles/directory_role_assignment_resource_test.go +++ b/internal/services/directoryroles/directory_role_assignment_resource_test.go @@ -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 DirectoryRoleAssignmentResource struct{} @@ -151,12 +151,12 @@ func (r DirectoryRoleAssignmentResource) Exists(ctx context.Context, clients *cl if _, status, err := client.Get(ctx, state.ID, 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 directory role assignment %q: %+v", state.ID, err) } - return utils.Bool(true), nil + return pointer.To(true), nil } func (DirectoryRoleAssignmentResource) templateThreeUsers(data acceptance.TestData) string { diff --git a/internal/services/directoryroles/directory_role_eligibility_schedule_request_resource.go b/internal/services/directoryroles/directory_role_eligibility_schedule_request_resource.go index d955352f46..220e0c7361 100644 --- a/internal/services/directoryroles/directory_role_eligibility_schedule_request_resource.go +++ b/internal/services/directoryroles/directory_role_eligibility_schedule_request_resource.go @@ -8,6 +8,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" @@ -15,7 +16,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" ) @@ -85,7 +85,7 @@ func directoryRoleEligibilityScheduleRequestResourceCreate(ctx context.Context, now := time.Now() properties := msgraph.UnifiedRoleEligibilityScheduleRequest{ - Action: utils.String(msgraph.UnifiedRoleScheduleRequestActionAdminAssign), + Action: pointer.To(msgraph.UnifiedRoleScheduleRequestActionAdminAssign), RoleDefinitionId: &roleDefinitionId, PrincipalId: &principalId, Justification: &justification, @@ -93,7 +93,7 @@ func directoryRoleEligibilityScheduleRequestResourceCreate(ctx context.Context, ScheduleInfo: &msgraph.RequestSchedule{ StartDateTime: &now, Expiration: &msgraph.ExpirationPattern{ - Type: utils.String(msgraph.ExpirationPatternTypeNoExpiration), + Type: pointer.To(msgraph.ExpirationPatternTypeNoExpiration), }, }, } @@ -115,11 +115,11 @@ func directoryRoleEligibilityScheduleRequestResourceCreate(ctx context.Context, resr, status, err := client.Get(ctx, *roleEligibilityScheduleRequest.ID, odata.Query{}) if err != nil { if status == http.StatusNotFound { - return utils.Bool(false), nil + return pointer.To(false), nil } return nil, err } - return utils.Bool(resr != nil), nil + return pointer.To(resr != nil), nil }); err != nil { return tf.ErrorDiagF(err, "Waiting for role eligibility schedule request for %q to be created for directory role %q", principalId, roleDefinitionId) } @@ -158,7 +158,7 @@ func directoryRoleEligibilityScheduleRequestResourceDelete(ctx context.Context, return tf.ErrorDiagF(err, "Retrieving roleEligibilityScheduleRequest %q", id) } - roleEligibilityScheduleRequest.Action = utils.String(msgraph.UnifiedRoleScheduleRequestActionAdminRemove) + roleEligibilityScheduleRequest.Action = pointer.To(msgraph.UnifiedRoleScheduleRequestActionAdminRemove) if _, _, err := client.Create(ctx, *roleEligibilityScheduleRequest); err != nil { return tf.ErrorDiagF(err, "Deleting role eligibility schedule request %q: %+v", d.Id(), err) diff --git a/internal/services/directoryroles/directory_role_eligibility_schedule_request_resource_test.go b/internal/services/directoryroles/directory_role_eligibility_schedule_request_resource_test.go index 31b986fc93..99a014fae8 100644 --- a/internal/services/directoryroles/directory_role_eligibility_schedule_request_resource_test.go +++ b/internal/services/directoryroles/directory_role_eligibility_schedule_request_resource_test.go @@ -6,12 +6,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 RoleEligibilityScheduleRequestResource struct{} @@ -42,7 +42,7 @@ func (r RoleEligibilityScheduleRequestResource) Exists(ctx context.Context, clie return nil, fmt.Errorf("failed to retrieve Role Eligibility Schedule Request with object ID %q: %+v", state.ID, err) } - return utils.Bool(resr.ID != nil && *resr.ID == state.ID), nil + return pointer.To(resr.ID != nil && *resr.ID == state.ID), nil } func (r RoleEligibilityScheduleRequestResource) basic(data acceptance.TestData) string { diff --git a/internal/services/directoryroles/directory_role_member_resource.go b/internal/services/directoryroles/directory_role_member_resource.go index 82d7395767..d1d145c024 100644 --- a/internal/services/directoryroles/directory_role_member_resource.go +++ b/internal/services/directoryroles/directory_role_member_resource.go @@ -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/terraform-provider-azuread/internal/clients" "github.com/hashicorp/terraform-provider-azuread/internal/helpers" @@ -18,7 +19,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" ) @@ -95,7 +95,7 @@ func directoryRoleMemberResourceCreate(ctx context.Context, d *pluginsdk.Resourc 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))) role.Members = &msgraph.Members{*memberObject} @@ -180,11 +180,11 @@ func directoryRoleMemberResourceDelete(ctx context.Context, d *pluginsdk.Resourc client.BaseClient.DisableRetries = true if _, status, err := client.GetMember(ctx, id.DirectoryRoleId, 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 directory role with object ID %q", id.MemberId, id.DirectoryRoleId) } diff --git a/internal/services/directoryroles/directory_role_member_resource_test.go b/internal/services/directoryroles/directory_role_member_resource_test.go index ee7e88e699..44f5177b00 100644 --- a/internal/services/directoryroles/directory_role_member_resource_test.go +++ b/internal/services/directoryroles/directory_role_member_resource_test.go @@ -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/directoryroles/parse" - "github.com/hashicorp/terraform-provider-azuread/internal/utils" ) type DirectoryRoleMemberResource struct{} @@ -120,12 +120,12 @@ func (r DirectoryRoleMemberResource) Exists(ctx context.Context, clients *client if _, status, err := client.GetMember(ctx, id.DirectoryRoleId, 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 directory role member %q (role ID: %q): %+v", id.MemberId, id.DirectoryRoleId, err) } - return utils.Bool(true), nil + return pointer.To(true), nil } func (DirectoryRoleMemberResource) templateThreeUsers(data acceptance.TestData) string { diff --git a/internal/services/directoryroles/directory_role_resource_test.go b/internal/services/directoryroles/directory_role_resource_test.go index a23bc2e9cb..301711ca96 100644 --- a/internal/services/directoryroles/directory_role_resource_test.go +++ b/internal/services/directoryroles/directory_role_resource_test.go @@ -9,11 +9,11 @@ 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/utils" ) type DirectoryRoleResource struct{} @@ -64,7 +64,7 @@ func (r DirectoryRoleResource) Exists(ctx context.Context, clients *clients.Clie } return nil, fmt.Errorf("failed to retrieve Directory Role 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 (DirectoryRoleResource) byDisplayName(_ acceptance.TestData) string { diff --git a/internal/services/groups/group_data_source.go b/internal/services/groups/group_data_source.go index e885d39c73..e7eb5014f0 100644 --- a/internal/services/groups/group_data_source.go +++ b/internal/services/groups/group_data_source.go @@ -10,12 +10,12 @@ 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/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" ) @@ -261,10 +261,10 @@ func groupDataSourceRead(ctx context.Context, d *pluginsdk.ResourceData, meta in var mailEnabled, securityEnabled *bool if v, exists := d.GetOkExists("mail_enabled"); exists { //nolint:staticcheck // needed to detect unset booleans - mailEnabled = utils.Bool(v.(bool)) + mailEnabled = pointer.To(v.(bool)) } if v, exists := d.GetOkExists("security_enabled"); exists { //nolint:staticcheck // needed to detect unset booleans - securityEnabled = utils.Bool(v.(bool)) + securityEnabled = pointer.To(v.(bool)) } var mailNickname string diff --git a/internal/services/groups/group_member_resource.go b/internal/services/groups/group_member_resource.go index 5c78d4d514..3296182401 100644 --- a/internal/services/groups/group_member_resource.go +++ b/internal/services/groups/group_member_resource.go @@ -12,6 +12,7 @@ import ( "strings" "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" @@ -19,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" ) @@ -100,7 +100,7 @@ func groupMemberResourceCreate(ctx context.Context, d *pluginsdk.ResourceData, m 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))) group.Members = &msgraph.Members{*memberObject} @@ -174,11 +174,11 @@ func groupMemberResourceDelete(ctx context.Context, d *pluginsdk.ResourceData, m client.BaseClient.DisableRetries = true if _, status, err := client.GetMember(ctx, id.GroupId, 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 group with object ID %q", id.MemberId, id.GroupId) } diff --git a/internal/services/groups/group_member_resource_test.go b/internal/services/groups/group_member_resource_test.go index 55b784c9d1..cda6849ce4 100644 --- a/internal/services/groups/group_member_resource_test.go +++ b/internal/services/groups/group_member_resource_test.go @@ -9,12 +9,12 @@ import ( "strings" "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/groups/parse" - "github.com/hashicorp/terraform-provider-azuread/internal/utils" ) type GroupMemberResource struct{} @@ -155,7 +155,7 @@ func (r GroupMemberResource) Exists(ctx context.Context, clients *clients.Client if members != nil { for _, objectId := range *members { if strings.EqualFold(objectId, id.MemberId) { - return utils.Bool(true), nil + return pointer.To(true), nil } } } diff --git a/internal/services/groups/group_resource.go b/internal/services/groups/group_resource.go index 23ab523d87..101e5cc0f5 100644 --- a/internal/services/groups/group_resource.go +++ b/internal/services/groups/group_resource.go @@ -13,6 +13,7 @@ import ( "strings" "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" @@ -489,10 +490,10 @@ func groupResourceCreate(ctx context.Context, d *pluginsdk.ResourceData, meta in var writebackConfiguration *msgraph.GroupWritebackConfiguration if v := d.Get("writeback_enabled").(bool); v { writebackConfiguration = &msgraph.GroupWritebackConfiguration{ - IsEnabled: utils.Bool(d.Get("writeback_enabled").(bool)), + IsEnabled: pointer.To(d.Get("writeback_enabled").(bool)), } if onPremisesGroupType := d.Get("onpremises_group_type").(string); onPremisesGroupType != "" { - writebackConfiguration.OnPremisesGroupType = utils.String(onPremisesGroupType) + writebackConfiguration.OnPremisesGroupType = pointer.To(onPremisesGroupType) } } @@ -503,35 +504,35 @@ func groupResourceCreate(ctx context.Context, d *pluginsdk.ResourceData, meta in DirectoryObject: msgraph.DirectoryObject{ ODataType: &odataType, }, - Description: utils.NullableString(description), - DisplayName: utils.String(displayName), + Description: tf.NullableString(description), + DisplayName: pointer.To(displayName), GroupTypes: &groupTypes, - IsAssignableToRole: utils.Bool(d.Get("assignable_to_role").(bool)), - MailEnabled: utils.Bool(mailEnabled), - MailNickname: utils.String(mailNickname), - MembershipRule: utils.NullableString(""), + IsAssignableToRole: pointer.To(d.Get("assignable_to_role").(bool)), + MailEnabled: pointer.To(mailEnabled), + MailNickname: pointer.To(mailNickname), + MembershipRule: tf.NullableString(""), ResourceBehaviorOptions: &behaviorOptions, ResourceProvisioningOptions: &provisioningOptions, - SecurityEnabled: utils.Bool(securityEnabled), + SecurityEnabled: pointer.To(securityEnabled), WritebackConfiguration: writebackConfiguration, } if v, ok := d.GetOk("dynamic_membership"); ok && len(v.([]interface{})) > 0 { if d.Get("dynamic_membership.0.enabled").(bool) { - properties.MembershipRuleProcessingState = utils.String("On") + properties.MembershipRuleProcessingState = pointer.To("On") } else { - properties.MembershipRuleProcessingState = utils.String("Paused") + properties.MembershipRuleProcessingState = pointer.To("Paused") } - properties.MembershipRule = utils.NullableString(d.Get("dynamic_membership.0.rule").(string)) + properties.MembershipRule = tf.NullableString(d.Get("dynamic_membership.0.rule").(string)) } if theme := d.Get("theme").(string); theme != "" { - properties.Theme = utils.NullableString(theme) + properties.Theme = tf.NullableString(theme) } if visibility := d.Get("visibility").(string); visibility != "" { - properties.Visibility = utils.String(visibility) + properties.Visibility = pointer.To(visibility) } // Sort the owners into two slices, the first containing up to 20 and the rest overflowing to the second slice @@ -549,7 +550,7 @@ func groupResourceCreate(ctx context.Context, d *pluginsdk.ResourceData, meta in if ownerObject.ID() == nil { return nil, errors.New("ownerObject ID was nil") } - ownerObject.ODataId = (*odata.Id)(utils.String(fmt.Sprintf("%s/v1.0/%s/directoryObjects/%s", + ownerObject.ODataId = (*odata.Id)(pointer.To(fmt.Sprintf("%s/v1.0/%s/directoryObjects/%s", client.BaseClient.Endpoint, tenantId, id))) if ownerObject.ODataType == nil { @@ -714,7 +715,7 @@ func groupResourceCreate(ctx context.Context, d *pluginsdk.ResourceData, meta in DirectoryObject: msgraph.DirectoryObject{ Id: group.ID(), }, - DisplayName: utils.String(displayNameToSet), + DisplayName: pointer.To(displayNameToSet), }) if err != nil { if status == http.StatusNotFound { @@ -731,11 +732,11 @@ func groupResourceCreate(ctx context.Context, d *pluginsdk.ResourceData, meta in group, status, err := client.Get(ctx, *group.ID(), odata.Query{}) if err != nil { if status == http.StatusNotFound { - return utils.Bool(false), nil + return pointer.To(false), nil } return nil, err } - return utils.Bool(group.DisplayName != nil && *group.DisplayName == displayName), nil + return pointer.To(group.DisplayName != nil && *group.DisplayName == displayName), nil }); err != nil { return tf.ErrorDiagF(err, "Waiting for update of `display_name` for group with object ID %q", *group.ID()) } @@ -752,13 +753,13 @@ func groupResourceCreate(ctx context.Context, d *pluginsdk.ResourceData, meta in if err != nil { return nil, err } - return utils.Bool(group.Description != nil && *group.Description != ""), nil + return pointer.To(group.Description != nil && *group.Description != ""), nil }); updated { status, err = client.Update(ctx, msgraph.Group{ DirectoryObject: msgraph.DirectoryObject{ Id: group.ID(), }, - Description: utils.NullableString(""), + Description: tf.NullableString(""), }) if err != nil { if status == http.StatusNotFound { @@ -775,7 +776,7 @@ func groupResourceCreate(ctx context.Context, d *pluginsdk.ResourceData, meta in if err != nil { return nil, err } - return utils.Bool(group.Description == nil || *group.Description == ""), nil + return pointer.To(group.Description == nil || *group.Description == ""), nil }); err != nil { return tf.ErrorDiagF(err, "Waiting to remove `description` for group with object ID %q", *group.ID()) } @@ -793,7 +794,7 @@ func groupResourceCreate(ctx context.Context, d *pluginsdk.ResourceData, meta in DirectoryObject: msgraph.DirectoryObject{ Id: group.ID(), }, - AllowExternalSenders: utils.Bool(allowExternalSenders.(bool)), + AllowExternalSenders: pointer.To(allowExternalSenders.(bool)), }); err != nil { return tf.ErrorDiagF(err, "Failed to set `external_senders_allowed` for group with object ID %q", *group.ID()) } @@ -806,7 +807,7 @@ func groupResourceCreate(ctx context.Context, d *pluginsdk.ResourceData, meta in if err != nil { return nil, err } - return utils.Bool(groupExtra != nil && groupExtra.AllowExternalSenders != nil && *groupExtra.AllowExternalSenders == allowExternalSenders), nil + return pointer.To(groupExtra != nil && groupExtra.AllowExternalSenders != nil && *groupExtra.AllowExternalSenders == allowExternalSenders), nil }); err != nil { return tf.ErrorDiagF(err, "Waiting for update of `external_senders_allowed` for group with object ID %q", *group.ID()) } @@ -818,7 +819,7 @@ func groupResourceCreate(ctx context.Context, d *pluginsdk.ResourceData, meta in DirectoryObject: msgraph.DirectoryObject{ Id: group.ID(), }, - AutoSubscribeNewMembers: utils.Bool(autoSubscribeNewMembers.(bool)), + AutoSubscribeNewMembers: pointer.To(autoSubscribeNewMembers.(bool)), }); err != nil { return tf.ErrorDiagF(err, "Failed to set `auto_subscribe_new_members` for group with object ID %q", *group.ID()) } @@ -831,7 +832,7 @@ func groupResourceCreate(ctx context.Context, d *pluginsdk.ResourceData, meta in if err != nil { return nil, err } - return utils.Bool(groupExtra != nil && groupExtra.AutoSubscribeNewMembers != nil && *groupExtra.AutoSubscribeNewMembers == autoSubscribeNewMembers), nil + return pointer.To(groupExtra != nil && groupExtra.AutoSubscribeNewMembers != nil && *groupExtra.AutoSubscribeNewMembers == autoSubscribeNewMembers), nil }); err != nil { return tf.ErrorDiagF(err, "Waiting for update of `auto_subscribe_new_members` for group with object ID %q", *group.ID()) } @@ -843,7 +844,7 @@ func groupResourceCreate(ctx context.Context, d *pluginsdk.ResourceData, meta in DirectoryObject: msgraph.DirectoryObject{ Id: group.ID(), }, - HideFromAddressLists: utils.Bool(hideFromAddressList.(bool)), + HideFromAddressLists: pointer.To(hideFromAddressList.(bool)), }); err != nil { return tf.ErrorDiagF(err, "Failed to set `hide_from_address_lists` for group with object ID %q", *group.ID()) } @@ -856,7 +857,7 @@ func groupResourceCreate(ctx context.Context, d *pluginsdk.ResourceData, meta in if err != nil { return nil, err } - return utils.Bool(groupExtra != nil && groupExtra.HideFromAddressLists != nil && *groupExtra.HideFromAddressLists == hideFromAddressList), nil + return pointer.To(groupExtra != nil && groupExtra.HideFromAddressLists != nil && *groupExtra.HideFromAddressLists == hideFromAddressList), nil }); err != nil { return tf.ErrorDiagF(err, "Waiting for update of `hide_from_address_lists` for group with object ID %q", *group.ID()) } @@ -868,7 +869,7 @@ func groupResourceCreate(ctx context.Context, d *pluginsdk.ResourceData, meta in DirectoryObject: msgraph.DirectoryObject{ Id: group.ID(), }, - HideFromOutlookClients: utils.Bool(hideFromOutlookClients.(bool)), + HideFromOutlookClients: pointer.To(hideFromOutlookClients.(bool)), }); err != nil { return tf.ErrorDiagF(err, "Failed to set `hide_from_outlook_clients` for group with object ID %q", *group.ID()) } @@ -881,7 +882,7 @@ func groupResourceCreate(ctx context.Context, d *pluginsdk.ResourceData, meta in if err != nil { return nil, err } - return utils.Bool(groupExtra != nil && groupExtra.HideFromOutlookClients != nil && *groupExtra.HideFromOutlookClients == hideFromOutlookClients), nil + return pointer.To(groupExtra != nil && groupExtra.HideFromOutlookClients != nil && *groupExtra.HideFromOutlookClients == hideFromOutlookClients), nil }); err != nil { return tf.ErrorDiagF(err, "Waiting for update of `hide_from_outlook_clients` for group with object ID %q", *group.ID()) } @@ -907,7 +908,7 @@ func groupResourceCreate(ctx context.Context, d *pluginsdk.ResourceData, meta in 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) @@ -965,40 +966,40 @@ func groupResourceUpdate(ctx context.Context, d *pluginsdk.ResourceData, meta in group := msgraph.Group{ DirectoryObject: msgraph.DirectoryObject{ - Id: utils.String(groupId), + Id: pointer.To(groupId), }, - Description: utils.NullableString(d.Get("description").(string)), - DisplayName: utils.String(displayName), - MailEnabled: utils.Bool(d.Get("mail_enabled").(bool)), - MembershipRule: utils.NullableString(""), - SecurityEnabled: utils.Bool(d.Get("security_enabled").(bool)), + Description: tf.NullableString(d.Get("description").(string)), + DisplayName: pointer.To(displayName), + MailEnabled: pointer.To(d.Get("mail_enabled").(bool)), + MembershipRule: tf.NullableString(""), + SecurityEnabled: pointer.To(d.Get("security_enabled").(bool)), } if d.HasChange("writeback_enabled") || d.HasChange("onpremises_group_type") { group.WritebackConfiguration = &msgraph.GroupWritebackConfiguration{ - IsEnabled: utils.Bool(d.Get("writeback_enabled").(bool)), + IsEnabled: pointer.To(d.Get("writeback_enabled").(bool)), } if onPremisesGroupType := d.Get("onpremises_group_type").(string); onPremisesGroupType != "" { - group.WritebackConfiguration.OnPremisesGroupType = utils.String(onPremisesGroupType) + group.WritebackConfiguration.OnPremisesGroupType = pointer.To(onPremisesGroupType) } } if v, ok := d.GetOk("dynamic_membership"); ok && len(v.([]interface{})) > 0 { if d.Get("dynamic_membership.0.enabled").(bool) { - group.MembershipRuleProcessingState = utils.String("On") + group.MembershipRuleProcessingState = pointer.To("On") } else { - group.MembershipRuleProcessingState = utils.String("Paused") + group.MembershipRuleProcessingState = pointer.To("Paused") } - group.MembershipRule = utils.NullableString(d.Get("dynamic_membership.0.rule").(string)) + group.MembershipRule = tf.NullableString(d.Get("dynamic_membership.0.rule").(string)) } if theme := d.Get("theme").(string); theme != "" { - group.Theme = utils.NullableString(theme) + group.Theme = tf.NullableString(theme) } if d.HasChange("visibility") { - group.Visibility = utils.String(d.Get("visibility").(string)) + group.Visibility = pointer.To(d.Get("visibility").(string)) } if _, err := client.Update(ctx, group); err != nil { @@ -1027,7 +1028,7 @@ func groupResourceUpdate(ctx context.Context, d *pluginsdk.ResourceData, meta in DirectoryObject: msgraph.DirectoryObject{ Id: group.ID(), }, - AllowExternalSenders: utils.Bool(v.(bool)), + AllowExternalSenders: pointer.To(v.(bool)), }); err != nil { return tf.ErrorDiagF(err, "Failed to set `external_senders_allowed` for group with object ID %q", *group.ID()) } @@ -1040,7 +1041,7 @@ func groupResourceUpdate(ctx context.Context, d *pluginsdk.ResourceData, meta in if err != nil { return nil, err } - return utils.Bool(groupExtra != nil && groupExtra.AllowExternalSenders != nil && *groupExtra.AllowExternalSenders == v.(bool)), nil + return pointer.To(groupExtra != nil && groupExtra.AllowExternalSenders != nil && *groupExtra.AllowExternalSenders == v.(bool)), nil }); err != nil { return tf.ErrorDiagF(err, "Waiting for update of `external_senders_allowed` for group with object ID %q", *group.ID()) } @@ -1052,7 +1053,7 @@ func groupResourceUpdate(ctx context.Context, d *pluginsdk.ResourceData, meta in DirectoryObject: msgraph.DirectoryObject{ Id: group.ID(), }, - AutoSubscribeNewMembers: utils.Bool(v.(bool)), + AutoSubscribeNewMembers: pointer.To(v.(bool)), }); err != nil { return tf.ErrorDiagF(err, "Failed to set `auto_subscribe_new_members` for group with object ID %q", *group.ID()) } @@ -1065,7 +1066,7 @@ func groupResourceUpdate(ctx context.Context, d *pluginsdk.ResourceData, meta in if err != nil { return nil, err } - return utils.Bool(groupExtra != nil && groupExtra.AutoSubscribeNewMembers != nil && *groupExtra.AutoSubscribeNewMembers == v.(bool)), nil + return pointer.To(groupExtra != nil && groupExtra.AutoSubscribeNewMembers != nil && *groupExtra.AutoSubscribeNewMembers == v.(bool)), nil }); err != nil { return tf.ErrorDiagF(err, "Waiting for update of `auto_subscribe_new_members` for group with object ID %q", *group.ID()) } @@ -1077,7 +1078,7 @@ func groupResourceUpdate(ctx context.Context, d *pluginsdk.ResourceData, meta in DirectoryObject: msgraph.DirectoryObject{ Id: group.ID(), }, - HideFromAddressLists: utils.Bool(v.(bool)), + HideFromAddressLists: pointer.To(v.(bool)), }); err != nil { return tf.ErrorDiagF(err, "Failed to set `hide_from_address_lists` for group with object ID %q", *group.ID()) } @@ -1090,7 +1091,7 @@ func groupResourceUpdate(ctx context.Context, d *pluginsdk.ResourceData, meta in if err != nil { return nil, err } - return utils.Bool(groupExtra != nil && groupExtra.HideFromAddressLists != nil && *groupExtra.HideFromAddressLists == v.(bool)), nil + return pointer.To(groupExtra != nil && groupExtra.HideFromAddressLists != nil && *groupExtra.HideFromAddressLists == v.(bool)), nil }); err != nil { return tf.ErrorDiagF(err, "Waiting for update of `hide_from_address_lists` for group with object ID %q", *group.ID()) } @@ -1102,7 +1103,7 @@ func groupResourceUpdate(ctx context.Context, d *pluginsdk.ResourceData, meta in DirectoryObject: msgraph.DirectoryObject{ Id: group.ID(), }, - HideFromOutlookClients: utils.Bool(v.(bool)), + HideFromOutlookClients: pointer.To(v.(bool)), }); err != nil { return tf.ErrorDiagF(err, "Failed to set `hide_from_outlook_clients` for group with object ID %q", *group.ID()) } @@ -1115,7 +1116,7 @@ func groupResourceUpdate(ctx context.Context, d *pluginsdk.ResourceData, meta in if err != nil { return nil, err } - return utils.Bool(groupExtra != nil && groupExtra.HideFromOutlookClients != nil && *groupExtra.HideFromOutlookClients == v.(bool)), nil + return pointer.To(groupExtra != nil && groupExtra.HideFromOutlookClients != nil && *groupExtra.HideFromOutlookClients == v.(bool)), nil }); err != nil { return tf.ErrorDiagF(err, "Waiting for update of `hide_from_outlook_clients` for group with object ID %q", *group.ID()) } @@ -1149,7 +1150,7 @@ func groupResourceUpdate(ctx context.Context, d *pluginsdk.ResourceData, meta in 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) @@ -1190,7 +1191,7 @@ func groupResourceUpdate(ctx context.Context, d *pluginsdk.ResourceData, meta in if ownerObject == nil { return tf.ErrorDiagF(errors.New("returned ownerObject was nil"), "Could not retrieve owner principal object %q", ownerId) } - ownerObject.ODataId = (*odata.Id)(utils.String(fmt.Sprintf("%s/v1.0/%s/directoryObjects/%s", + ownerObject.ODataId = (*odata.Id)(pointer.To(fmt.Sprintf("%s/v1.0/%s/directoryObjects/%s", client.BaseClient.Endpoint, tenantId, ownerId))) newOwners = append(newOwners, *ownerObject) @@ -1385,11 +1386,11 @@ func groupResourceDelete(ctx context.Context, d *pluginsdk.ResourceData, meta in client.BaseClient.DisableRetries = true if _, status, err := client.Get(ctx, groupId, 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 group with object ID %q", groupId) } @@ -1401,7 +1402,7 @@ func addGroupToAdministrativeUnit(ctx context.Context, auClient *msgraph.Adminis members := msgraph.Members{ group.DirectoryObject, } - members[0].ODataId = (*odata.Id)(utils.String(fmt.Sprintf("%s/v1.0/%s/directoryObjects/%s", + members[0].ODataId = (*odata.Id)(pointer.To(fmt.Sprintf("%s/v1.0/%s/directoryObjects/%s", auClient.BaseClient.Endpoint, tenantId, *group.DirectoryObject.ID()))) _, err := auClient.AddMembers(ctx, administrativeUnitId, &members) return err diff --git a/internal/services/groups/group_resource_test.go b/internal/services/groups/group_resource_test.go index acd1770597..c2cebcf910 100644 --- a/internal/services/groups/group_resource_test.go +++ b/internal/services/groups/group_resource_test.go @@ -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 GroupResource struct{} @@ -564,7 +564,7 @@ func (r GroupResource) Exists(ctx context.Context, clients *clients.Client, stat } return nil, fmt.Errorf("failed to retrieve Group with object ID %q: %+v", state.ID, err) } - return utils.Bool(group.ID() != nil && *group.ID() == state.ID), nil + return pointer.To(group.ID() != nil && *group.ID() == state.ID), nil } func (GroupResource) templateDiverseDirectoryObjects(data acceptance.TestData) string { diff --git a/internal/services/groups/groups.go b/internal/services/groups/groups.go index 533f969885..403f70a4f0 100644 --- a/internal/services/groups/groups.go +++ b/internal/services/groups/groups.go @@ -8,7 +8,6 @@ import ( "fmt" "math/rand" "net/http" - "time" "github.com/hashicorp/go-azure-sdk/sdk/odata" "github.com/manicminer/hamilton/msgraph" @@ -17,7 +16,6 @@ import ( func groupDefaultMailNickname() string { charSet := "0123456789abcdef" result := make([]byte, 9) - rand.Seed(time.Now().UTC().UnixNano()) for i := 0; i < 9; i++ { result[i] = charSet[rand.Intn(len(charSet))] } diff --git a/internal/services/identitygovernance/access_package_assignment_policy_resource.go b/internal/services/identitygovernance/access_package_assignment_policy_resource.go index 0d5a704c23..1aedc0fc0c 100644 --- a/internal/services/identitygovernance/access_package_assignment_policy_resource.go +++ b/internal/services/identitygovernance/access_package_assignment_policy_resource.go @@ -10,6 +10,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" @@ -17,7 +18,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" ) @@ -443,11 +443,11 @@ func accessPackageAssignmentPolicyResourceDelete(ctx context.Context, d *plugins client.BaseClient.DisableRetries = true if _, status, err := client.Get(ctx, accessPackageAssignmentPolicyId, 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 access package assignment policy with object ID %q", accessPackageAssignmentPolicyId) } @@ -469,13 +469,13 @@ func buildAssignmentPolicyResourceData(ctx context.Context, d *pluginsdk.Resourc } properties := msgraph.AccessPackageAssignmentPolicy{ - ID: utils.String(d.Id()), - DisplayName: utils.String(d.Get("display_name").(string)), - Description: utils.String(d.Get("description").(string)), - CanExtend: utils.Bool(d.Get("extension_enabled").(bool)), - DurationInDays: utils.Int32(int32(d.Get("duration_in_days").(int))), + ID: pointer.To(d.Id()), + DisplayName: pointer.To(d.Get("display_name").(string)), + Description: pointer.To(d.Get("description").(string)), + CanExtend: pointer.To(d.Get("extension_enabled").(bool)), + DurationInDays: pointer.To(int32(d.Get("duration_in_days").(int))), Questions: expandAccessPackageQuestions(d.Get("question").([]interface{})), - AccessPackageId: utils.String(d.Get("access_package_id").(string)), + AccessPackageId: pointer.To(d.Get("access_package_id").(string)), } expirationDateValue := d.Get("expiration_date").(string) diff --git a/internal/services/identitygovernance/access_package_assignment_policy_resource_test.go b/internal/services/identitygovernance/access_package_assignment_policy_resource_test.go index 22078f3352..5b547fce5f 100644 --- a/internal/services/identitygovernance/access_package_assignment_policy_resource_test.go +++ b/internal/services/identitygovernance/access_package_assignment_policy_resource_test.go @@ -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 AccessPackageAssignmentPolicyResource struct{} @@ -101,11 +101,11 @@ func (AccessPackageAssignmentPolicyResource) Exists(ctx context.Context, clients _, status, err := client.Get(ctx, state.ID, odata.Query{}) if err != nil { if status == http.StatusNotFound { - return utils.Bool(false), nil + return pointer.To(false), nil } return nil, fmt.Errorf("failed to retrieve Access package assignment policy with ID %q: %+v", state.ID, err) } - return utils.Bool(true), nil + return pointer.To(true), nil } func (AccessPackageAssignmentPolicyResource) simple(data acceptance.TestData) string { diff --git a/internal/services/identitygovernance/access_package_catalog_resource.go b/internal/services/identitygovernance/access_package_catalog_resource.go index 1dc8546cef..cf6545d040 100644 --- a/internal/services/identitygovernance/access_package_catalog_resource.go +++ b/internal/services/identitygovernance/access_package_catalog_resource.go @@ -11,6 +11,7 @@ import ( "strings" "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" @@ -18,7 +19,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" ) @@ -88,10 +88,10 @@ func accessPackageCatalogResourceCreate(ctx context.Context, d *pluginsdk.Resour } properties := msgraph.AccessPackageCatalog{ - DisplayName: utils.String(displayName), - Description: utils.String(d.Get("description").(string)), + DisplayName: pointer.To(displayName), + Description: pointer.To(d.Get("description").(string)), State: state, - IsExternallyVisible: utils.Bool(d.Get("externally_visible").(bool)), + IsExternallyVisible: pointer.To(d.Get("externally_visible").(bool)), } accessPackageCatalog, _, err := client.Create(ctx, properties) @@ -117,11 +117,11 @@ func accessPackageCatalogResourceUpdate(ctx context.Context, d *pluginsdk.Resour } properties := msgraph.AccessPackageCatalog{ - ID: utils.String(d.Id()), - DisplayName: utils.String(d.Get("display_name").(string)), - Description: utils.String(d.Get("description").(string)), + ID: pointer.To(d.Id()), + DisplayName: pointer.To(d.Get("display_name").(string)), + Description: pointer.To(d.Get("description").(string)), State: state, - IsExternallyVisible: utils.Bool(d.Get("externally_visible").(bool)), + IsExternallyVisible: pointer.To(d.Get("externally_visible").(bool)), } if _, err := client.Update(ctx, properties); err != nil { @@ -183,11 +183,11 @@ func accessPackageCatalogResourceDelete(ctx context.Context, d *pluginsdk.Resour client.BaseClient.DisableRetries = true if _, status, err := client.Get(ctx, accessPackageCatalogId, 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 access package catalog with object ID %q", accessPackageCatalogId) } diff --git a/internal/services/identitygovernance/access_package_catalog_resource_test.go b/internal/services/identitygovernance/access_package_catalog_resource_test.go index 37772be94b..696d163258 100644 --- a/internal/services/identitygovernance/access_package_catalog_resource_test.go +++ b/internal/services/identitygovernance/access_package_catalog_resource_test.go @@ -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 AccessPackageCatalogResource struct{} @@ -86,12 +86,12 @@ func (AccessPackageCatalogResource) Exists(ctx context.Context, clients *clients _, status, err := client.Get(ctx, state.ID, odata.Query{}) if err != nil { if status == http.StatusNotFound { - return utils.Bool(false), nil + return pointer.To(false), nil } return nil, fmt.Errorf("failed to retrieve access package catalog with ID %q: %+v", state.ID, err) } - return utils.Bool(true), nil + return pointer.To(true), nil } func (AccessPackageCatalogResource) basic(data acceptance.TestData) string { diff --git a/internal/services/identitygovernance/access_package_catalog_role_assignment_resource.go b/internal/services/identitygovernance/access_package_catalog_role_assignment_resource.go index 5fbabcc528..58e6b45781 100644 --- a/internal/services/identitygovernance/access_package_catalog_role_assignment_resource.go +++ b/internal/services/identitygovernance/access_package_catalog_role_assignment_resource.go @@ -12,13 +12,13 @@ import ( "strings" "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" "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" ) @@ -78,10 +78,10 @@ func accessPackageCatalogRoleAssignmentResourceCreate(ctx context.Context, d *pl roleId := d.Get("role_id").(string) properties := msgraph.UnifiedRoleAssignment{ - DirectoryScopeId: utils.String("/"), - PrincipalId: utils.String(principalId), - RoleDefinitionId: utils.String(roleId), - AppScopeId: utils.String("/AccessPackageCatalog/" + catalogId), + DirectoryScopeId: pointer.To("/"), + PrincipalId: pointer.To(principalId), + RoleDefinitionId: pointer.To(roleId), + AppScopeId: pointer.To("/AccessPackageCatalog/" + catalogId), } assignment, status, err := client.Create(ctx, properties) @@ -112,7 +112,7 @@ func accessPackageCatalogRoleAssignmentResourceRead(ctx context.Context, d *plug catalogId := strings.TrimPrefix(*assignment.AppScopeId, "/AccessPackageCatalog/") - tf.Set(d, "catalog_id", utils.String(catalogId)) + tf.Set(d, "catalog_id", pointer.To(catalogId)) tf.Set(d, "principal_object_id", assignment.PrincipalId) tf.Set(d, "role_id", assignment.RoleDefinitionId) diff --git a/internal/services/identitygovernance/access_package_catalog_role_assignment_resource_test.go b/internal/services/identitygovernance/access_package_catalog_role_assignment_resource_test.go index bcbdb0bd8b..f4468c9349 100644 --- a/internal/services/identitygovernance/access_package_catalog_role_assignment_resource_test.go +++ b/internal/services/identitygovernance/access_package_catalog_role_assignment_resource_test.go @@ -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 AccessPackageCatalogRoleAssignmentResource struct{} @@ -80,12 +80,12 @@ func (r AccessPackageCatalogRoleAssignmentResource) Exists(ctx context.Context, if _, status, err := client.Get(ctx, state.ID, 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 directory role assignment %q: %+v", state.ID, err) } - return utils.Bool(true), nil + return pointer.To(true), nil } func (AccessPackageCatalogRoleAssignmentResource) group(data acceptance.TestData) string { diff --git a/internal/services/identitygovernance/access_package_resource.go b/internal/services/identitygovernance/access_package_resource.go index 661d301af5..f80d847d05 100644 --- a/internal/services/identitygovernance/access_package_resource.go +++ b/internal/services/identitygovernance/access_package_resource.go @@ -10,6 +10,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" @@ -17,7 +18,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" ) @@ -90,9 +90,9 @@ func accessPackageResourceCreate(ctx context.Context, d *pluginsdk.ResourceData, } properties := msgraph.AccessPackage{ - DisplayName: utils.String(displayName), - Description: utils.String(d.Get("description").(string)), - IsHidden: utils.Bool(d.Get("hidden").(bool)), + DisplayName: pointer.To(displayName), + Description: pointer.To(d.Get("description").(string)), + IsHidden: pointer.To(d.Get("hidden").(bool)), Catalog: accessPackageCatalog, CatalogId: accessPackageCatalog.ID, } @@ -123,10 +123,10 @@ func accessPackageResourceUpdate(ctx context.Context, d *pluginsdk.ResourceData, defer tf.UnlockByName(accessPackageResourceName, objectId) properties := msgraph.AccessPackage{ - ID: utils.String(objectId), - DisplayName: utils.String(d.Get("display_name").(string)), - Description: utils.String(d.Get("description").(string)), - IsHidden: utils.Bool(d.Get("hidden").(bool)), + ID: pointer.To(objectId), + DisplayName: pointer.To(d.Get("display_name").(string)), + Description: pointer.To(d.Get("description").(string)), + IsHidden: pointer.To(d.Get("hidden").(bool)), Catalog: accessPackageCatalog, CatalogId: accessPackageCatalog.ID, } @@ -186,11 +186,11 @@ func accessPackageResourceDelete(ctx context.Context, d *pluginsdk.ResourceData, client.BaseClient.DisableRetries = true if _, status, err := client.Get(ctx, accessPackageId, 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 access package with object ID %q", accessPackageId) } diff --git a/internal/services/identitygovernance/access_package_resource_catalog_association_resource.go b/internal/services/identitygovernance/access_package_resource_catalog_association_resource.go index ee3fe903aa..c75e036a20 100644 --- a/internal/services/identitygovernance/access_package_resource_catalog_association_resource.go +++ b/internal/services/identitygovernance/access_package_resource_catalog_association_resource.go @@ -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/identitygovernance/parse" "github.com/hashicorp/terraform-provider-azuread/internal/services/identitygovernance/validate" "github.com/hashicorp/terraform-provider-azuread/internal/tf" "github.com/hashicorp/terraform-provider-azuread/internal/tf/pluginsdk" - "github.com/hashicorp/terraform-provider-azuread/internal/utils" "github.com/manicminer/hamilton/msgraph" ) @@ -84,7 +84,7 @@ func accessPackageResourceCatalogAssociationResourceCreate(ctx context.Context, properties := msgraph.AccessPackageResourceRequest{ CatalogId: &catalogId, - RequestType: utils.String("AdminAdd"), + RequestType: pointer.To("AdminAdd"), AccessPackageResource: &msgraph.AccessPackageResource{ OriginId: &resourceOriginId, OriginSystem: resourceOriginSystem, diff --git a/internal/services/identitygovernance/access_package_resource_catalog_association_resource_test.go b/internal/services/identitygovernance/access_package_resource_catalog_association_resource_test.go index 763b0f11d8..c37c362324 100644 --- a/internal/services/identitygovernance/access_package_resource_catalog_association_resource_test.go +++ b/internal/services/identitygovernance/access_package_resource_catalog_association_resource_test.go @@ -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/identitygovernance/parse" - "github.com/hashicorp/terraform-provider-azuread/internal/utils" ) type AccessPackageResourceCatalogAssociationResource struct{} @@ -62,13 +62,13 @@ func (r AccessPackageResourceCatalogAssociationResource) Exists(ctx context.Cont _, status, err := client.Get(ctx, id.CatalogId, id.OriginId) if err != nil { if status == http.StatusNotFound { - return utils.Bool(false), nil + return pointer.To(false), nil } return nil, fmt.Errorf("failed to retrieve access package catalog association with ID %q: %+v", id.ID(), err) } - return utils.Bool(true), nil + return pointer.To(true), nil } func (r AccessPackageResourceCatalogAssociationResource) complete(data acceptance.TestData) string { diff --git a/internal/services/identitygovernance/access_package_resource_package_association_resource.go b/internal/services/identitygovernance/access_package_resource_package_association_resource.go index e3fe563b11..fb9f9579ec 100644 --- a/internal/services/identitygovernance/access_package_resource_package_association_resource.go +++ b/internal/services/identitygovernance/access_package_resource_package_association_resource.go @@ -10,6 +10,7 @@ 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/identitygovernance/parse" @@ -17,7 +18,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" ) @@ -86,8 +86,8 @@ func accessPackageResourcePackageAssociationResourceCreate(ctx context.Context, properties := msgraph.AccessPackageResourceRoleScope{ AccessPackageId: &accessPackageId, AccessPackageResourceRole: &msgraph.AccessPackageResourceRole{ - DisplayName: utils.String(accessType), - OriginId: utils.String(fmt.Sprintf("%s_%s", accessType, catalogResourceAssociationId.OriginId)), + DisplayName: pointer.To(accessType), + OriginId: pointer.To(fmt.Sprintf("%s_%s", accessType, catalogResourceAssociationId.OriginId)), OriginSystem: resource.OriginSystem, AccessPackageResource: &msgraph.AccessPackageResource{ ID: resource.ID, diff --git a/internal/services/identitygovernance/access_package_resource_package_association_resource_test.go b/internal/services/identitygovernance/access_package_resource_package_association_resource_test.go index 89fd1b4cc2..9b42c72e14 100644 --- a/internal/services/identitygovernance/access_package_resource_package_association_resource_test.go +++ b/internal/services/identitygovernance/access_package_resource_package_association_resource_test.go @@ -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/identitygovernance/parse" - "github.com/hashicorp/terraform-provider-azuread/internal/utils" ) type AccessPackageResourcePackageAssociationResource struct{} @@ -48,13 +48,13 @@ func (AccessPackageResourcePackageAssociationResource) Exists(ctx context.Contex _, status, err := client.Get(ctx, id.AccessPackageId, id.ResourcePackageAssociationId) if err != nil { if status == http.StatusNotFound { - return utils.Bool(false), nil + return pointer.To(false), nil } return nil, fmt.Errorf("failed to retrieve access package resource association with ID %q: %+v", id.ID(), err) } - return utils.Bool(true), nil + return pointer.To(true), nil } func (AccessPackageResourcePackageAssociationResource) complete(data acceptance.TestData) string { diff --git a/internal/services/identitygovernance/access_package_resource_test.go b/internal/services/identitygovernance/access_package_resource_test.go index 339f2678dd..924ae49219 100644 --- a/internal/services/identitygovernance/access_package_resource_test.go +++ b/internal/services/identitygovernance/access_package_resource_test.go @@ -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 AccessPackageResource struct{} @@ -86,11 +86,11 @@ func (AccessPackageResource) Exists(ctx context.Context, clients *clients.Client _, status, err := client.Get(ctx, state.ID, odata.Query{}) if err != nil { if status == http.StatusNotFound { - return utils.Bool(false), nil + return pointer.To(false), nil } return nil, fmt.Errorf("failed to retrieve access package with ID %q: %+v", state.ID, err) } - return utils.Bool(true), nil + return pointer.To(true), nil } func (AccessPackageResource) basic(data acceptance.TestData) string { diff --git a/internal/services/identitygovernance/identitygovernance.go b/internal/services/identitygovernance/identitygovernance.go index c984fd6ef6..aa8d3cdbc6 100644 --- a/internal/services/identitygovernance/identitygovernance.go +++ b/internal/services/identitygovernance/identitygovernance.go @@ -7,8 +7,8 @@ import ( "fmt" "time" + "github.com/hashicorp/go-azure-helpers/lang/pointer" "github.com/hashicorp/go-azure-sdk/sdk/odata" - "github.com/hashicorp/terraform-provider-azuread/internal/utils" "github.com/manicminer/hamilton/msgraph" ) @@ -19,7 +19,7 @@ func expandRequestorSettings(input []interface{}) *msgraph.RequestorSettings { in := input[0].(map[string]interface{}) result := msgraph.RequestorSettings{ ScopeType: in["scope_type"].(string), - AcceptRequests: utils.Bool(in["requests_accepted"].(bool)), + AcceptRequests: pointer.To(in["requests_accepted"].(bool)), } result.AllowedRequestors = expandUserSets(in["requestor"].([]interface{})) @@ -46,9 +46,9 @@ func expandApprovalSettings(input []interface{}) *msgraph.ApprovalSettings { in := input[0].(map[string]interface{}) result := msgraph.ApprovalSettings{ - IsApprovalRequired: utils.Bool(in["approval_required"].(bool)), - IsApprovalRequiredForExtension: utils.Bool(in["approval_required_for_extension"].(bool)), - IsRequestorJustificationRequired: utils.Bool(in["requestor_justification_required"].(bool)), + IsApprovalRequired: pointer.To(in["approval_required"].(bool)), + IsApprovalRequiredForExtension: pointer.To(in["approval_required_for_extension"].(bool)), + IsRequestorJustificationRequired: pointer.To(in["requestor_justification_required"].(bool)), } approvalStages := make([]msgraph.ApprovalStage, 0) @@ -56,10 +56,10 @@ func expandApprovalSettings(input []interface{}) *msgraph.ApprovalSettings { v_map := v.(map[string]interface{}) stage := msgraph.ApprovalStage{ - ApprovalStageTimeOutInDays: utils.Int32(int32(v_map["approval_timeout_in_days"].(int))), - EscalationTimeInMinutes: utils.Int32(int32(v_map["enable_alternative_approval_in_days"].(int) * 24 * 60)), - IsApproverJustificationRequired: utils.Bool(v_map["approver_justification_required"].(bool)), - IsEscalationEnabled: utils.Bool(v_map["alternative_approval_enabled"].(bool)), + ApprovalStageTimeOutInDays: pointer.To(int32(v_map["approval_timeout_in_days"].(int))), + EscalationTimeInMinutes: pointer.To(int32(v_map["enable_alternative_approval_in_days"].(int) * 24 * 60)), + IsApproverJustificationRequired: pointer.To(v_map["approver_justification_required"].(bool)), + IsEscalationEnabled: pointer.To(v_map["alternative_approval_enabled"].(bool)), } stage.PrimaryApprovers = expandUserSets(v_map["primary_approver"].([]interface{})) @@ -111,10 +111,10 @@ func expandAssignmentReviewSettings(input []interface{}) (*msgraph.AssignmentRev result := msgraph.AssignmentReviewSettings{ AccessReviewTimeoutBehavior: in["access_review_timeout_behavior"].(string), - DurationInDays: utils.Int32(int32(in["duration_in_days"].(int))), - IsAccessRecommendationEnabled: utils.Bool(in["access_recommendation_enabled"].(bool)), - IsApprovalJustificationRequired: utils.Bool(in["approver_justification_required"].(bool)), - IsEnabled: utils.Bool(in["enabled"].(bool)), + DurationInDays: pointer.To(int32(in["duration_in_days"].(int))), + IsAccessRecommendationEnabled: pointer.To(in["access_recommendation_enabled"].(bool)), + IsApprovalJustificationRequired: pointer.To(in["approver_justification_required"].(bool)), + IsEnabled: pointer.To(in["enabled"].(bool)), RecurrenceType: in["review_frequency"].(string), ReviewerType: in["review_type"].(string), } @@ -159,10 +159,10 @@ func expandUserSets(input []interface{}) *[]msgraph.UserSet { oDataType, needId := userSetODataType(v_map["subject_type"].(string)) userSet := msgraph.UserSet{ ODataType: oDataType, - IsBackup: utils.Bool(v_map["backup"].(bool)), + IsBackup: pointer.To(v_map["backup"].(bool)), } if needId { - userSet.ID = utils.String(v_map["object_id"].(string)) + userSet.ID = pointer.To(v_map["object_id"].(string)) } userSets = append(userSets, userSet) @@ -239,22 +239,22 @@ func expandAccessPackageQuestions(questions []interface{}) *[]msgraph.AccessPack v_text := v_text_list[0].(map[string]interface{}) q := msgraph.AccessPackageQuestion{ - IsRequired: utils.Bool(v_map["required"].(bool)), - Sequence: utils.Int32(int32(v_map["sequence"].(int))), + IsRequired: pointer.To(v_map["required"].(bool)), + Sequence: pointer.To(int32(v_map["sequence"].(int))), Text: expandAccessPackageLocalizedContent(v_text), } v_map_choices := v_map["choice"].([]interface{}) - q.ODataType = utils.String(odata.TypeAccessPackageTextInputQuestion) + q.ODataType = pointer.To(odata.TypeAccessPackageTextInputQuestion) if len(v_map_choices) > 0 { - q.ODataType = utils.String(odata.TypeAccessPackageMultipleChoiceQuestion) + q.ODataType = pointer.To(odata.TypeAccessPackageMultipleChoiceQuestion) choices := make([]msgraph.AccessPackageMultipleChoiceQuestions, 0) for _, c := range v_map_choices { c_map := c.(map[string]interface{}) c_map_display_value := c_map["display_value"].([]interface{}) choices = append(choices, msgraph.AccessPackageMultipleChoiceQuestions{ - ActualValue: utils.String(c_map["actual_value"].(string)), + ActualValue: pointer.To(c_map["actual_value"].(string)), DisplayValue: expandAccessPackageLocalizedContent(c_map_display_value[0].(map[string]interface{})), }) } @@ -305,7 +305,7 @@ func flattenAccessPackageQuestions(input *[]msgraph.AccessPackageQuestion) []map func expandAccessPackageLocalizedContent(input map[string]interface{}) *msgraph.AccessPackageLocalizedContent { result := msgraph.AccessPackageLocalizedContent{ - DefaultText: utils.String(input["default_text"].(string)), + DefaultText: pointer.To(input["default_text"].(string)), } texts := make([]msgraph.AccessPackageLocalizedTexts, 0) @@ -313,8 +313,8 @@ func expandAccessPackageLocalizedContent(input map[string]interface{}) *msgraph. for _, v := range input["localized_text"].([]interface{}) { v_map := v.(map[string]interface{}) texts = append(texts, msgraph.AccessPackageLocalizedTexts{ - LanguageCode: utils.String(v_map["language_code"].(string)), - Text: utils.String(v_map["content"].(string)), + LanguageCode: pointer.To(v_map["language_code"].(string)), + Text: pointer.To(v_map["content"].(string)), }) } diff --git a/internal/services/invitations/invitation_resource.go b/internal/services/invitations/invitation_resource.go index 786a4ed545..57f1d379aa 100644 --- a/internal/services/invitations/invitation_resource.go +++ b/internal/services/invitations/invitation_resource.go @@ -11,13 +11,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/helpers" "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" ) @@ -129,17 +129,17 @@ func invitationResourceCreate(ctx context.Context, d *pluginsdk.ResourceData, me usersClient := meta.(*clients.Client).Invitations.UsersClient properties := msgraph.Invitation{ - InvitedUserEmailAddress: utils.String(d.Get("user_email_address").(string)), - InviteRedirectURL: utils.String(d.Get("redirect_url").(string)), - InvitedUserType: utils.String(d.Get("user_type").(string)), + InvitedUserEmailAddress: pointer.To(d.Get("user_email_address").(string)), + InviteRedirectURL: pointer.To(d.Get("redirect_url").(string)), + InvitedUserType: pointer.To(d.Get("user_type").(string)), } if v, ok := d.GetOk("user_display_name"); ok { - properties.InvitedUserDisplayName = utils.String(v.(string)) + properties.InvitedUserDisplayName = pointer.To(v.(string)) } if v, ok := d.GetOk("message"); ok { - properties.SendInvitationMessage = utils.Bool(true) + properties.SendInvitationMessage = pointer.To(true) properties.InvitedUserMessageInfo = expandInvitedUserMessageInfo(v.([]interface{})) } @@ -169,7 +169,7 @@ func invitationResourceCreate(ctx context.Context, d *pluginsdk.ResourceData, me DirectoryObject: msgraph.DirectoryObject{ Id: invitation.InvitedUser.ID(), }, - CompanyName: utils.NullableString("TERRAFORM_UPDATE"), + CompanyName: tf.NullableString("TERRAFORM_UPDATE"), }) if err != nil { if status == http.StatusNotFound { @@ -181,7 +181,7 @@ func invitationResourceCreate(ctx context.Context, d *pluginsdk.ResourceData, me DirectoryObject: msgraph.DirectoryObject{ Id: invitation.InvitedUser.ID(), }, - CompanyName: utils.NullableString(""), + CompanyName: tf.NullableString(""), }) if err != nil { if status == http.StatusNotFound { @@ -239,11 +239,11 @@ func invitationResourceDelete(ctx context.Context, d *pluginsdk.ResourceData, me client.BaseClient.DisableRetries = true if _, status, err := client.Get(ctx, userID, 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 invited user with object ID %q", userID) } diff --git a/internal/services/invitations/invitation_resource_test.go b/internal/services/invitations/invitation_resource_test.go index 3a99c03533..3636abe061 100644 --- a/internal/services/invitations/invitation_resource_test.go +++ b/internal/services/invitations/invitation_resource_test.go @@ -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 InvitationResource struct{} @@ -154,7 +154,7 @@ func (r InvitationResource) Exists(ctx context.Context, clients *clients.Client, return nil, fmt.Errorf("failed to retrieve invited user with object ID %q: %+v", userID, err) } - return utils.Bool(user.ID() != nil && *user.ID() == userID), nil + return pointer.To(user.ID() != nil && *user.ID() == userID), nil } func (InvitationResource) basic(data acceptance.TestData) string { diff --git a/internal/services/policies/claims_mapping_policy_resource.go b/internal/services/policies/claims_mapping_policy_resource.go index 0d925e8abf..cc736cf375 100644 --- a/internal/services/policies/claims_mapping_policy_resource.go +++ b/internal/services/policies/claims_mapping_policy_resource.go @@ -9,12 +9,12 @@ import ( "log" "net/http" + "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" "github.com/hashicorp/terraform-provider-azuread/internal/tf" "github.com/hashicorp/terraform-provider-azuread/internal/tf/pluginsdk" - "github.com/hashicorp/terraform-provider-azuread/internal/utils" "github.com/manicminer/hamilton/msgraph" ) @@ -56,7 +56,7 @@ func claimsMappingPolicyResourceCreate(ctx context.Context, d *pluginsdk.Resourc claimsMappingPolicy := msgraph.ClaimsMappingPolicy{ Definition: tf.ExpandStringSlicePtr(d.Get("definition").([]interface{})), - DisplayName: utils.String(d.Get("display_name").(string)), + DisplayName: pointer.To(d.Get("display_name").(string)), } policy, _, err := client.Create(ctx, claimsMappingPolicy) if err != nil { @@ -102,7 +102,7 @@ func claimsMappingPolicyResourceUpdate(ctx context.Context, d *pluginsdk.Resourc Id: &objectId, }, Definition: tf.ExpandStringSlicePtr(d.Get("definition").([]interface{})), - DisplayName: utils.String(d.Get("display_name").(string)), + DisplayName: pointer.To(d.Get("display_name").(string)), } _, err := client.Update(ctx, claimsMappingPolicy) if err != nil { diff --git a/internal/services/serviceprincipals/service_principal_certificate_resource.go b/internal/services/serviceprincipals/service_principal_certificate_resource.go index 1cef63e58c..b77e3352d6 100644 --- a/internal/services/serviceprincipals/service_principal_certificate_resource.go +++ b/internal/services/serviceprincipals/service_principal_certificate_resource.go @@ -12,6 +12,7 @@ import ( "strings" "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" @@ -19,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" ) @@ -304,10 +304,10 @@ func servicePrincipalCertificateResourceDelete(ctx context.Context, d *pluginsdk credential := helpers.GetKeyCredential(servicePrincipal.KeyCredentials, id.KeyId) if credential == nil { - return utils.Bool(false), nil + return pointer.To(false), nil } - return utils.Bool(true), nil + return pointer.To(true), nil }); err != nil { return tf.ErrorDiagF(err, "Waiting for deletion of certificate credential %q from service principal with object ID %q", id.KeyId, id.ObjectId) } diff --git a/internal/services/serviceprincipals/service_principal_certificate_resource_test.go b/internal/services/serviceprincipals/service_principal_certificate_resource_test.go index 08d134b803..f4460c24ef 100644 --- a/internal/services/serviceprincipals/service_principal_certificate_resource_test.go +++ b/internal/services/serviceprincipals/service_principal_certificate_resource_test.go @@ -10,13 +10,13 @@ import ( "testing" "time" + "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/serviceprincipals/parse" - "github.com/hashicorp/terraform-provider-azuread/internal/utils" ) // To create test certificates: @@ -191,7 +191,7 @@ func (r ServicePrincipalCertificateResource) Exists(ctx context.Context, clients if servicePrincipal.KeyCredentials != nil { for _, cred := range *servicePrincipal.KeyCredentials { if cred.KeyId != nil && *cred.KeyId == id.KeyId { - return utils.Bool(true), nil + return pointer.To(true), nil } } } diff --git a/internal/services/serviceprincipals/service_principal_claims_mapping_policy_assignment_resource.go b/internal/services/serviceprincipals/service_principal_claims_mapping_policy_assignment_resource.go index 66158f9203..2e07da854e 100644 --- a/internal/services/serviceprincipals/service_principal_claims_mapping_policy_assignment_resource.go +++ b/internal/services/serviceprincipals/service_principal_claims_mapping_policy_assignment_resource.go @@ -9,12 +9,12 @@ import ( "log" "net/http" + "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/serviceprincipals/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/utils" "github.com/manicminer/hamilton/msgraph" ) @@ -55,12 +55,12 @@ func servicePrincipalClaimsMappingPolicyAssignmentResourceCreate(ctx context.Con properties := msgraph.ServicePrincipal{ DirectoryObject: msgraph.DirectoryObject{ - Id: utils.String(d.Get("service_principal_id").(string)), + Id: pointer.To(d.Get("service_principal_id").(string)), }, ClaimsMappingPolicies: &[]msgraph.ClaimsMappingPolicy{ { DirectoryObject: msgraph.DirectoryObject{ - ODataId: (*odata.Id)(utils.String(fmt.Sprintf("%s/v1.0/%s/directoryObjects/%s", + ODataId: (*odata.Id)(pointer.To(fmt.Sprintf("%s/v1.0/%s/directoryObjects/%s", client.BaseClient.Endpoint, tenantId, policyId))), Id: &policyId, }, diff --git a/internal/services/serviceprincipals/service_principal_claims_mapping_policy_assignment_resource_test.go b/internal/services/serviceprincipals/service_principal_claims_mapping_policy_assignment_resource_test.go index e6c163d903..838ddab0a8 100644 --- a/internal/services/serviceprincipals/service_principal_claims_mapping_policy_assignment_resource_test.go +++ b/internal/services/serviceprincipals/service_principal_claims_mapping_policy_assignment_resource_test.go @@ -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/serviceprincipals/parse" - "github.com/hashicorp/terraform-provider-azuread/internal/utils" ) type ServicePrincipalClaimsMappingPolicyAssignmentResource struct{} @@ -70,17 +70,17 @@ func (r ServicePrincipalClaimsMappingPolicyAssignmentResource) Exists(ctx contex policyList, status, err := client.ListClaimsMappingPolicy(ctx, id.ServicePrincipalId) if err != nil { if status == http.StatusNotFound { - return utils.Bool(false), fmt.Errorf("Service Policy with object ID %q does not exist", id.ServicePrincipalId) + return pointer.To(false), fmt.Errorf("Service Policy with object ID %q does not exist", id.ServicePrincipalId) } - return utils.Bool(false), fmt.Errorf("failed to retrieve claims mapping policy assignments with service policy ID %q: %+v", id.ServicePrincipalId, err) + return pointer.To(false), fmt.Errorf("failed to retrieve claims mapping policy assignments with service policy ID %q: %+v", id.ServicePrincipalId, err) } // Check the assignment is found in the currently assigned policies for _, policy := range *policyList { if policy.ID() != nil && *policy.ID() == id.ClaimsMappingPolicyId { - return utils.Bool(true), nil + return pointer.To(true), nil } } - return utils.Bool(false), nil + return pointer.To(false), nil } diff --git a/internal/services/serviceprincipals/service_principal_delegated_permission_grant_resource.go b/internal/services/serviceprincipals/service_principal_delegated_permission_grant_resource.go index 1a6a25d8f9..35ec9a1441 100644 --- a/internal/services/serviceprincipals/service_principal_delegated_permission_grant_resource.go +++ b/internal/services/serviceprincipals/service_principal_delegated_permission_grant_resource.go @@ -11,12 +11,12 @@ 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/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" ) @@ -102,16 +102,16 @@ func servicePrincipalDelegatedPermissionGrantResourceCreate(ctx context.Context, } properties := msgraph.DelegatedPermissionGrant{ - ClientId: utils.String(servicePrincipalId), - ResourceId: utils.String(resourceId), + ClientId: pointer.To(servicePrincipalId), + ResourceId: pointer.To(resourceId), Scopes: tf.ExpandStringSlicePtr(d.Get("claim_values").(*pluginsdk.Set).List()), } if v, ok := d.GetOk("user_object_id"); ok && v.(string) != "" { - properties.PrincipalId = utils.String(v.(string)) - properties.ConsentType = utils.String(msgraph.DelegatedPermissionGrantConsentTypePrincipal) + properties.PrincipalId = pointer.To(v.(string)) + properties.ConsentType = pointer.To(msgraph.DelegatedPermissionGrantConsentTypePrincipal) } else { - properties.ConsentType = utils.String(msgraph.DelegatedPermissionGrantConsentTypeAllPrincipals) + properties.ConsentType = pointer.To(msgraph.DelegatedPermissionGrantConsentTypeAllPrincipals) } delegatedPermissionGrant, _, err := client.Create(ctx, properties) @@ -132,7 +132,7 @@ func servicePrincipalDelegatedPermissionGrantResourceUpdate(ctx context.Context, client := meta.(*clients.Client).ServicePrincipals.DelegatedPermissionGrantsClient properties := msgraph.DelegatedPermissionGrant{ - Id: utils.String(d.Id()), + Id: pointer.To(d.Id()), Scopes: tf.ExpandStringSlicePtr(d.Get("claim_values").(*pluginsdk.Set).List()), } diff --git a/internal/services/serviceprincipals/service_principal_delegated_permission_grant_resource_test.go b/internal/services/serviceprincipals/service_principal_delegated_permission_grant_resource_test.go index b54c380024..81c5700489 100644 --- a/internal/services/serviceprincipals/service_principal_delegated_permission_grant_resource_test.go +++ b/internal/services/serviceprincipals/service_principal_delegated_permission_grant_resource_test.go @@ -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 ServicePrincipalDelegatedPermissionGrantResource struct{} @@ -61,7 +61,7 @@ func (r ServicePrincipalDelegatedPermissionGrantResource) Exists(ctx context.Con return nil, fmt.Errorf("failed to retrieve Delegated Permission Grant with ID %q: %+v", state.ID, err) } - return utils.Bool(true), nil + return pointer.To(true), nil } func (r ServicePrincipalDelegatedPermissionGrantResource) template(data acceptance.TestData) string { diff --git a/internal/services/serviceprincipals/service_principal_password_resource.go b/internal/services/serviceprincipals/service_principal_password_resource.go index 86b350283d..9994a91702 100644 --- a/internal/services/serviceprincipals/service_principal_password_resource.go +++ b/internal/services/serviceprincipals/service_principal_password_resource.go @@ -12,6 +12,7 @@ import ( "strings" "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" @@ -20,7 +21,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" ) func servicePrincipalPasswordResource() *pluginsdk.Resource { @@ -280,10 +280,10 @@ func servicePrincipalPasswordResourceDelete(ctx context.Context, d *pluginsdk.Re credential := helpers.GetPasswordCredential(servicePrincipal.PasswordCredentials, id.KeyId) if credential == nil { - return utils.Bool(false), nil + return pointer.To(false), nil } - return utils.Bool(true), nil + return pointer.To(true), nil }); err != nil { return tf.ErrorDiagF(err, "Waiting for deletion of password credential %q from service principal with object ID %q", id.KeyId, id.ObjectId) } diff --git a/internal/services/serviceprincipals/service_principal_password_resource_test.go b/internal/services/serviceprincipals/service_principal_password_resource_test.go index 1831f0f255..9a8d8b0f1c 100644 --- a/internal/services/serviceprincipals/service_principal_password_resource_test.go +++ b/internal/services/serviceprincipals/service_principal_password_resource_test.go @@ -10,13 +10,13 @@ import ( "testing" "time" + "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/serviceprincipals/parse" - "github.com/hashicorp/terraform-provider-azuread/internal/utils" ) type ServicePrincipalPasswordResource struct{} @@ -99,7 +99,7 @@ func (r ServicePrincipalPasswordResource) Exists(ctx context.Context, clients *c if servicePrincipal.PasswordCredentials != nil { for _, cred := range *servicePrincipal.PasswordCredentials { if cred.KeyId != nil && *cred.KeyId == id.KeyId { - return utils.Bool(true), nil + return pointer.To(true), nil } } } diff --git a/internal/services/serviceprincipals/service_principal_token_signing_certificate_resource.go b/internal/services/serviceprincipals/service_principal_token_signing_certificate_resource.go index 37b5a30579..e3abb4a993 100644 --- a/internal/services/serviceprincipals/service_principal_token_signing_certificate_resource.go +++ b/internal/services/serviceprincipals/service_principal_token_signing_certificate_resource.go @@ -13,6 +13,7 @@ import ( "strings" "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" @@ -20,7 +21,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" ) @@ -103,7 +103,7 @@ func servicePrincipalTokenSigningCertificateResourceCreate(ctx context.Context, keyCreds := msgraph.KeyCredential{} if v, ok := d.GetOk("display_name"); ok { - keyCreds.DisplayName = utils.String(v.(string)) + keyCreds.DisplayName = pointer.To(v.(string)) } if v, ok := d.GetOk("end_date"); ok { @@ -299,10 +299,10 @@ func servicePrincipalTokenSigningCertificateResourceDelete(ctx context.Context, credential := helpers.GetKeyCredential(servicePrincipal.KeyCredentials, id.KeyId) if credential == nil { - return utils.Bool(false), nil + return pointer.To(false), nil } - return utils.Bool(true), nil + return pointer.To(true), nil }); err != nil { return tf.ErrorDiagF(err, "Waiting for deletion of token signing certificate credential %q from service principal with object ID %q", id.KeyId, id.ObjectId) } diff --git a/internal/services/serviceprincipals/service_principal_token_signing_certificate_resource_test.go b/internal/services/serviceprincipals/service_principal_token_signing_certificate_resource_test.go index 68598fb273..bf50bb4351 100644 --- a/internal/services/serviceprincipals/service_principal_token_signing_certificate_resource_test.go +++ b/internal/services/serviceprincipals/service_principal_token_signing_certificate_resource_test.go @@ -10,13 +10,13 @@ import ( "testing" "time" + "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/serviceprincipals/parse" - "github.com/hashicorp/terraform-provider-azuread/internal/utils" ) type servicePrincipalTokenSigningCertificateResource struct{} @@ -83,7 +83,7 @@ func (r servicePrincipalTokenSigningCertificateResource) Exists(ctx context.Cont if servicePrincipal.KeyCredentials != nil { for _, cred := range *servicePrincipal.KeyCredentials { if cred.KeyId != nil && *cred.KeyId == id.KeyId { - return utils.Bool(true), nil + return pointer.To(true), nil } } } diff --git a/internal/services/serviceprincipals/serviceprincipals.go b/internal/services/serviceprincipals/serviceprincipals.go index 22db232205..14bac2a223 100644 --- a/internal/services/serviceprincipals/serviceprincipals.go +++ b/internal/services/serviceprincipals/serviceprincipals.go @@ -13,8 +13,8 @@ import ( "strings" "time" + "github.com/hashicorp/go-azure-helpers/lang/pointer" "github.com/hashicorp/go-azure-sdk/sdk/odata" - "github.com/hashicorp/terraform-provider-azuread/internal/utils" "github.com/manicminer/hamilton/msgraph" ) @@ -26,7 +26,7 @@ func expandSamlSingleSignOn(in []interface{}) *msgraph.SamlSingleSignOnSettings samlSingleSignOnSettings := in[0].(map[string]interface{}) - result.RelayState = utils.String(samlSingleSignOnSettings["relay_state"].(string)) + result.RelayState = pointer.To(samlSingleSignOnSettings["relay_state"].(string)) return &result } diff --git a/internal/services/serviceprincipals/synchronization.go b/internal/services/serviceprincipals/synchronization.go index b914d014e7..84780f6712 100644 --- a/internal/services/serviceprincipals/synchronization.go +++ b/internal/services/serviceprincipals/synchronization.go @@ -6,7 +6,7 @@ package serviceprincipals import ( "time" - "github.com/hashicorp/terraform-provider-azuread/internal/utils" + "github.com/hashicorp/go-azure-helpers/lang/pointer" "github.com/manicminer/hamilton/msgraph" ) @@ -20,8 +20,8 @@ func emptySynchronizationSecretKeyStringValuePair(in []interface{}) *[]msgraph.S item := raw.(map[string]interface{}) result = append(result, msgraph.SynchronizationSecretKeyStringValuePair{ - Key: utils.String(item["key"].(string)), - Value: utils.String(""), + Key: pointer.To(item["key"].(string)), + Value: pointer.To(""), }) } @@ -38,8 +38,8 @@ func expandSynchronizationSecretKeyStringValuePair(in []interface{}) *[]msgraph. item := raw.(map[string]interface{}) result = append(result, msgraph.SynchronizationSecretKeyStringValuePair{ - Key: utils.String(item["key"].(string)), - Value: utils.String(item["value"].(string)), + Key: pointer.To(item["key"].(string)), + Value: pointer.To(item["value"].(string)), }) } @@ -78,7 +78,7 @@ func flattenSynchronizationSecretKeyStringValuePair(in *[]msgraph.Synchronizatio } currentItem := raw.(map[string]interface{}) if currentItem["key"].(string) == *item.Key { - value = utils.String(currentItem["value"].(string)) + value = pointer.To(currentItem["value"].(string)) } } } diff --git a/internal/services/serviceprincipals/synchronization_job_resource.go b/internal/services/serviceprincipals/synchronization_job_resource.go index 65d82c5f3b..abc635d9bc 100644 --- a/internal/services/serviceprincipals/synchronization_job_resource.go +++ b/internal/services/serviceprincipals/synchronization_job_resource.go @@ -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/terraform-provider-azuread/internal/clients" "github.com/hashicorp/terraform-provider-azuread/internal/helpers" @@ -18,7 +19,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" ) @@ -111,7 +111,7 @@ func synchronizationJobResourceCreate(ctx context.Context, d *pluginsdk.Resource // Create a new synchronization job synchronizationJob := msgraph.SynchronizationJob{ - TemplateId: utils.String(d.Get("template_id").(string)), + TemplateId: pointer.To(d.Get("template_id").(string)), } newJob, _, err := client.Create(ctx, synchronizationJob, *servicePrincipal.ID()) @@ -232,10 +232,10 @@ func synchronizationJobResourceDelete(ctx context.Context, d *pluginsdk.Resource job, _, _ := client.Get(ctx, id.JobId, id.ServicePrincipalId) if job == nil { - return utils.Bool(false), nil + return pointer.To(false), nil } - return utils.Bool(true), nil + return pointer.To(true), nil }); err != nil { return tf.ErrorDiagF(err, "Waiting for deletion of synchronization job %q from service principal with object ID %q", id.JobId, id.ServicePrincipalId) } diff --git a/internal/services/serviceprincipals/synchronization_job_resource_test.go b/internal/services/serviceprincipals/synchronization_job_resource_test.go index 1f85766c09..987191fab0 100644 --- a/internal/services/serviceprincipals/synchronization_job_resource_test.go +++ b/internal/services/serviceprincipals/synchronization_job_resource_test.go @@ -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/serviceprincipals/parse" - "github.com/hashicorp/terraform-provider-azuread/internal/utils" ) type SynchronizationJobResource struct{} @@ -70,7 +70,7 @@ func (r SynchronizationJobResource) Exists(ctx context.Context, clients *clients } return nil, fmt.Errorf("Retrieving synchronization job with object ID %q", id.JobId) } - return utils.Bool(true), nil + return pointer.To(true), nil } func (SynchronizationJobResource) template(data acceptance.TestData) string { diff --git a/internal/services/serviceprincipals/synchronization_secret_resource.go b/internal/services/serviceprincipals/synchronization_secret_resource.go index 290fc4cb47..95de8cbee6 100644 --- a/internal/services/serviceprincipals/synchronization_secret_resource.go +++ b/internal/services/serviceprincipals/synchronization_secret_resource.go @@ -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/terraform-provider-azuread/internal/clients" "github.com/hashicorp/terraform-provider-azuread/internal/helpers" @@ -18,7 +19,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" ) @@ -203,10 +203,10 @@ func synchronizationSecretResourceDelete(ctx context.Context, d *pluginsdk.Resou // Test if credentials are removed if allCredentialsRemoved(*credentials, *synchronizationSecrets.Credentials) { - return utils.Bool(false), nil + return pointer.To(false), nil } - return utils.Bool(true), nil + return pointer.To(true), nil }); err != nil { return tf.ErrorDiagF(err, "Waiting for deletion of synchronization secrets from service principal with object ID %q", id.ServicePrincipalId) } diff --git a/internal/services/serviceprincipals/synchronization_secret_resource_test.go b/internal/services/serviceprincipals/synchronization_secret_resource_test.go index be493d4d64..058b3b7a2c 100644 --- a/internal/services/serviceprincipals/synchronization_secret_resource_test.go +++ b/internal/services/serviceprincipals/synchronization_secret_resource_test.go @@ -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/serviceprincipals/parse" - "github.com/hashicorp/terraform-provider-azuread/internal/utils" ) type SynchronizationSecretResource struct{} @@ -55,7 +55,7 @@ func (r SynchronizationSecretResource) Exists(ctx context.Context, clients *clie } return nil, fmt.Errorf("Retrieving synchronization secrets for service principal %q", id.ServicePrincipalId) } - return utils.Bool(true), nil + return pointer.To(true), nil } func (SynchronizationSecretResource) template(data acceptance.TestData) string { diff --git a/internal/services/userflows/user_flow_attribute_resource.go b/internal/services/userflows/user_flow_attribute_resource.go index 6381002d33..cdc4dbd8d9 100644 --- a/internal/services/userflows/user_flow_attribute_resource.go +++ b/internal/services/userflows/user_flow_attribute_resource.go @@ -12,13 +12,13 @@ import ( "strings" "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/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" ) @@ -90,9 +90,9 @@ func userFlowAttributeResourceCreate(ctx context.Context, d *pluginsdk.ResourceD } attr := msgraph.UserFlowAttribute{ - DataType: utils.String(d.Get("data_type").(string)), - Description: utils.String(d.Get("description").(string)), - DisplayName: utils.String(displayName), + DataType: pointer.To(d.Get("data_type").(string)), + Description: pointer.To(d.Get("description").(string)), + DisplayName: pointer.To(displayName), } userFlowAttr, _, err := client.Create(ctx, attr) @@ -114,8 +114,8 @@ func userFlowAttributeResourceUpdate(ctx context.Context, d *pluginsdk.ResourceD id := d.Id() attr := msgraph.UserFlowAttribute{ - ID: utils.String(id), - Description: utils.String(d.Get("description").(string)), + ID: pointer.To(id), + Description: pointer.To(d.Get("description").(string)), } if _, err := client.Update(ctx, attr); err != nil { @@ -170,11 +170,11 @@ func userFlowAttributeResourceDelete(ctx context.Context, d *pluginsdk.ResourceD client.BaseClient.DisableRetries = true if _, status, err := client.Get(ctx, id, 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 user flow attribute with ID %q", id) } diff --git a/internal/services/userflows/user_flow_attribute_resource_test.go b/internal/services/userflows/user_flow_attribute_resource_test.go index bc0487a3f9..73c4dee9df 100644 --- a/internal/services/userflows/user_flow_attribute_resource_test.go +++ b/internal/services/userflows/user_flow_attribute_resource_test.go @@ -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 UserflowAttributeResource struct{} @@ -82,7 +82,7 @@ func (r UserflowAttributeResource) Exists(ctx context.Context, clients *clients. return nil, fmt.Errorf("failed to retrieve User Flow attribute with ID %q: %+v", state.ID, err) } - return utils.Bool(userFlowAttr.ID != nil && *userFlowAttr.ID == state.ID), nil + return pointer.To(userFlowAttr.ID != nil && *userFlowAttr.ID == state.ID), nil } func (r UserflowAttributeResource) basic(data acceptance.TestData) string { diff --git a/internal/services/users/user_resource.go b/internal/services/users/user_resource.go index 33e9a774d5..3f544b470d 100644 --- a/internal/services/users/user_resource.go +++ b/internal/services/users/user_resource.go @@ -12,6 +12,7 @@ import ( "strings" "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" @@ -19,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" ) @@ -421,41 +421,41 @@ func userResourceCreate(ctx context.Context, d *pluginsdk.ResourceData, meta int } properties := msgraph.User{ - AccountEnabled: utils.Bool(d.Get("account_enabled").(bool)), - AgeGroup: utils.NullableString(d.Get("age_group").(string)), - City: utils.NullableString(d.Get("city").(string)), - ConsentProvidedForMinor: utils.NullableString(d.Get("consent_provided_for_minor").(string)), - CompanyName: utils.NullableString(d.Get("company_name").(string)), - Country: utils.NullableString(d.Get("country").(string)), - Department: utils.NullableString(d.Get("department").(string)), - DisplayName: utils.String(d.Get("display_name").(string)), - EmployeeId: utils.NullableString(d.Get("employee_id").(string)), + AccountEnabled: pointer.To(d.Get("account_enabled").(bool)), + AgeGroup: tf.NullableString(d.Get("age_group").(string)), + City: tf.NullableString(d.Get("city").(string)), + ConsentProvidedForMinor: tf.NullableString(d.Get("consent_provided_for_minor").(string)), + CompanyName: tf.NullableString(d.Get("company_name").(string)), + Country: tf.NullableString(d.Get("country").(string)), + Department: tf.NullableString(d.Get("department").(string)), + DisplayName: pointer.To(d.Get("display_name").(string)), + EmployeeId: tf.NullableString(d.Get("employee_id").(string)), EmployeeOrgData: &msgraph.EmployeeOrgData{ - CostCenter: utils.String(d.Get("cost_center").(string)), - Division: utils.String(d.Get("division").(string)), + CostCenter: pointer.To(d.Get("cost_center").(string)), + Division: pointer.To(d.Get("division").(string)), }, - EmployeeType: utils.NullableString(d.Get("employee_type").(string)), - FaxNumber: utils.NullableString(d.Get("fax_number").(string)), - GivenName: utils.NullableString(d.Get("given_name").(string)), - JobTitle: utils.NullableString(d.Get("job_title").(string)), - Mail: utils.NullableString(d.Get("mail").(string)), - MailNickname: utils.String(mailNickName), - MobilePhone: utils.NullableString(d.Get("mobile_phone").(string)), - OfficeLocation: utils.NullableString(d.Get("office_location").(string)), + EmployeeType: tf.NullableString(d.Get("employee_type").(string)), + FaxNumber: tf.NullableString(d.Get("fax_number").(string)), + GivenName: tf.NullableString(d.Get("given_name").(string)), + JobTitle: tf.NullableString(d.Get("job_title").(string)), + Mail: tf.NullableString(d.Get("mail").(string)), + MailNickname: pointer.To(mailNickName), + MobilePhone: tf.NullableString(d.Get("mobile_phone").(string)), + OfficeLocation: tf.NullableString(d.Get("office_location").(string)), OtherMails: tf.ExpandStringSlicePtr(d.Get("other_mails").(*pluginsdk.Set).List()), - PasswordPolicies: utils.NullableString(passwordPolicies), - PostalCode: utils.NullableString(d.Get("postal_code").(string)), - PreferredLanguage: utils.NullableString(d.Get("preferred_language").(string)), - ShowInAddressList: utils.Bool(d.Get("show_in_address_list").(bool)), - State: utils.NullableString(d.Get("state").(string)), - StreetAddress: utils.NullableString(d.Get("street_address").(string)), - Surname: utils.NullableString(d.Get("surname").(string)), - UsageLocation: utils.NullableString(d.Get("usage_location").(string)), - UserPrincipalName: utils.String(upn), + PasswordPolicies: tf.NullableString(passwordPolicies), + PostalCode: tf.NullableString(d.Get("postal_code").(string)), + PreferredLanguage: tf.NullableString(d.Get("preferred_language").(string)), + ShowInAddressList: pointer.To(d.Get("show_in_address_list").(bool)), + State: tf.NullableString(d.Get("state").(string)), + StreetAddress: tf.NullableString(d.Get("street_address").(string)), + Surname: tf.NullableString(d.Get("surname").(string)), + UsageLocation: tf.NullableString(d.Get("usage_location").(string)), + UserPrincipalName: pointer.To(upn), PasswordProfile: &msgraph.UserPasswordProfile{ - ForceChangePasswordNextSignIn: utils.Bool(d.Get("force_password_change").(bool)), - Password: utils.String(password), + ForceChangePasswordNextSignIn: pointer.To(d.Get("force_password_change").(bool)), + Password: pointer.To(password), }, } @@ -464,7 +464,7 @@ func userResourceCreate(ctx context.Context, d *pluginsdk.ResourceData, meta int } if v, ok := d.GetOk("onpremises_immutable_id"); ok { - properties.OnPremisesImmutableId = utils.String(v.(string)) + properties.OnPremisesImmutableId = pointer.To(v.(string)) } user, _, err := client.Create(ctx, properties) @@ -517,43 +517,43 @@ func userResourceUpdate(ctx context.Context, d *pluginsdk.ResourceData, meta int properties := msgraph.User{ DirectoryObject: msgraph.DirectoryObject{ - Id: utils.String(d.Id()), + Id: pointer.To(d.Id()), }, - AccountEnabled: utils.Bool(d.Get("account_enabled").(bool)), - AgeGroup: utils.NullableString(d.Get("age_group").(string)), - City: utils.NullableString(d.Get("city").(string)), - CompanyName: utils.NullableString(d.Get("company_name").(string)), - ConsentProvidedForMinor: utils.NullableString(d.Get("consent_provided_for_minor").(string)), - Country: utils.NullableString(d.Get("country").(string)), - Department: utils.NullableString(d.Get("department").(string)), - DisplayName: utils.String(d.Get("display_name").(string)), - EmployeeId: utils.NullableString(d.Get("employee_id").(string)), + AccountEnabled: pointer.To(d.Get("account_enabled").(bool)), + AgeGroup: tf.NullableString(d.Get("age_group").(string)), + City: tf.NullableString(d.Get("city").(string)), + CompanyName: tf.NullableString(d.Get("company_name").(string)), + ConsentProvidedForMinor: tf.NullableString(d.Get("consent_provided_for_minor").(string)), + Country: tf.NullableString(d.Get("country").(string)), + Department: tf.NullableString(d.Get("department").(string)), + DisplayName: pointer.To(d.Get("display_name").(string)), + EmployeeId: tf.NullableString(d.Get("employee_id").(string)), EmployeeOrgData: &msgraph.EmployeeOrgData{ - CostCenter: utils.String(d.Get("cost_center").(string)), - Division: utils.String(d.Get("division").(string)), + CostCenter: pointer.To(d.Get("cost_center").(string)), + Division: pointer.To(d.Get("division").(string)), }, - EmployeeType: utils.NullableString(d.Get("employee_type").(string)), - FaxNumber: utils.NullableString(d.Get("fax_number").(string)), - GivenName: utils.NullableString(d.Get("given_name").(string)), - JobTitle: utils.NullableString(d.Get("job_title").(string)), - MailNickname: utils.String(d.Get("mail_nickname").(string)), - MobilePhone: utils.NullableString(d.Get("mobile_phone").(string)), - OfficeLocation: utils.NullableString(d.Get("office_location").(string)), + EmployeeType: tf.NullableString(d.Get("employee_type").(string)), + FaxNumber: tf.NullableString(d.Get("fax_number").(string)), + GivenName: tf.NullableString(d.Get("given_name").(string)), + JobTitle: tf.NullableString(d.Get("job_title").(string)), + MailNickname: pointer.To(d.Get("mail_nickname").(string)), + MobilePhone: tf.NullableString(d.Get("mobile_phone").(string)), + OfficeLocation: tf.NullableString(d.Get("office_location").(string)), OtherMails: tf.ExpandStringSlicePtr(d.Get("other_mails").(*pluginsdk.Set).List()), - PasswordPolicies: utils.NullableString(passwordPolicies), - PostalCode: utils.NullableString(d.Get("postal_code").(string)), - PreferredLanguage: utils.NullableString(d.Get("preferred_language").(string)), - State: utils.NullableString(d.Get("state").(string)), - StreetAddress: utils.NullableString(d.Get("street_address").(string)), - Surname: utils.NullableString(d.Get("surname").(string)), - UsageLocation: utils.NullableString(d.Get("usage_location").(string)), - UserPrincipalName: utils.String(d.Get("user_principal_name").(string)), + PasswordPolicies: tf.NullableString(passwordPolicies), + PostalCode: tf.NullableString(d.Get("postal_code").(string)), + PreferredLanguage: tf.NullableString(d.Get("preferred_language").(string)), + State: tf.NullableString(d.Get("state").(string)), + StreetAddress: tf.NullableString(d.Get("street_address").(string)), + Surname: tf.NullableString(d.Get("surname").(string)), + UsageLocation: tf.NullableString(d.Get("usage_location").(string)), + UserPrincipalName: pointer.To(d.Get("user_principal_name").(string)), } if password := d.Get("password").(string); d.HasChange("password") && password != "" { properties.PasswordProfile = &msgraph.UserPasswordProfile{ - ForceChangePasswordNextSignIn: utils.Bool(d.Get("force_password_change").(bool)), - Password: utils.String(password), + ForceChangePasswordNextSignIn: pointer.To(d.Get("force_password_change").(bool)), + Password: pointer.To(password), } } @@ -563,16 +563,16 @@ func userResourceUpdate(ctx context.Context, d *pluginsdk.ResourceData, meta int if d.HasChange("mail") { if mail := d.Get("mail").(string); mail != "" { - properties.Mail = utils.NullableString(mail) + properties.Mail = tf.NullableString(mail) } } if d.HasChange("onpremises_immutable_id") { - properties.OnPremisesImmutableId = utils.String(d.Get("onpremises_immutable_id").(string)) + properties.OnPremisesImmutableId = pointer.To(d.Get("onpremises_immutable_id").(string)) } if d.HasChange("show_in_address_list") { - properties.ShowInAddressList = utils.Bool(d.Get("show_in_address_list").(bool)) + properties.ShowInAddressList = pointer.To(d.Get("show_in_address_list").(bool)) } if _, err := client.Update(ctx, properties); err != nil { @@ -706,11 +706,11 @@ func userResourceDelete(ctx context.Context, d *pluginsdk.ResourceData, meta int client.BaseClient.DisableRetries = true if _, status, err := client.Get(ctx, userId, 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 user with object ID %q", userId) } diff --git a/internal/services/users/user_resource_test.go b/internal/services/users/user_resource_test.go index cf1c2e8211..c6834a5f10 100644 --- a/internal/services/users/user_resource_test.go +++ b/internal/services/users/user_resource_test.go @@ -10,12 +10,12 @@ import ( "regexp" "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 UserResource struct{} @@ -139,7 +139,7 @@ func (r UserResource) Exists(ctx context.Context, clients *clients.Client, state } return nil, fmt.Errorf("failed to retrieve User with object ID %q: %+v", state.ID, err) } - return utils.Bool(user.ID() != nil && *user.ID() == state.ID), nil + return pointer.To(user.ID() != nil && *user.ID() == state.ID), nil } func (UserResource) basic(data acceptance.TestData) string { diff --git a/internal/services/users/users.go b/internal/services/users/users.go index 33e0799d8a..a395db11ca 100644 --- a/internal/services/users/users.go +++ b/internal/services/users/users.go @@ -8,8 +8,8 @@ import ( "errors" "fmt" + "github.com/hashicorp/go-azure-helpers/lang/pointer" "github.com/hashicorp/go-azure-sdk/sdk/odata" - "github.com/hashicorp/terraform-provider-azuread/internal/utils" "github.com/manicminer/hamilton/msgraph" ) @@ -22,7 +22,7 @@ func assignManager(ctx context.Context, client *msgraph.UsersClient, directoryOb if managerObject == nil { return errors.New("managerObject was nil") } - managerObject.ODataId = (*odata.Id)(utils.String(fmt.Sprintf("%s/v1.0/%s/directoryObjects/%s", + managerObject.ODataId = (*odata.Id)(pointer.To(fmt.Sprintf("%s/v1.0/%s/directoryObjects/%s", client.BaseClient.Endpoint, tenantId, managerId))) manager := msgraph.User{