Skip to content

Commit

Permalink
post mege cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
katbyte committed Dec 8, 2022
1 parent a65fe20 commit 7febf23
Show file tree
Hide file tree
Showing 17 changed files with 29 additions and 83 deletions.
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
19 changes: 0 additions & 19 deletions internal/services/cognitive/cognitive_account_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion internal/services/digitaltwins/client/client.go
Original file line number Diff line number Diff line change
@@ -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"
)
Expand Down
22 changes: 7 additions & 15 deletions internal/services/media/media_content_key_policy_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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{}{
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand All @@ -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 {
Expand Down Expand Up @@ -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 := ""
Expand Down Expand Up @@ -1069,7 +1061,7 @@ func flattenPlayReadyLicenses(input []contentkeypolicies.ContentKeyPolicyPlayRea
})
}

return results, nil
return results
}

func expandPlayRight(input []interface{}) *contentkeypolicies.ContentKeyPolicyPlayReadyPlayRight {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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{} {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = <<QUERY
SELECT *
INTO [YourOutputAlias]
FROM [YourInputAlias]
QUERY
}
`, template, data.RandomInteger)
}

func (r StreamAnalyticsReferenceInputMsSqlResource) requiresImport(data acceptance.TestData) string {
template := r.basic(data)
return fmt.Sprintf(`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,9 @@ func resourceStreamAnalyticsStreamInputBlobCreateUpdate(d *pluginsdk.ResourceDat
props := inputs.Input{
Name: utils.String(id.InputName),
Properties: &inputs.StreamInputProperties{
//Type: streamanalytics.TypeBasicInputPropertiesTypeStream,
// Type: streamanalytics.TypeBasicInputPropertiesTypeStream,
Datasource: &inputs.BlobStreamInputDataSource{
//Type: streamanalytics.TypeBasicStreamInputDataSourceTypeMicrosoftStorageBlob,
// Type: streamanalytics.TypeBasicStreamInputDataSourceTypeMicrosoftStorageBlob,
Properties: &inputs.BlobStreamInputDataSourceProperties{
Container: utils.String(containerName),
DateFormat: utils.String(dateFormat),
Expand Down Expand Up @@ -199,7 +199,7 @@ func resourceStreamAnalyticsStreamInputBlobRead(d *pluginsdk.ResourceData, meta

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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ func resourceStreamAnalyticsStreamInputEventHubRead(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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ func (r StreamInputEventHubV2Resource) Read() sdk.ResourceFunc {

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)
}
Expand Down Expand Up @@ -378,7 +378,7 @@ func (r StreamInputEventHubV2Resource) CustomImporter() sdk.ResourceRunFunc {

props := resp.Model.Properties

input, ok := props.(inputs.InputProperties)
input, ok := props.(inputs.InputProperties) // nolint: gosimple
if !ok {
return fmt.Errorf("specified resource is not an Input: %+v", err)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ func resourceStreamAnalyticsStreamInputIoTHubRead(d *pluginsdk.ResourceData, met

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)
}
Expand Down

0 comments on commit 7febf23

Please sign in to comment.