Skip to content

Commit

Permalink
Merge pull request #1221 from hashicorp/bugfix/application-object-id-…
Browse files Browse the repository at this point in the history
…breaking-diff

Applications: DiffSuppressFunc for `application_object_id`
  • Loading branch information
manicminer authored Oct 23, 2023
2 parents d25b6df + 68fa71d commit ad05a3f
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 0 deletions.
14 changes: 14 additions & 0 deletions internal/services/applications/application_certificate_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,20 @@ func applicationCertificateResource() *pluginsdk.Resource {
ExactlyOneOf: []string{"application_id", "application_object_id"},
Deprecated: "The `application_object_id` property has been replaced with the `application_id` property and will be removed in version 3.0 of the AzureAD provider",
ValidateFunc: validation.Any(validation.IsUUID, parse.ValidateApplicationID),
DiffSuppressFunc: func(_, oldValue, newValue string, _ *pluginsdk.ResourceData) bool {
// Where oldValue is a UUID (i.e. the bare object ID), and newValue is a properly formed application
// resource ID, we'll ignore a diff where these point to the same application resource.
// This maintains compatibility with configurations mixing the ID attributes, e.g.
// application_object_id = azuread_application.example.id
if _, err := uuid.ParseUUID(oldValue); err == nil {
if applicationId, err := parse.ParseApplicationID(newValue); err == nil {
if applicationId.ApplicationId == oldValue {
return true
}
}
}
return false
},
},

"encoding": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,20 @@ func applicationFederatedIdentityCredentialResource() *pluginsdk.Resource {
ExactlyOneOf: []string{"application_id", "application_object_id"},
Deprecated: "The `application_object_id` property has been replaced with the `application_id` property and will be removed in version 3.0 of the AzureAD provider",
ValidateFunc: validation.Any(validation.IsUUID, parse.ValidateApplicationID),
DiffSuppressFunc: func(_, oldValue, newValue string, _ *pluginsdk.ResourceData) bool {
// Where oldValue is a UUID (i.e. the bare object ID), and newValue is a properly formed application
// resource ID, we'll ignore a diff where these point to the same application resource.
// This maintains compatibility with configurations mixing the ID attributes, e.g.
// application_object_id = azuread_application.example.id
if _, err := uuid.ParseUUID(oldValue); err == nil {
if applicationId, err := parse.ParseApplicationID(newValue); err == nil {
if applicationId.ApplicationId == oldValue {
return true
}
}
}
return false
},
},

"audiences": {
Expand Down
14 changes: 14 additions & 0 deletions internal/services/applications/application_password_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,20 @@ func applicationPasswordResource() *pluginsdk.Resource {
ExactlyOneOf: []string{"application_id", "application_object_id"},
Deprecated: "The `application_object_id` property has been replaced with the `application_id` property and will be removed in version 3.0 of the AzureAD provider",
ValidateFunc: validation.Any(validation.IsUUID, parse.ValidateApplicationID),
DiffSuppressFunc: func(_, oldValue, newValue string, _ *pluginsdk.ResourceData) bool {
// Where oldValue is a UUID (i.e. the bare object ID), and newValue is a properly formed application
// resource ID, we'll ignore a diff where these point to the same application resource.
// This maintains compatibility with configurations mixing the ID attributes, e.g.
// application_object_id = azuread_application.example.id
if _, err := uuid.ParseUUID(oldValue); err == nil {
if applicationId, err := parse.ParseApplicationID(newValue); err == nil {
if applicationId.ApplicationId == oldValue {
return true
}
}
}
return false
},
},

"display_name": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,20 @@ func applicationPreAuthorizedResource() *pluginsdk.Resource {
ExactlyOneOf: []string{"application_id", "application_object_id"},
Deprecated: "The `application_object_id` property has been replaced with the `application_id` property and will be removed in version 3.0 of the AzureAD provider",
ValidateFunc: validation.Any(validation.IsUUID, parse.ValidateApplicationID),
DiffSuppressFunc: func(_, oldValue, newValue string, _ *pluginsdk.ResourceData) bool {
// Where oldValue is a UUID (i.e. the bare object ID), and newValue is a properly formed application
// resource ID, we'll ignore a diff where these point to the same application resource.
// This maintains compatibility with configurations mixing the ID attributes, e.g.
// application_object_id = azuread_application.example.id
if _, err := uuid.ParseUUID(oldValue); err == nil {
if applicationId, err := parse.ParseApplicationID(newValue); err == nil {
if applicationId.ApplicationId == oldValue {
return true
}
}
}
return false
},
},

"authorized_app_id": {
Expand Down

0 comments on commit ad05a3f

Please sign in to comment.