Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Applications: DiffSuppressFunc for application_object_id #1221

Merged
merged 1 commit into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading