-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
azurerm_log_analytics_linked_storage_account
- fix data_source_type
case sensitivity
#18116
Merged
katbyte
merged 6 commits into
hashicorp:main
from
teowa:fix_log_analytics_linked_storage_account_dst
Sep 28, 2022
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
e0b857b
fix log_analytics_linked_storage_account data_source_type case sensit…
teowa a6d06d6
Merge branch 'main' of github.com:hashicorp/terraform-provider-azurer…
teowa b06c1a4
ignore case of data_source_type
teowa 82f6492
add 4.0 flag to ignore-case
teowa 4e65e45
read using id.dataSourceType
teowa f707d01
add state migration
teowa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
internal/services/loganalytics/migration/linked_storage_account_v0_to_v1.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package migration | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2020-08-01/linkedstorageaccounts" | ||
"github.com/hashicorp/terraform-provider-azurerm/helpers/azure" | ||
"github.com/hashicorp/terraform-provider-azurerm/internal/features" | ||
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" | ||
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/suppress" | ||
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" | ||
) | ||
|
||
var _ pluginsdk.StateUpgrade = LinkedStorageAccountV0ToV1{} | ||
|
||
type LinkedStorageAccountV0ToV1 struct{} | ||
|
||
func (LinkedStorageAccountV0ToV1) UpgradeFunc() pluginsdk.StateUpgraderFunc { | ||
return func(ctx context.Context, rawState map[string]interface{}, meta interface{}) (map[string]interface{}, error) { | ||
oldId, err := linkedstorageaccounts.ParseDataSourceTypeIDInsensitively(rawState["id"].(string)) | ||
if err != nil { | ||
return rawState, err | ||
} | ||
|
||
rawState["id"] = oldId.ID() | ||
return rawState, nil | ||
} | ||
} | ||
|
||
func (LinkedStorageAccountV0ToV1) Schema() map[string]*pluginsdk.Schema { | ||
schema := map[string]*pluginsdk.Schema{ | ||
"data_source_type": { | ||
Type: pluginsdk.TypeString, | ||
Required: true, | ||
ForceNew: true, | ||
ValidateFunc: validation.StringInSlice([]string{ | ||
string(linkedstorageaccounts.DataSourceTypeCustomLogs), | ||
string(linkedstorageaccounts.DataSourceTypeAzureWatson), | ||
string(linkedstorageaccounts.DataSourceTypeQuery), | ||
string(linkedstorageaccounts.DataSourceTypeAlerts), | ||
string(linkedstorageaccounts.DataSourceTypeIngestion), | ||
}, !features.FourPointOhBeta()), | ||
}, | ||
|
||
"resource_group_name": azure.SchemaResourceGroupName(), | ||
|
||
"workspace_resource_id": { | ||
Type: pluginsdk.TypeString, | ||
Required: true, | ||
ForceNew: true, | ||
ValidateFunc: linkedstorageaccounts.ValidateWorkspaceID, | ||
}, | ||
|
||
"storage_account_ids": { | ||
Type: pluginsdk.TypeSet, | ||
Required: true, | ||
MinItems: 1, | ||
Elem: &pluginsdk.Schema{ | ||
Type: pluginsdk.TypeString, | ||
ValidateFunc: azure.ValidateResourceID, | ||
}, | ||
}, | ||
} | ||
|
||
if !features.FourPointOh() { | ||
schema["data_source_type"].DiffSuppressFunc = suppress.CaseDifference | ||
} | ||
return schema | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since this is part of the id, we might want to do a state migration so we can remove the parse insensitively above?