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

TestCase: Fix TC for Log Analytics #18205

Closed
wants to merge 8 commits into from
Closed
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 @@ -4,7 +4,6 @@ import (
"encoding/json"
"fmt"
"log"
"strings"
"time"

"github.com/hashicorp/go-azure-helpers/lang/response"
Expand Down Expand Up @@ -199,7 +198,7 @@ func flattenLogAnalyticsDataSourceWindowsEventEventType(eventTypes []dataSourceW
for _, e := range eventTypes {
// The casing isn't preserved by the API for event types, so we need to normalise it here until
// https://github.com/Azure/azure-rest-api-specs/issues/18163 is fixed
output = append(output, strings.ToLower(e.EventType))
output = append(output, e.EventType)
}
return output
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,23 @@ package loganalytics
import (
"fmt"
"log"
"strings"
"time"

"github.com/hashicorp/go-azure-helpers/lang/response"
"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/helpers/tf"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
"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"
"github.com/hashicorp/terraform-provider-azurerm/internal/timeouts"
"github.com/hashicorp/terraform-provider-azurerm/utils"
)

func resourceLogAnalyticsLinkedStorageAccount() *pluginsdk.Resource {
return &pluginsdk.Resource{
resource := &pluginsdk.Resource{
Create: resourceLogAnalyticsLinkedStorageAccountCreateUpdate,
Read: resourceLogAnalyticsLinkedStorageAccountRead,
Update: resourceLogAnalyticsLinkedStorageAccountCreateUpdate,
Expand All @@ -42,12 +43,11 @@ func resourceLogAnalyticsLinkedStorageAccount() *pluginsdk.Resource {
Required: true,
ForceNew: true,
ValidateFunc: validation.StringInSlice([]string{
strings.ToLower(string(linkedstorageaccounts.DataSourceTypeCustomLogs)),
strings.ToLower(string(linkedstorageaccounts.DataSourceTypeAzureWatson)),
strings.ToLower(string(linkedstorageaccounts.DataSourceTypeQuery)),
strings.ToLower(string(linkedstorageaccounts.DataSourceTypeAlerts)),
// Value removed from enum in 2020-08-01, but effectively still works
"ingestion",
string(linkedstorageaccounts.DataSourceTypeAlerts),
string(linkedstorageaccounts.DataSourceTypeAzureWatson),
string(linkedstorageaccounts.DataSourceTypeCustomLogs),
string(linkedstorageaccounts.DataSourceTypeIngestion),
string(linkedstorageaccounts.DataSourceTypeQuery),
}, false),
},

Expand All @@ -71,6 +71,25 @@ func resourceLogAnalyticsLinkedStorageAccount() *pluginsdk.Resource {
},
},
}

// TODO 4.0: remove this block to respect correct casing
if !features.FourPointOhBeta() {
resource.Schema["data_source_type"] = &pluginsdk.Schema{
Type: pluginsdk.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: validation.StringInSlice([]string{
string(linkedstorageaccounts.DataSourceTypeAlerts),
string(linkedstorageaccounts.DataSourceTypeAzureWatson),
string(linkedstorageaccounts.DataSourceTypeCustomLogs),
string(linkedstorageaccounts.DataSourceTypeIngestion),
string(linkedstorageaccounts.DataSourceTypeQuery),
}, true),
DiffSuppressFunc: suppress.CaseDifference,
}
}

return resource
}

func resourceLogAnalyticsLinkedStorageAccountCreateUpdate(d *pluginsdk.ResourceData, meta interface{}) error {
Expand Down