Skip to content

Commit

Permalink
fix state upgraders for azuread_directory_role_assignment and `azur…
Browse files Browse the repository at this point in the history
…ead_service_principal_delegated_permission_grant` - user segment is not a UUID
  • Loading branch information
manicminer committed Sep 27, 2024
1 parent 0fe9311 commit b384118
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ package migrations

import (
"context"
"fmt"
"log"

"github.com/hashicorp/go-azure-sdk/microsoft-graph/common-types/stable"
"github.com/hashicorp/go-uuid"
"github.com/hashicorp/terraform-provider-azuread/internal/helpers/tf/pluginsdk"
)

Expand Down Expand Up @@ -45,10 +43,6 @@ func ResourceDirectoryRoleAssignmentInstanceResourceV0() *pluginsdk.Resource {
func ResourceDirectoryRoleAssignmentInstanceStateUpgradeV0(_ context.Context, rawState map[string]interface{}, _ interface{}) (map[string]interface{}, error) {
log.Println("[DEBUG] Migrating ID from v0 to v1 format")
oldId := rawState["id"].(string)
if _, err := uuid.ParseUUID(oldId); err != nil {
return rawState, fmt.Errorf("parsing ID for `azuread_directory_role_assignment`: %+v", err)
}

newId := stable.NewRoleManagementDirectoryRoleAssignmentID(oldId)
rawState["id"] = newId.ID()
return rawState, nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ package migrations

import (
"context"
"fmt"
"log"

"github.com/hashicorp/go-azure-sdk/microsoft-graph/common-types/stable"
"github.com/hashicorp/go-uuid"
"github.com/hashicorp/terraform-provider-azuread/internal/helpers/tf/pluginsdk"
)

Expand Down Expand Up @@ -46,10 +44,6 @@ func ResourceServicePrincipalDelegatedPermissionGrantInstanceResourceV0() *plugi
func ResourceServicePrincipalDelegatedPermissionGrantInstanceStateUpgradeV0(_ context.Context, rawState map[string]interface{}, _ interface{}) (map[string]interface{}, error) {
log.Println("[DEBUG] Migrating ID from v0 to v1 format")
oldId := rawState["id"].(string)
if _, err := uuid.ParseUUID(oldId); err != nil {
return rawState, fmt.Errorf("parsing ID for `azuread_service_principal_delegated_permission_grant`: %+v", err)
}

newId := stable.NewOAuth2PermissionGrantID(oldId)
rawState["id"] = newId.ID()
return rawState, nil
Expand Down

0 comments on commit b384118

Please sign in to comment.