From 9e7320867d8b922be5eba7f53a98583b1f0ddb16 Mon Sep 17 00:00:00 2001 From: Tom Harvey Date: Fri, 21 Dec 2018 12:46:39 +0100 Subject: [PATCH] Enforce read & write permissions values Co-Authored-By: pdecat --- azurerm/helpers/validate/strings.go | 14 -------------- .../resource_arm_application_insights_api_key.go | 6 +++--- 2 files changed, 3 insertions(+), 17 deletions(-) diff --git a/azurerm/helpers/validate/strings.go b/azurerm/helpers/validate/strings.go index 2c8b6bd2c7b8..1dec1bd2e07f 100644 --- a/azurerm/helpers/validate/strings.go +++ b/azurerm/helpers/validate/strings.go @@ -18,17 +18,3 @@ func NoEmptyStrings(i interface{}, k string) ([]string, []error) { return nil, nil } - -// LowercaseString validates that the string is all lower case characters -func LowercaseString(i interface{}, k string) ([]string, []error) { - v, ok := i.(string) - if !ok { - return nil, []error{fmt.Errorf("expected type of %q to be string", k)} - } - - if v != strings.ToLower(v) { - return nil, []error{fmt.Errorf("%q must not be lower case", k)} - } - - return nil, nil -} diff --git a/azurerm/resource_arm_application_insights_api_key.go b/azurerm/resource_arm_application_insights_api_key.go index 3cb63d726340..d262728da8ce 100644 --- a/azurerm/resource_arm_application_insights_api_key.go +++ b/azurerm/resource_arm_application_insights_api_key.go @@ -6,10 +6,10 @@ import ( "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/tf" - "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/validate" "github.com/Azure/azure-sdk-for-go/services/appinsights/mgmt/2015-05-01/insights" "github.com/hashicorp/terraform/helper/schema" + "github.com/hashicorp/terraform/helper/validation" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" ) @@ -48,7 +48,7 @@ func resourceArmApplicationInsightsAPIKey() *schema.Resource { Set: schema.HashString, Elem: &schema.Schema{ Type: schema.TypeString, - ValidateFunc: validate.LowercaseString, + ValidateFunc: validation.StringInSlice([]string{"agentconfig", "aggregate", "api", "draft", "extendqueries", "search"}, false), }, }, @@ -59,7 +59,7 @@ func resourceArmApplicationInsightsAPIKey() *schema.Resource { Set: schema.HashString, Elem: &schema.Schema{ Type: schema.TypeString, - ValidateFunc: validate.LowercaseString, + ValidateFunc: validation.StringInSlice([]string{"annotations"}, false), }, }, },