Skip to content

Commit

Permalink
Merge pull request #1781 from terraform-providers/td-suppressCaseDiff
Browse files Browse the repository at this point in the history
cleaning up some package tech debt
  • Loading branch information
katbyte authored Aug 16, 2018
2 parents 8b7445d + 9dbcdf9 commit 6289f69
Show file tree
Hide file tree
Showing 14 changed files with 56 additions and 74 deletions.
6 changes: 3 additions & 3 deletions azurerm/data_source_app_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"

"github.com/hashicorp/terraform/helper/schema"
azSchema "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/schema"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils"
)

Expand All @@ -28,7 +28,7 @@ func dataSourceArmAppService() *schema.Resource {
Computed: true,
},

"site_config": azSchema.AppServiceSiteConfigSchema(),
"site_config": azure.SchemaAppServiceSiteConfig(),

"client_affinity_enabled": {
Type: schema.TypeBool,
Expand Down Expand Up @@ -192,7 +192,7 @@ func dataSourceArmAppServiceRead(d *schema.ResourceData, meta interface{}) error
return err
}

siteConfig := azSchema.FlattenAppServiceSiteConfig(configResp.SiteConfig)
siteConfig := azure.FlattenAppServiceSiteConfig(configResp.SiteConfig)
if err := d.Set("site_config", siteConfig); err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions azurerm/data_source_key_vault.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (

"github.com/Azure/azure-sdk-for-go/services/keyvault/mgmt/2016-10-01/keyvault"
"github.com/hashicorp/terraform/helper/schema"
kvschema "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/schema"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils"
)

Expand Down Expand Up @@ -142,7 +142,7 @@ func dataSourceArmKeyVaultRead(d *schema.ResourceData, meta interface{}) error {
return fmt.Errorf("Error flattening `sku` for KeyVault %q: %+v", resp.Name, err)
}

flattenedPolicies := kvschema.FlattenKeyVaultAccessPolicies(props.AccessPolicies)
flattenedPolicies := azure.FlattenKeyVaultAccessPolicies(props.AccessPolicies)
if err := d.Set("access_policy", flattenedPolicies); err != nil {
return fmt.Errorf("Error flattening `access_policy` for KeyVault %q: %+v", resp.Name, err)
}
Expand Down
4 changes: 2 additions & 2 deletions azurerm/data_source_subscription.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import (
"fmt"

"github.com/hashicorp/terraform/helper/schema"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/subscription"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils"
)

func dataSourceArmSubscription() *schema.Resource {
return &schema.Resource{
Read: dataSourceArmSubscriptionRead,
Schema: subscription.SubscriptionSchema(true),
Schema: azure.SchemaSubscription(true),
}
}

Expand Down
4 changes: 2 additions & 2 deletions azurerm/data_source_subscriptions.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"

"github.com/hashicorp/terraform/helper/schema"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/subscription"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure"
)

func dataSourceArmSubscriptions() *schema.Resource {
Expand All @@ -16,7 +16,7 @@ func dataSourceArmSubscriptions() *schema.Resource {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: subscription.SubscriptionSchema(false),
Schema: azure.SchemaSubscription(false),
},
},
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package schema
package azure

import (
"log"
Expand All @@ -8,10 +8,11 @@ import (
"github.com/Azure/azure-sdk-for-go/services/web/mgmt/2018-02-01/web"
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/helper/validation"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/suppress"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils"
)

func AppServiceSiteConfigSchema() *schema.Schema {
func SchemaAppServiceSiteConfig() *schema.Schema {
return &schema.Schema{
Type: schema.TypeList,
Optional: true,
Expand Down Expand Up @@ -39,7 +40,7 @@ func AppServiceSiteConfigSchema() *schema.Schema {
"v2.0",
"v4.0",
}, true),
DiffSuppressFunc: IgnoreCaseDiffSuppressFunc,
DiffSuppressFunc: suppress.CaseDifference,
},

"http2_enabled": {
Expand Down Expand Up @@ -83,7 +84,7 @@ func AppServiceSiteConfigSchema() *schema.Schema {
"JETTY",
"TOMCAT",
}, true),
DiffSuppressFunc: IgnoreCaseDiffSuppressFunc,
DiffSuppressFunc: suppress.CaseDifference,
},

"java_container_version": {
Expand All @@ -105,7 +106,7 @@ func AppServiceSiteConfigSchema() *schema.Schema {
string(web.Classic),
string(web.Integrated),
}, true),
DiffSuppressFunc: IgnoreCaseDiffSuppressFunc,
DiffSuppressFunc: suppress.CaseDifference,
},

"php_version": {
Expand Down Expand Up @@ -144,7 +145,7 @@ func AppServiceSiteConfigSchema() *schema.Schema {
"VS2015",
"VS2017",
}, true),
DiffSuppressFunc: IgnoreCaseDiffSuppressFunc,
DiffSuppressFunc: suppress.CaseDifference,
},

"scm_type": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package schema
package azure

import (
"github.com/Azure/azure-sdk-for-go/services/keyvault/mgmt/2016-10-01/keyvault"
Expand All @@ -8,7 +8,7 @@ import (
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/suppress"
)

func KeyVaultCertificatePermissionsSchema() *schema.Schema {
func SchemaKeyVaultCertificatePermissions() *schema.Schema {
return &schema.Schema{
Type: schema.TypeList,
Optional: true,
Expand All @@ -35,7 +35,7 @@ func KeyVaultCertificatePermissionsSchema() *schema.Schema {
}
}

func KeyVaultKeyPermissionsSchema() *schema.Schema {
func SchemaKeyVaultKeyPermissions() *schema.Schema {
return &schema.Schema{
Type: schema.TypeList,
Required: true,
Expand Down Expand Up @@ -64,7 +64,7 @@ func KeyVaultKeyPermissionsSchema() *schema.Schema {
}
}

func KeyVaultSecretPermissionsSchema() *schema.Schema {
func SchemaKeyVaultSecretPermissions() *schema.Schema {
return &schema.Schema{
Type: schema.TypeList,
Required: true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package subscription
package azure

import (
"github.com/hashicorp/terraform/helper/schema"
)

func SubscriptionSchema(subscriptionIDOptional bool) map[string]*schema.Schema {
func SchemaSubscription(subscriptionIDOptional bool) map[string]*schema.Schema {
s := map[string]*schema.Schema{
"subscription_id": {
Type: schema.TypeString,
Expand Down
19 changes: 0 additions & 19 deletions azurerm/helpers/schema/diff_suppress_func.go

This file was deleted.

6 changes: 3 additions & 3 deletions azurerm/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/terraform"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/authentication"
azSchema "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/schema"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/suppress"
)

// Provider returns a terraform.ResourceProvider.
Expand Down Expand Up @@ -438,9 +438,9 @@ func registerAzureResourceProvidersWithSubscription(ctx context.Context, provide
// armMutexKV is the instance of MutexKV for ARM resources
var armMutexKV = mutexkv.NewMutexKV()

// Deprecated - use `azschema.IgnoreCaseDiffSuppressFunc` instead
// Deprecated: use `suppress.CaseDifference` instead
func ignoreCaseDiffSuppressFunc(k, old, new string, d *schema.ResourceData) bool {
return azSchema.IgnoreCaseDiffSuppressFunc(k, old, new, d)
return suppress.CaseDifference(k, old, new, d)
}

// ignoreCaseStateFunc is a StateFunc from helper/schema that converts the
Expand Down
12 changes: 6 additions & 6 deletions azurerm/resource_arm_app_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/Azure/azure-sdk-for-go/services/web/mgmt/2018-02-01/web"
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/helper/validation"
azSchema "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/schema"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils"
)

Expand Down Expand Up @@ -67,7 +67,7 @@ func resourceArmAppService() *schema.Resource {
ForceNew: true,
},

"site_config": azSchema.AppServiceSiteConfigSchema(),
"site_config": azure.SchemaAppServiceSiteConfig(),

"client_affinity_enabled": {
Type: schema.TypeBool,
Expand Down Expand Up @@ -208,7 +208,7 @@ func resourceArmAppServiceCreate(d *schema.ResourceData, meta interface{}) error
httpsOnly := d.Get("https_only").(bool)
tags := d.Get("tags").(map[string]interface{})

siteConfig := azSchema.ExpandAppServiceSiteConfig(d.Get("site_config"))
siteConfig := azure.ExpandAppServiceSiteConfig(d.Get("site_config"))

siteEnvelope := web.Site{
Location: &location,
Expand Down Expand Up @@ -272,7 +272,7 @@ func resourceArmAppServiceUpdate(d *schema.ResourceData, meta interface{}) error
httpsOnly := d.Get("https_only").(bool)
tags := d.Get("tags").(map[string]interface{})

siteConfig := azSchema.ExpandAppServiceSiteConfig(d.Get("site_config"))
siteConfig := azure.ExpandAppServiceSiteConfig(d.Get("site_config"))
siteEnvelope := web.Site{
Location: &location,
Tags: expandTags(tags),
Expand All @@ -296,7 +296,7 @@ func resourceArmAppServiceUpdate(d *schema.ResourceData, meta interface{}) error

if d.HasChange("site_config") {
// update the main configuration
siteConfig := azSchema.ExpandAppServiceSiteConfig(d.Get("site_config"))
siteConfig := azure.ExpandAppServiceSiteConfig(d.Get("site_config"))
siteConfigResource := web.SiteConfigResource{
SiteConfig: &siteConfig,
}
Expand Down Expand Up @@ -451,7 +451,7 @@ func resourceArmAppServiceRead(d *schema.ResourceData, meta interface{}) error {
return err
}

siteConfig := azSchema.FlattenAppServiceSiteConfig(configResp.SiteConfig)
siteConfig := azure.FlattenAppServiceSiteConfig(configResp.SiteConfig)
if err := d.Set("site_config", siteConfig); err != nil {
return err
}
Expand Down
12 changes: 6 additions & 6 deletions azurerm/resource_arm_app_service_slot.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/Azure/azure-sdk-for-go/services/web/mgmt/2018-02-01/web"
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/helper/validation"
azSchema "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/schema"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils"
)

Expand Down Expand Up @@ -72,7 +72,7 @@ func resourceArmAppServiceSlot() *schema.Resource {
ForceNew: true,
},

"site_config": azSchema.AppServiceSiteConfigSchema(),
"site_config": azure.SchemaAppServiceSiteConfig(),

"client_affinity_enabled": {
Type: schema.TypeBool,
Expand Down Expand Up @@ -159,7 +159,7 @@ func resourceArmAppServiceSlotCreate(d *schema.ResourceData, meta interface{}) e
httpsOnly := d.Get("https_only").(bool)
tags := d.Get("tags").(map[string]interface{})

siteConfig := azSchema.ExpandAppServiceSiteConfig(d.Get("site_config"))
siteConfig := azure.ExpandAppServiceSiteConfig(d.Get("site_config"))
siteEnvelope := web.Site{
Location: &location,
Tags: expandTags(tags),
Expand Down Expand Up @@ -230,7 +230,7 @@ func resourceArmAppServiceSlotUpdate(d *schema.ResourceData, meta interface{}) e
location := azureRMNormalizeLocation(d.Get("location").(string))
appServicePlanId := d.Get("app_service_plan_id").(string)
slot := id.Path["slots"]
siteConfig := azSchema.ExpandAppServiceSiteConfig(d.Get("site_config"))
siteConfig := azure.ExpandAppServiceSiteConfig(d.Get("site_config"))
enabled := d.Get("enabled").(bool)
httpsOnly := d.Get("https_only").(bool)
tags := d.Get("tags").(map[string]interface{})
Expand Down Expand Up @@ -259,7 +259,7 @@ func resourceArmAppServiceSlotUpdate(d *schema.ResourceData, meta interface{}) e
}
if d.HasChange("site_config") {
// update the main configuration
siteConfig := azSchema.ExpandAppServiceSiteConfig(d.Get("site_config"))
siteConfig := azure.ExpandAppServiceSiteConfig(d.Get("site_config"))
siteConfigResource := web.SiteConfigResource{
SiteConfig: &siteConfig,
}
Expand Down Expand Up @@ -372,7 +372,7 @@ func resourceArmAppServiceSlotRead(d *schema.ResourceData, meta interface{}) err
return err
}

siteConfig := azSchema.FlattenAppServiceSiteConfig(configResp.SiteConfig)
siteConfig := azure.FlattenAppServiceSiteConfig(configResp.SiteConfig)
if err := d.Set("site_config", siteConfig); err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion azurerm/resource_arm_cosmos_db_account.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import (

"github.com/hashicorp/terraform/helper/hashcode"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/helper/validation"

"github.com/hashicorp/terraform/helper/schema"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/response"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils"
)
Expand Down
14 changes: 7 additions & 7 deletions azurerm/resource_arm_key_vault.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/helper/validation"
uuid "github.com/satori/go.uuid"
azschema "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/schema"
"github.com/satori/go.uuid"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils"
)

Expand Down Expand Up @@ -97,9 +97,9 @@ func resourceArmKeyVault() *schema.Resource {
Optional: true,
ValidateFunc: validateUUID,
},
"certificate_permissions": azschema.KeyVaultCertificatePermissionsSchema(),
"key_permissions": azschema.KeyVaultKeyPermissionsSchema(),
"secret_permissions": azschema.KeyVaultSecretPermissionsSchema(),
"certificate_permissions": azure.SchemaKeyVaultCertificatePermissions(),
"key_permissions": azure.SchemaKeyVaultKeyPermissions(),
"secret_permissions": azure.SchemaKeyVaultSecretPermissions(),
},
},
},
Expand Down Expand Up @@ -139,7 +139,7 @@ func resourceArmKeyVaultCreateUpdate(d *schema.ResourceData, meta interface{}) e
tags := d.Get("tags").(map[string]interface{})

policies := d.Get("access_policy").([]interface{})
accessPolicies, err := azschema.ExpandKeyVaultAccessPolicies(policies)
accessPolicies, err := azure.ExpandKeyVaultAccessPolicies(policies)
if err != nil {
return fmt.Errorf("Error expanding `access_policy`: %+v", policies)
}
Expand Down Expand Up @@ -236,7 +236,7 @@ func resourceArmKeyVaultRead(d *schema.ResourceData, meta interface{}) error {
return fmt.Errorf("Error flattening `sku` for KeyVault %q: %+v", resp.Name, err)
}

flattenedPolicies := azschema.FlattenKeyVaultAccessPolicies(props.AccessPolicies)
flattenedPolicies := azure.FlattenKeyVaultAccessPolicies(props.AccessPolicies)
if err := d.Set("access_policy", flattenedPolicies); err != nil {
return fmt.Errorf("Error flattening `access_policy` for KeyVault %q: %+v", resp.Name, err)
}
Expand Down
Loading

0 comments on commit 6289f69

Please sign in to comment.