Skip to content

Commit

Permalink
pull
Browse files Browse the repository at this point in the history
  • Loading branch information
katbyte committed Sep 19, 2020
2 parents ece80e9 + 4058ea1 commit 5f956cc
Show file tree
Hide file tree
Showing 756 changed files with 51,524 additions and 5,312 deletions.
6 changes: 0 additions & 6 deletions .github/ISSUE_TEMPLATE.md

This file was deleted.

2 changes: 2 additions & 0 deletions .teamcity/components/generated/services.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ var services = mapOf(
"appconfiguration" to "App Configuration",
"appplatform" to "App Platform",
"applicationinsights" to "Application Insights",
"attestation" to "Attestation",
"authorization" to "Authorization",
"automation" to "Automation",
"batch" to "Batch",
Expand Down Expand Up @@ -42,6 +43,7 @@ var services = mapOf(
"machinelearning" to "Machine Learning",
"maintenance" to "Maintenance",
"managedapplications" to "Managed Applications",
"lighthouse" to "Lighthouse",
"managementgroup" to "Management Group",
"maps" to "Maps",
"mariadb" to "MariaDB",
Expand Down
167 changes: 153 additions & 14 deletions CHANGELOG.md

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions azurerm/helpers/azure/api_management.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,17 @@ func SchemaApiManagementChildName() *schema.Schema {
}
}

// SchemaApiManagementChildName returns the Schema for the identifier
// used by resources within nested under the API Management Service resource
func SchemaApiManagementApiName() *schema.Schema {
return &schema.Schema{
Type: schema.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: validate.ApiManagementApiName,
}
}

// SchemaApiManagementChildDataSourceName returns the Schema for the identifier
// used by resources within nested under the API Management Service resource
func SchemaApiManagementChildDataSourceName() *schema.Schema {
Expand Down
2 changes: 1 addition & 1 deletion azurerm/helpers/azure/key_vault.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"fmt"

"github.com/Azure/azure-sdk-for-go/services/keyvault/mgmt/2018-02-14/keyvault"
"github.com/Azure/azure-sdk-for-go/services/keyvault/mgmt/2019-09-01/keyvault"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils"
)

Expand Down
2 changes: 1 addition & 1 deletion azurerm/helpers/azure/key_vault_access_policy.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package azure

import (
"github.com/Azure/azure-sdk-for-go/services/keyvault/mgmt/2018-02-14/keyvault"
"github.com/Azure/azure-sdk-for-go/services/keyvault/mgmt/2019-09-01/keyvault"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/helper/validation"
uuid "github.com/satori/go.uuid"
Expand Down
2 changes: 1 addition & 1 deletion azurerm/helpers/azure/resourceid.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,5 +110,5 @@ func (id *ResourceID) ValidateNoEmptySegments(sourceId string) error {
return nil
}

return fmt.Errorf("ID contained more segments than required: %q", sourceId)
return fmt.Errorf("ID contained more segments than required: %q, %v", sourceId, id.Path)
}
17 changes: 12 additions & 5 deletions azurerm/helpers/azure/zones.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
package azure

import "github.com/hashicorp/terraform-plugin-sdk/helper/schema"
import (
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/helper/validation"
)

func SchemaZones() *schema.Schema {
return &schema.Schema{
Type: schema.TypeList,
Optional: true,
ForceNew: true,
Elem: &schema.Schema{
Type: schema.TypeString,
Type: schema.TypeString,
ValidateFunc: validation.StringIsNotEmpty,
},
}
}
Expand All @@ -20,7 +24,8 @@ func SchemaSingleZone() *schema.Schema {
ForceNew: true,
MaxItems: 1,
Elem: &schema.Schema{
Type: schema.TypeString,
Type: schema.TypeString,
ValidateFunc: validation.StringIsNotEmpty,
},
}
}
Expand All @@ -32,7 +37,8 @@ func SchemaMultipleZones() *schema.Schema {
ForceNew: true,
MinItems: 1,
Elem: &schema.Schema{
Type: schema.TypeString,
Type: schema.TypeString,
ValidateFunc: validation.StringIsNotEmpty,
},
}
}
Expand All @@ -43,7 +49,8 @@ func SchemaZonesComputed() *schema.Schema {
Optional: true,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
Type: schema.TypeString,
ValidateFunc: validation.StringIsNotEmpty,
},
}
}
Expand Down
25 changes: 25 additions & 0 deletions azurerm/helpers/validate/cosmos.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,28 @@ func CosmosThroughput(v interface{}, k string) (warnings []string, errors []erro

return warnings, errors
}

func CosmosMaxThroughput(i interface{}, k string) (warnings []string, errors []error) {
v, ok := i.(int)
if !ok {
errors = append(errors, fmt.Errorf("expected type of %q to be int", k))
return
}

if v < 4000 {
errors = append(errors, fmt.Errorf(
"%s must be a minimum of 4000", k))
}

if v > 1000000 {
errors = append(errors, fmt.Errorf(
"%s must be a maximum of 1000000", k))
}

if v%1000 != 0 {
errors = append(errors, fmt.Errorf(
"%q must be set in increments of 1000", k))
}

return warnings, errors
}
51 changes: 51 additions & 0 deletions azurerm/helpers/validate/cosmos_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,54 @@ func TestCosmosThroughput(t *testing.T) {
}
}
}

func TestCosmosMaxThroughput(t *testing.T) {
cases := []struct {
Value interface{}
Errors int
}{
{
Value: 400,
Errors: 2,
},
{
Value: 1000,
Errors: 1,
},
{
Value: 4000,
Errors: 0,
},
{
Value: 4001,
Errors: 1,
},
{
Value: 10000,
Errors: 0,
},
{
Value: 54000,
Errors: 0,
},
{
Value: 1000000,
Errors: 0,
},
{
Value: 1100000,
Errors: 1,
},
{
Value: "400",
Errors: 1,
},
}

for _, tc := range cases {
_, errors := CosmosMaxThroughput(tc.Value, "throughput")
if len(errors) != tc.Errors {
t.Fatalf("Expected CosmosMaxThroughput to trigger '%d' errors for '%d' - got '%d'", tc.Errors, tc.Value, len(errors))
}
}
}
13 changes: 2 additions & 11 deletions azurerm/helpers/validate/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,13 @@ package validate
import (
"fmt"
"regexp"
"strings"
)

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

// File share names can contain only uppercase and lowercase letters, numbers, and hyphens,
// and must begin and end with a letter or a number.
// However they can be nested (e.g. foo/bar) with at most one level.
if !regexp.MustCompile(`^[A-Za-z0-9]{1,}[A-Za-z0-9-]{0,1}[A-Za-z0-9]{1,}(/[A-Za-z0-9]{1,}[A-Za-z0-9-]{0,1}[A-Za-z0-9]{1,})?$`).MatchString(value) {
errors = append(errors, fmt.Errorf("%s must contain only uppercase and lowercase alphanumeric characters, numbers and hyphens. It must start and end with a letter and end only with a number or letter and can only be nested one level", k))
}

// The name cannot contain two consecutive hyphens.
if strings.Contains(value, "--") {
errors = append(errors, fmt.Errorf("%s cannot contain two concecutive hyphens", k))
if !regexp.MustCompile(`^[A-Za-z0-9-]+(/[A-Za-z0-9-]+)*$`).MatchString(value) {
errors = append(errors, fmt.Errorf("%s must contain only uppercase and lowercase alphanumeric characters, numbers and hyphens, and can be nested multiple levels", k))
}

return warnings, errors
Expand Down
42 changes: 31 additions & 11 deletions azurerm/helpers/validate/storage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,46 +19,66 @@ func TestValidateStorageShareDirectoryName(t *testing.T) {
Input: "123abc",
Expected: true,
},
{
Input: "abc-123",
Expected: true,
},
{
Input: "123-abc",
Expected: true,
},
{
Input: "-123-abc",
Expected: false,
Expected: true,
},
{
Input: "123-abc-",
Expected: false,
Input: "abc-123-",
Expected: true,
},
{
Input: "123--abc",
Expected: false,
Input: "abc--123",
Expected: true,
},
{
Input: "hello/world",
Expected: true,
},
{
Input: "hello/-world",
Expected: true,
},
{
Input: "hello-/world",
Expected: true,
},
{
Input: "abc-123/world-",
Expected: true,
},
{
Input: "123-abc/hello-world",
Expected: true,
},
{
Input: "123-abc/hello--world",
Expected: false,
Input: "abc-123/hello--world",
Expected: true,
},
{
Input: "123-abc/hello/world",
Expected: false,
Input: "abc-123/hello/world",
Expected: true,
},
{
Input: "123-abc/hello/world-",
Expected: false,
Input: "abc-123/hello/world-",
Expected: true,
},
{
Input: "hello/",
Expected: false,
},
{
Input: "abc-test-123/hjg-345-test",
Expected: true,
},
{
Input: "Abc123",
Expected: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import (
"github.com/davecgh/go-spew/spew"
"github.com/hashicorp/go-azure-helpers/resourceproviders"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/clients"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/provider"
rmResourceProviders "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/resourceproviders"
)

// since this depends on GetAuthConfig which lives in this package
// unfortunately this has to live in a different package to the other func

func TestAccAzureRMEnsureRequiredResourceProvidersAreRegistered(t *testing.T) {
func TestAccEnsureRequiredResourceProvidersAreRegistered(t *testing.T) {
config := GetAuthConfig(t)
if config == nil {
return
Expand Down Expand Up @@ -43,8 +43,8 @@ func TestAccAzureRMEnsureRequiredResourceProvidersAreRegistered(t *testing.T) {
}

availableResourceProviders := providerList.Values()
requiredResourceProviders := provider.RequiredResourceProviders()
err = provider.EnsureResourceProvidersAreRegistered(ctx, *client, availableResourceProviders, requiredResourceProviders)
requiredResourceProviders := rmResourceProviders.Required()
err = rmResourceProviders.EnsureRegistered(ctx, *client, availableResourceProviders, requiredResourceProviders)
if err != nil {
t.Fatalf("Error registering Resource Providers: %+v", err)
}
Expand Down
6 changes: 6 additions & 0 deletions azurerm/internal/clients/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
appConfiguration "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/appconfiguration/client"
applicationInsights "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/applicationinsights/client"
appPlatform "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/appplatform/client"
attestation "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/attestation/client"
authorization "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/authorization/client"
automation "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/automation/client"
batch "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/batch/client"
Expand Down Expand Up @@ -43,6 +44,7 @@ import (
timeseriesinsights "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/iottimeseriesinsights/client"
keyvault "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/keyvault/client"
kusto "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/kusto/client"
lighthouse "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/lighthouse/client"
loganalytics "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/loganalytics/client"
logic "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/logic/client"
machinelearning "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/machinelearning/client"
Expand Down Expand Up @@ -97,6 +99,7 @@ type Client struct {
AppConfiguration *appConfiguration.Client
AppInsights *applicationInsights.Client
AppPlatform *appPlatform.Client
Attestation *attestation.Client
Authorization *authorization.Client
Automation *automation.Client
Batch *batch.Client
Expand Down Expand Up @@ -128,6 +131,7 @@ type Client struct {
IoTTimeSeriesInsights *timeseriesinsights.Client
KeyVault *keyvault.Client
Kusto *kusto.Client
Lighthouse *lighthouse.Client
LogAnalytics *loganalytics.Client
Logic *logic.Client
MachineLearning *machinelearning.Client
Expand Down Expand Up @@ -183,6 +187,7 @@ func (client *Client) Build(ctx context.Context, o *common.ClientOptions) error
client.AppConfiguration = appConfiguration.NewClient(o)
client.AppInsights = applicationInsights.NewClient(o)
client.AppPlatform = appPlatform.NewClient(o)
client.Attestation = attestation.NewClient(o)
client.Authorization = authorization.NewClient(o)
client.Automation = automation.NewClient(o)
client.Batch = batch.NewClient(o)
Expand Down Expand Up @@ -214,6 +219,7 @@ func (client *Client) Build(ctx context.Context, o *common.ClientOptions) error
client.IoTTimeSeriesInsights = timeseriesinsights.NewClient(o)
client.KeyVault = keyvault.NewClient(o)
client.Kusto = kusto.NewClient(o)
client.Lighthouse = lighthouse.NewClient(o)
client.LogAnalytics = loganalytics.NewClient(o)
client.Logic = logic.NewClient(o)
client.MachineLearning = machinelearning.NewClient(o)
Expand Down
14 changes: 14 additions & 0 deletions azurerm/internal/features/beta_features_opt_in.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package features

import (
"os"
"strings"
)

// VMSSExtensionsBeta returns whether or not the beta for VMSS Extensions for Linux and Windows VMSS resources is
// enabled.
//
// Set the Environment Variable `ARM_PROVIDER_VMSS_EXTENSIONS_BETA` to `true`
func VMSSExtensionsBeta() bool {
return strings.EqualFold(os.Getenv("ARM_PROVIDER_VMSS_EXTENSIONS_BETA"), "true")
}
Loading

0 comments on commit 5f956cc

Please sign in to comment.