Skip to content

Commit

Permalink
fix comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Aris van Ommeren committed May 1, 2020
1 parent 4744654 commit 968f387
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 46 deletions.
Expand Up @@ -12,7 +12,7 @@ type FunctionAppSlotResourceID struct {
Name string
}

func ParseFunctionAppSlotID(input string) (*FunctionAppSlotResourceID, error) {
func FunctionAppSlotID(input string) (*FunctionAppSlotResourceID, error) {
id, err := azure.ParseAzureResourceID(input)
if err != nil {
return nil, fmt.Errorf("[ERROR] Unable to parse App Service Slot ID %q: %+v", input, err)
Expand Down
14 changes: 2 additions & 12 deletions azurerm/internal/services/web/resource_arm_app_service.go
Expand Up @@ -3,7 +3,6 @@ package web
import (
"fmt"
"log"
"regexp"
"time"

"github.com/Azure/azure-sdk-for-go/services/web/mgmt/2019-08-01/web"
Expand All @@ -14,6 +13,7 @@ import (
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/tf"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/clients"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/features"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/web/validate"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/tags"
azSchema "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/tf/schema"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/timeouts"
Expand Down Expand Up @@ -44,7 +44,7 @@ func resourceArmAppService() *schema.Resource {
Type: schema.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: validateAppServiceName,
ValidateFunc: validate.AppServiceName,
},

"identity": azure.SchemaAppServiceIdentity(),
Expand Down Expand Up @@ -760,16 +760,6 @@ func flattenAppServiceAppSettings(input map[string]*string) map[string]string {
return output
}

func validateAppServiceName(v interface{}, k string) (warnings []string, errors []error) {
value := v.(string)

if matched := regexp.MustCompile(`^[0-9a-zA-Z-]{1,60}$`).Match([]byte(value)); !matched {
errors = append(errors, fmt.Errorf("%q may only contain alphanumeric characters and dashes and up to 60 characters in length", k))
}

return warnings, errors
}

func flattenAppServiceSiteCredential(input *web.UserProperties) []interface{} {
results := make([]interface{}, 0)
result := make(map[string]interface{})
Expand Down
63 changes: 33 additions & 30 deletions azurerm/internal/services/web/resource_arm_function_app_slot.go
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/validate"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/clients"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/features"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/web/parse"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/tags"
azSchema "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/tf/schema"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/timeouts"
Expand All @@ -28,7 +29,7 @@ func resourceArmFunctionAppSlot() *schema.Resource {
Update: resourceArmFunctionAppSlotUpdate,
Delete: resourceArmFunctionAppSlotDelete,
Importer: azSchema.ValidateResourceIDPriorToImport(func(id string) error {
_, err := ParseFunctionAppSlotID(id)
_, err := parse.FunctionAppSlotID(id)
return err
}),

Expand All @@ -53,20 +54,17 @@ func resourceArmFunctionAppSlot() *schema.Resource {
"identity": azure.SchemaAppServiceIdentity(),

"function_app_name": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
},

"kind": {
Type: schema.TypeString,
Computed: true,
Type: schema.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: validate.AppServiceName,
},

"app_service_plan_id": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
Type: schema.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: ValidateAppServicePlanID,
},

"version": {
Expand All @@ -90,16 +88,27 @@ func resourceArmFunctionAppSlot() *schema.Resource {
},
},

"daily_memory_time_quota": {
Type: schema.TypeInt,
Optional: true,
},

"enabled": {
Type: schema.TypeBool,
Optional: true,
Default: true,
},

"enable_builtin_logging": {
Type: schema.TypeBool,
Optional: true,
Default: true,
},

"client_affinity_enabled": {
"https_only": {
Type: schema.TypeBool,
Optional: true,
Computed: true,
Default: false,
},

"os_type": {
Expand All @@ -111,21 +120,10 @@ func resourceArmFunctionAppSlot() *schema.Resource {
}, false),
},

"https_only": {
Type: schema.TypeBool,
Optional: true,
Default: false,
},

"enabled": {
"client_affinity_enabled": {
Type: schema.TypeBool,
Optional: true,
Default: true,
},

"daily_memory_time_quota": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
},

"connection_string": {
Expand Down Expand Up @@ -170,6 +168,11 @@ func resourceArmFunctionAppSlot() *schema.Resource {
Computed: true,
},

"kind": {
Type: schema.TypeString,
Computed: true,
},

"outbound_ip_addresses": {
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -392,7 +395,7 @@ func resourceArmFunctionAppSlotUpdate(d *schema.ResourceData, meta interface{})
ctx, cancel := timeouts.ForUpdate(meta.(*clients.Client).StopContext, d)
defer cancel()

id, err := ParseFunctionAppSlotID(d.Id())
id, err := parse.FunctionAppSlotID(d.Id())
if err != nil {
return err
}
Expand Down Expand Up @@ -510,7 +513,7 @@ func resourceArmFunctionAppSlotRead(d *schema.ResourceData, meta interface{}) er
ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d)
defer cancel()

id, err := ParseFunctionAppSlotID(d.Id())
id, err := parse.FunctionAppSlotID(d.Id())
if err != nil {
return err
}
Expand Down Expand Up @@ -637,7 +640,7 @@ func resourceArmFunctionAppSlotDelete(d *schema.ResourceData, meta interface{})
ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d)
defer cancel()

id, err := ParseFunctionAppSlotID(d.Id())
id, err := parse.FunctionAppSlotID(d.Id())
if err != nil {
return err
}
Expand Down
Expand Up @@ -151,6 +151,7 @@ func TestAccAzureRMFunctionAppSlot_clientAffinityEnabledUpdate(t *testing.T) {
resource.TestCheckResourceAttr(data.ResourceName, "client_affinity_enabled", "true"),
),
},
data.ImportStep(),
{
Config: testAccAzureRMFunctionAppSlot_clientAffinityEnabled(data, false),
Check: resource.ComposeTestCheckFunc(
Expand Down Expand Up @@ -182,6 +183,7 @@ func TestAccAzureRMFunctionAppSlot_connectionStrings(t *testing.T) {
resource.TestCheckResourceAttr(data.ResourceName, "connection_string.2442860602.type", "PostgreSQL"),
),
},
data.ImportStep(),
{
Config: testAccAzureRMFunctionAppSlot_connectionStringsUpdated(data),
Check: resource.ComposeTestCheckFunc(
Expand Down
16 changes: 16 additions & 0 deletions azurerm/internal/services/web/validate/app_service.go
@@ -0,0 +1,16 @@
package validate

import (
"fmt"
"regexp"
)

func AppServiceName(v interface{}, k string) (warnings []string, errors []error) {
value := v.(string)

if matched := regexp.MustCompile(`^[0-9a-zA-Z-]{1,60}$`).Match([]byte(value)); !matched {
errors = append(errors, fmt.Errorf("%q may only contain alphanumeric characters and dashes and up to 60 characters in length", k))
}

return warnings, errors
}
6 changes: 3 additions & 3 deletions website/docs/r/function_app_slot.html.markdown
Expand Up @@ -76,11 +76,11 @@ The following arguments are supported:

~> **Note:** When using an App Service Plan in the `Free` or `Shared` Tiers `use_32_bit_worker_process` must be set to `true`.

* `auth_settings` - (Optional) A `auth_settings` block as defined below.
* `auth_settings` - (Optional) An `auth_settings` block as defined below.

* `enable_builtin_logging` - (Optional) Should the built-in logging of this Function App be enabled? Defaults to `true`.

* `connection_string` - (Optional) An `connection_string` block as defined below.
* `connection_string` - (Optional) A `connection_string` block as defined below.

* `os_type` - (Optional) A string indicating the Operating System type for this function app.

Expand Down Expand Up @@ -158,7 +158,7 @@ An `auth_settings` block supports the following:

* `enabled` - (Required) Is Authentication enabled?

* `active_directory` - (Optional) A `active_directory` block as defined below.
* `active_directory` - (Optional) An `active_directory` block as defined below.

* `additional_login_params` - (Optional) Login parameters to send to the OpenID Connect authorization endpoint when a user logs in. Each parameter must be in the form "key=value".

Expand Down

0 comments on commit 968f387

Please sign in to comment.