From 7febf23067481dc794010575e14ea58b3fa430c7 Mon Sep 17 00:00:00 2001 From: kt Date: Wed, 7 Dec 2022 17:46:28 -0800 Subject: [PATCH] post mege cleanup --- .golangci.yml | 2 +- ..._gateway_certificate_authority_resource.go | 4 +-- .../cognitive_account_resource_test.go | 19 -------------- .../registry_webhook_migration_v0_to_v1.go | 2 +- .../services/digitaltwins/client/client.go | 2 +- .../media_content_key_policy_resource.go | 22 +++++----------- .../mssql_managed_instance_data_source.go | 2 +- ...ce_transparent_data_encryption_resource.go | 2 +- ...entinel_alert_rule_template_data_source.go | 10 +++---- .../stream_analytics_reference_input.go | 3 ++- ...analytics_reference_input_blob_resource.go | 2 +- ...nalytics_reference_input_mssql_resource.go | 2 +- ...ics_reference_input_mssql_resource_test.go | 26 ------------------- ...am_analytics_stream_input_blob_resource.go | 6 ++--- ...nalytics_stream_input_eventhub_resource.go | 2 +- ...ytics_stream_input_eventhub_v2_resource.go | 4 +-- ..._analytics_stream_input_iothub_resource.go | 2 +- 17 files changed, 29 insertions(+), 83 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index af5b9220abd2..23d93685d83d 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -35,7 +35,7 @@ linters: - unparam - vet - vetshadow - - wastedassign + # - wastedassign # disabled because of generics # - whitespace # Disabled for performance reasons - Ignores cache and takes 12+ minutes to run on the repo for _any_ change linters-settings: diff --git a/internal/services/apimanagement/api_management_gateway_certificate_authority_resource.go b/internal/services/apimanagement/api_management_gateway_certificate_authority_resource.go index c2fe787ebdeb..e2af027a0c3b 100644 --- a/internal/services/apimanagement/api_management_gateway_certificate_authority_resource.go +++ b/internal/services/apimanagement/api_management_gateway_certificate_authority_resource.go @@ -86,12 +86,12 @@ func resourceApiManagementGatewayCertificateAuthorityCreateUpdate(d *pluginsdk.R }, } - resp, err := client.CreateOrUpdate(ctx, id.ResourceGroup, id.ServiceName, d.Get("gateway_name").(string), d.Get("certificate_name").(string), parameters, "") + _, err = client.CreateOrUpdate(ctx, id.ResourceGroup, id.ServiceName, d.Get("gateway_name").(string), d.Get("certificate_name").(string), parameters, "") if err != nil { return fmt.Errorf("creating or updating %s: %+v", id, err) } - d.SetId(*resp.ID) + d.SetId(id.ID()) return resourceApiManagementGatewayCertificateAuthorityRead(d, meta) } diff --git a/internal/services/cognitive/cognitive_account_resource_test.go b/internal/services/cognitive/cognitive_account_resource_test.go index f7a9da70fb59..3be2b569c776 100644 --- a/internal/services/cognitive/cognitive_account_resource_test.go +++ b/internal/services/cognitive/cognitive_account_resource_test.go @@ -789,25 +789,6 @@ resource "azurerm_cognitive_account" "test" { `, data.RandomInteger, data.Locations.Primary, data.RandomInteger) } -func (CognitiveAccountResource) openAI(data acceptance.TestData) string { - return fmt.Sprintf(` -provider "azurerm" { - features {} -} -resource "azurerm_resource_group" "test" { - name = "acctestRG-cognitive-%d" - location = "%s" -} -resource "azurerm_cognitive_account" "test" { - name = "acctestcogacc-%d" - location = azurerm_resource_group.test.location - resource_group_name = azurerm_resource_group.test.name - kind = "OpenAI" - sku_name = "S0" -} -`, data.RandomInteger, data.Locations.Primary, data.RandomInteger) -} - func (CognitiveAccountResource) dynamicThrottlingEnabled(data acceptance.TestData) string { return fmt.Sprintf(` provider "azurerm" { diff --git a/internal/services/containers/migration/registry_webhook_migration_v0_to_v1.go b/internal/services/containers/migration/registry_webhook_migration_v0_to_v1.go index a18b27a0d121..8cb9dd7373b5 100644 --- a/internal/services/containers/migration/registry_webhook_migration_v0_to_v1.go +++ b/internal/services/containers/migration/registry_webhook_migration_v0_to_v1.go @@ -4,7 +4,7 @@ import ( "context" "log" - "github.com/Azure/azure-sdk-for-go/services/preview/containerregistry/mgmt/2021-08-01-preview/containerregistry" + "github.com/Azure/azure-sdk-for-go/services/preview/containerregistry/mgmt/2021-08-01-preview/containerregistry" // nolint: staticcheck "github.com/hashicorp/go-azure-helpers/resourcemanager/resourcegroups" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-provider-azurerm/internal/services/containers/parse" diff --git a/internal/services/digitaltwins/client/client.go b/internal/services/digitaltwins/client/client.go index 1c1df4f9889e..2d16220c2a09 100644 --- a/internal/services/digitaltwins/client/client.go +++ b/internal/services/digitaltwins/client/client.go @@ -1,7 +1,7 @@ package client import ( - "github.com/Azure/azure-sdk-for-go/services/digitaltwins/mgmt/2020-12-01/digitaltwins" + "github.com/Azure/azure-sdk-for-go/services/digitaltwins/mgmt/2020-12-01/digitaltwins" // nolint: staticcheck "github.com/hashicorp/go-azure-sdk/resource-manager/digitaltwins/2022-10-31/timeseriesdatabaseconnections" "github.com/hashicorp/terraform-provider-azurerm/internal/common" ) diff --git a/internal/services/media/media_content_key_policy_resource.go b/internal/services/media/media_content_key_policy_resource.go index 3df5e09e68ed..e03860babb01 100644 --- a/internal/services/media/media_content_key_policy_resource.go +++ b/internal/services/media/media_content_key_policy_resource.go @@ -552,11 +552,7 @@ func flattenPolicyOptions(input []contentkeypolicies.ContentKeyPolicyOption) ([] } if v, ok := option.Configuration.(contentkeypolicies.ContentKeyPolicyPlayReadyConfiguration); ok { - license, err := flattenPlayReadyLicenses(v.Licenses) - if err != nil { - return nil, err - } - playReadyLicense = license + playReadyLicense = flattenPlayReadyLicenses(v.Licenses) } if v, ok := option.Configuration.(contentkeypolicies.ContentKeyPolicyWidevineConfiguration); ok { @@ -569,11 +565,7 @@ func flattenPolicyOptions(input []contentkeypolicies.ContentKeyPolicyOption) ([] openRestrictionEnabled = true } if v, ok := option.Restriction.(contentkeypolicies.ContentKeyPolicyTokenRestriction); ok { - restriction, err := flattenTokenRestriction(v) - if err != nil { - return nil, err - } - tokenRestriction = restriction + tokenRestriction = flattenTokenRestriction(v) } results = append(results, map[string]interface{}{ @@ -643,7 +635,7 @@ func expandRestriction(option map[string]interface{}) (contentkeypolicies.Conten return nil, fmt.Errorf("policy_option must contain at least one type of restriction: open_restriction_enabled or token_restriction.") } -func flattenTokenRestriction(input contentkeypolicies.ContentKeyPolicyTokenRestriction) ([]interface{}, error) { +func flattenTokenRestriction(input contentkeypolicies.ContentKeyPolicyTokenRestriction) []interface{} { openIDConnectDiscoveryDocument := "" if input.OpenIdConnectDiscoveryDocument != nil { openIDConnectDiscoveryDocument = *input.OpenIdConnectDiscoveryDocument @@ -688,7 +680,7 @@ func flattenTokenRestriction(input contentkeypolicies.ContentKeyPolicyTokenRestr "primary_rsa_token_key_exponent": rsaTokenKeyExponent, "primary_rsa_token_key_modulus": rsaTokenKeyModulus, }, - }, nil + } } func expandConfiguration(input map[string]interface{}) (contentkeypolicies.ContentKeyPolicyConfiguration, error) { @@ -698,7 +690,7 @@ func expandConfiguration(input map[string]interface{}) (contentkeypolicies.Conte widevineConfigurationTemplate := input["widevine_configuration_template"].(string) configurationCount := 0 - if clearKeyConfigurationEnabled != false { + if clearKeyConfigurationEnabled { configurationCount++ } if len(fairPlayConfigurations) > 0 { @@ -1010,7 +1002,7 @@ func expandPlayReadyLicenses(input []interface{}) (*[]contentkeypolicies.Content return &results, nil } -func flattenPlayReadyLicenses(input []contentkeypolicies.ContentKeyPolicyPlayReadyLicense) ([]interface{}, error) { +func flattenPlayReadyLicenses(input []contentkeypolicies.ContentKeyPolicyPlayReadyLicense) []interface{} { results := make([]interface{}, 0) for _, v := range input { beginDate := "" @@ -1069,7 +1061,7 @@ func flattenPlayReadyLicenses(input []contentkeypolicies.ContentKeyPolicyPlayRea }) } - return results, nil + return results } func expandPlayRight(input []interface{}) *contentkeypolicies.ContentKeyPolicyPlayReadyPlayRight { diff --git a/internal/services/mssql/mssql_managed_instance_data_source.go b/internal/services/mssql/mssql_managed_instance_data_source.go index 1ee8c7acf106..afbcba361895 100644 --- a/internal/services/mssql/mssql_managed_instance_data_source.go +++ b/internal/services/mssql/mssql_managed_instance_data_source.go @@ -5,7 +5,7 @@ import ( "fmt" "time" - "github.com/Azure/azure-sdk-for-go/services/preview/sql/mgmt/v5.0/sql" + "github.com/Azure/azure-sdk-for-go/services/preview/sql/mgmt/v5.0/sql" // nolint: staticcheck "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" diff --git a/internal/services/mssql/mssql_managed_instance_transparent_data_encryption_resource.go b/internal/services/mssql/mssql_managed_instance_transparent_data_encryption_resource.go index 0dc7840a538b..3e649d9cfe29 100644 --- a/internal/services/mssql/mssql_managed_instance_transparent_data_encryption_resource.go +++ b/internal/services/mssql/mssql_managed_instance_transparent_data_encryption_resource.go @@ -7,7 +7,7 @@ import ( "strings" "time" - "github.com/Azure/azure-sdk-for-go/services/preview/sql/mgmt/v5.0/sql" + "github.com/Azure/azure-sdk-for-go/services/preview/sql/mgmt/v5.0/sql" // nolint: staticcheck "github.com/hashicorp/terraform-provider-azurerm/internal/clients" keyVaultParser "github.com/hashicorp/terraform-provider-azurerm/internal/services/keyvault/parse" keyVaultValidate "github.com/hashicorp/terraform-provider-azurerm/internal/services/keyvault/validate" diff --git a/internal/services/sentinel/sentinel_alert_rule_template_data_source.go b/internal/services/sentinel/sentinel_alert_rule_template_data_source.go index 4c8edaa1d25d..5ca7f4df3369 100644 --- a/internal/services/sentinel/sentinel_alert_rule_template_data_source.go +++ b/internal/services/sentinel/sentinel_alert_rule_template_data_source.go @@ -173,9 +173,9 @@ func dataSourceSentinelAlertRuleTemplateRead(d *pluginsdk.ResourceData, meta int switch template := resp.(type) { case securityinsight.MLBehaviorAnalyticsAlertRuleTemplate: - err = setForMLBehaviorAnalyticsAlertRuleTemplate(d, id, &template) + setForMLBehaviorAnalyticsAlertRuleTemplate(d, id, &template) case securityinsight.FusionAlertRuleTemplate: - err = setForFusionAlertRuleTemplate(d, id, &template) + setForFusionAlertRuleTemplate(d, id, &template) case securityinsight.MicrosoftSecurityIncidentCreationAlertRuleTemplate: err = setForMsSecurityIncidentAlertRuleTemplate(d, id, &template) case securityinsight.ScheduledAlertRuleTemplate: @@ -267,18 +267,16 @@ func setForMsSecurityIncidentAlertRuleTemplate(d *pluginsdk.ResourceData, id par return d.Set("security_incident_template", flattenMsSecurityIncidentAlertRuleTemplate(template.MicrosoftSecurityIncidentCreationAlertRuleTemplateProperties)) } -func setForFusionAlertRuleTemplate(d *pluginsdk.ResourceData, id parse.SentinelAlertRuleTemplateId, template *securityinsight.FusionAlertRuleTemplate) error { +func setForFusionAlertRuleTemplate(d *pluginsdk.ResourceData, id parse.SentinelAlertRuleTemplateId, template *securityinsight.FusionAlertRuleTemplate) { d.SetId(id.ID()) d.Set("name", template.Name) d.Set("display_name", template.DisplayName) - return nil } -func setForMLBehaviorAnalyticsAlertRuleTemplate(d *pluginsdk.ResourceData, id parse.SentinelAlertRuleTemplateId, template *securityinsight.MLBehaviorAnalyticsAlertRuleTemplate) error { +func setForMLBehaviorAnalyticsAlertRuleTemplate(d *pluginsdk.ResourceData, id parse.SentinelAlertRuleTemplateId, template *securityinsight.MLBehaviorAnalyticsAlertRuleTemplate) { d.SetId(id.ID()) d.Set("name", template.Name) d.Set("display_name", template.DisplayName) - return nil } func flattenScheduledAlertRuleTemplate(input *securityinsight.ScheduledAlertRuleTemplateProperties) []interface{} { diff --git a/internal/services/streamanalytics/stream_analytics_reference_input.go b/internal/services/streamanalytics/stream_analytics_reference_input.go index a523c27285de..59be059ffc66 100644 --- a/internal/services/streamanalytics/stream_analytics_reference_input.go +++ b/internal/services/streamanalytics/stream_analytics_reference_input.go @@ -24,10 +24,11 @@ func importStreamAnalyticsReferenceInput(expectType string) pluginsdk.ImporterFu if model := resp.Model; model != nil { if props := model.Properties; props != nil { - input, ok := props.(inputs.InputProperties) + input, ok := props.(inputs.InputProperties) // nolint: gosimple if !ok { return nil, fmt.Errorf("failed to convert to Input") } + reference, ok := input.(inputs.ReferenceInputProperties) if !ok { return nil, fmt.Errorf("failed to convert to Reference Input") diff --git a/internal/services/streamanalytics/stream_analytics_reference_input_blob_resource.go b/internal/services/streamanalytics/stream_analytics_reference_input_blob_resource.go index 2f0e0c844b87..460289896d6c 100644 --- a/internal/services/streamanalytics/stream_analytics_reference_input_blob_resource.go +++ b/internal/services/streamanalytics/stream_analytics_reference_input_blob_resource.go @@ -243,7 +243,7 @@ func resourceStreamAnalyticsReferenceInputBlobRead(d *pluginsdk.ResourceData, me if model := resp.Model; model != nil { if props := model.Properties; props != nil { - input, ok := props.(inputs.InputProperties) + input, ok := props.(inputs.InputProperties) // nolint: gosimple if !ok { return fmt.Errorf("converting %s to an Input", *id) } diff --git a/internal/services/streamanalytics/stream_analytics_reference_input_mssql_resource.go b/internal/services/streamanalytics/stream_analytics_reference_input_mssql_resource.go index b609ba27d55e..66a3d8990eb4 100644 --- a/internal/services/streamanalytics/stream_analytics_reference_input_mssql_resource.go +++ b/internal/services/streamanalytics/stream_analytics_reference_input_mssql_resource.go @@ -220,7 +220,7 @@ func resourceStreamAnalyticsReferenceInputMsSqlRead(d *pluginsdk.ResourceData, m if model := resp.Model; model != nil { if props := model.Properties; props != nil { - input, ok := props.(inputs.InputProperties) + input, ok := props.(inputs.InputProperties) // nolint: gosimple if !ok { return fmt.Errorf("converting %s to an Input", *id) } diff --git a/internal/services/streamanalytics/stream_analytics_reference_input_mssql_resource_test.go b/internal/services/streamanalytics/stream_analytics_reference_input_mssql_resource_test.go index b2a0d4b5ec41..deb5b66a363c 100644 --- a/internal/services/streamanalytics/stream_analytics_reference_input_mssql_resource_test.go +++ b/internal/services/streamanalytics/stream_analytics_reference_input_mssql_resource_test.go @@ -153,32 +153,6 @@ QUERY `, template, data.RandomInteger) } -func (r StreamAnalyticsReferenceInputMsSqlResource) complete(data acceptance.TestData) string { - template := r.template(data) - return fmt.Sprintf(` -%s - -resource "azurerm_analytics_reference_input_mssql" "test" { - name = "acctestinput-%d" - stream_analytics_job_name = azurerm_stream_analytics_job.test.name - resource_group_name = azurerm_stream_analytics_job.test.resource_group_name - server = azurerm_mssql_server.test.fully_qualified_domain_name - database = azurerm_mssql_database.test.name - username = "maurice" - password = "ludicrousdisplay" - refresh_type = "RefreshPeriodicallyWithFull" - refresh_interval_duration = "00:10:00" - table = "exampletable" - full_snapshot_query = <