Skip to content

Commit

Permalink
Merge master into log-profile
Browse files Browse the repository at this point in the history
  • Loading branch information
katbyte committed Oct 15, 2018
2 parents abe39d7 + 6ed8129 commit 8f7b279
Show file tree
Hide file tree
Showing 76 changed files with 14,711 additions and 305 deletions.
14 changes: 12 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ FEATURES:
* **New Resource:** `azurerm_api_management` [GH-1516]
* **New Resource:** `azurerm_cognitive_account` [GH-962]
* **New Resource:** `azurerm_databricks_workspace` [GH-1134]
* **New Resource:** `azurerm_dev_test_policy` [GH-2070]
* **New Resource:** `azurerm_dev_test_linux_virtual_machine` [GH-2058]
* **New Resource:** `azurerm_dev_test_windows_virtual_machine` [GH-2058]
* **New Resource:** `azurerm_security_center_contact` [GH-2045]
* **New Resource:** `azurerm_security_center_subscription_pricing` [GH-2043]
* **New Resource:** `azurerm_security_center_workspace` [GH-2072]
* **New Resource:** `azurerm_subnet_network_security_group_association` [GH-1933]
* **New Resource:** `azurerm_subnet_route_table_association ` [GH-1933]

BUG FIXES:

Expand All @@ -19,10 +27,12 @@ BUG FIXES:

IMPROVEMENTS:

* `azurerm_application_gateway` - support for the `StandardV2` and `WAFV2` skus and tiers [GH-2015]
* `azurerm_application_gateway` - support for the `StandardV2` and `WAFV2` skus and tiers [GH-2015]
* `azurerm_dev_test_virtual_network` - support for managing the Subnet [GH-2041]
* `azurerm_key_vault` - support for Virtual Network Rules [GH-2027]
* `azurerm_kubernetes_cluster` - changing the `oms_agent` property no longer forces a new resource [GH-2021]

* `azurerm_postgresql_virtual_network_rule` - support for the `ignore_missing_vnet_service_endpoint` [GH-2056]
* `azurerm_public_ip` - support for IPv6 addresses [GH-2019]

## 1.16.0 (October 01, 2018)

Expand Down
31 changes: 31 additions & 0 deletions azurerm/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import (
"github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2015-11-01-preview/operationalinsights"
"github.com/Azure/azure-sdk-for-go/services/preview/operationsmanagement/mgmt/2015-11-01-preview/operationsmanagement"
"github.com/Azure/azure-sdk-for-go/services/preview/resources/mgmt/2018-03-01-preview/management"
"github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/2017-08-01-preview/security"
"github.com/Azure/azure-sdk-for-go/services/preview/sql/mgmt/2015-05-01-preview/sql"
"github.com/Azure/azure-sdk-for-go/services/recoveryservices/mgmt/2016-06-01/recoveryservices"
"github.com/Azure/azure-sdk-for-go/services/redis/mgmt/2018-03-01/redis"
Expand Down Expand Up @@ -154,6 +155,8 @@ type ArmClient struct {

// DevTestLabs
devTestLabsClient dtl.LabsClient
devTestPoliciesClient dtl.PoliciesClient
devTestVirtualMachinesClient dtl.VirtualMachinesClient
devTestVirtualNetworksClient dtl.VirtualNetworksClient

// Databases
Expand Down Expand Up @@ -255,6 +258,11 @@ type ArmClient struct {
// Search
searchServicesClient search.ServicesClient

// Security Centre
securityCenterPricingClient security.PricingsClient
securityCenterContactsClient security.ContactsClient
securityCenterWorkspaceClient security.WorkspaceSettingsClient

// ServiceBus
serviceBusQueuesClient servicebus.QueuesClient
serviceBusNamespacesClient servicebus.NamespacesClient
Expand Down Expand Up @@ -493,6 +501,7 @@ func getArmClient(c *authentication.Config) (*ArmClient, error) {
client.registerRelayClients(endpoint, c.SubscriptionID, auth, sender)
client.registerResourcesClients(endpoint, c.SubscriptionID, auth)
client.registerSearchClients(endpoint, c.SubscriptionID, auth)
client.registerSecurityCenterClients(endpoint, c.SubscriptionID, "Global", auth)
client.registerServiceBusClients(endpoint, c.SubscriptionID, auth)
client.registerServiceFabricClients(endpoint, c.SubscriptionID, auth)
client.registerSchedulerClients(endpoint, c.SubscriptionID, auth)
Expand Down Expand Up @@ -774,6 +783,14 @@ func (c *ArmClient) registerDevTestClients(endpoint, subscriptionId string, auth
c.configureClient(&labsClient.Client, auth)
c.devTestLabsClient = labsClient

devTestPoliciesClient := dtl.NewPoliciesClientWithBaseURI(endpoint, subscriptionId)
c.configureClient(&devTestPoliciesClient.Client, auth)
c.devTestPoliciesClient = devTestPoliciesClient

devTestVirtualMachinesClient := dtl.NewVirtualMachinesClientWithBaseURI(endpoint, subscriptionId)
c.configureClient(&devTestVirtualMachinesClient.Client, auth)
c.devTestVirtualMachinesClient = devTestVirtualMachinesClient

devTestVirtualNetworksClient := dtl.NewVirtualNetworksClientWithBaseURI(endpoint, subscriptionId)
c.configureClient(&devTestVirtualNetworksClient.Client, auth)
c.devTestVirtualNetworksClient = devTestVirtualNetworksClient
Expand Down Expand Up @@ -1021,6 +1038,20 @@ func (c *ArmClient) registerSearchClients(endpoint, subscriptionId string, auth
c.searchServicesClient = searchClient
}

func (c *ArmClient) registerSecurityCenterClients(endpoint, subscriptionId, ascLocation string, auth autorest.Authorizer) {
securityCenterPricingClient := security.NewPricingsClientWithBaseURI(endpoint, subscriptionId, ascLocation)
c.configureClient(&securityCenterPricingClient.Client, auth)
c.securityCenterPricingClient = securityCenterPricingClient

securityCenterContactsClient := security.NewContactsClientWithBaseURI(endpoint, subscriptionId, ascLocation)
c.configureClient(&securityCenterContactsClient.Client, auth)
c.securityCenterContactsClient = securityCenterContactsClient

securityCenterWorkspaceClient := security.NewWorkspaceSettingsClientWithBaseURI(endpoint, subscriptionId, ascLocation)
c.configureClient(&securityCenterWorkspaceClient.Client, auth)
c.securityCenterWorkspaceClient = securityCenterWorkspaceClient
}

func (c *ArmClient) registerServiceBusClients(endpoint, subscriptionId string, auth autorest.Authorizer) {
queuesClient := servicebus.NewQueuesClientWithBaseURI(endpoint, subscriptionId)
c.configureClient(&queuesClient.Client, auth)
Expand Down
4 changes: 2 additions & 2 deletions azurerm/data_source_dev_test_lab.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/azure"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/validate"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils"
)

Expand All @@ -16,7 +16,7 @@ func dataSourceArmDevTestLab() *schema.Resource {
"name": {
Type: schema.TypeString,
Required: true,
ValidateFunc: azure.ValidateDevTestLabName(),
ValidateFunc: validate.DevTestLabName(),
},

"location": locationForDataSourceSchema(),
Expand Down
9 changes: 9 additions & 0 deletions azurerm/data_source_public_ip.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ func dataSourceArmPublicIP() *schema.Resource {

"resource_group_name": resourceGroupNameForDataSourceSchema(),

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

"domain_name_label": {
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -73,6 +78,10 @@ func dataSourceArmPublicIPRead(d *schema.ResourceData, meta interface{}) error {
}
}

if ipVersion := props.PublicIPAddressVersion; string(ipVersion) != "" {
d.Set("ip_version", string(ipVersion))
}

if v := props.IPAddress; v != nil && *v != "" {
d.Set("ip_address", v)
}
Expand Down
1 change: 1 addition & 0 deletions azurerm/data_source_public_ip_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ func TestAccDataSourceAzureRMPublicIP_basic(t *testing.T) {
resource.TestCheckResourceAttr(dataSourceName, "idle_timeout_in_minutes", "30"),
resource.TestCheckResourceAttrSet(dataSourceName, "fqdn"),
resource.TestCheckResourceAttrSet(dataSourceName, "ip_address"),
resource.TestCheckResourceAttr(dataSourceName, "ip_version", "IPv4"),
resource.TestCheckResourceAttr(dataSourceName, "tags.%", "1"),
resource.TestCheckResourceAttr(dataSourceName, "tags.environment", "test"),
),
Expand Down
142 changes: 136 additions & 6 deletions azurerm/helpers/azure/devtest.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,144 @@
package azure

import (
"regexp"

"github.com/Azure/azure-sdk-for-go/services/devtestlabs/mgmt/2016-05-15/dtl"
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/helper/validation"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/validate"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils"
)

func ValidateDevTestLabName() schema.SchemaValidateFunc {
return validation.StringMatch(
regexp.MustCompile("^[A-Za-z0-9_-]+$"),
"Lab Name can only include alphanumeric characters, underscores, hyphens.")
func SchemaDevTestVirtualMachineInboundNatRule() *schema.Schema {
return &schema.Schema{
Type: schema.TypeSet,
Optional: true,
// since these aren't returned from the API
ForceNew: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"protocol": {
Type: schema.TypeString,
Required: true,
ValidateFunc: validation.StringInSlice([]string{
string(dtl.TCP),
string(dtl.UDP),
}, false),
},

"backend_port": {
Type: schema.TypeInt,
Required: true,
ForceNew: true,
ValidateFunc: validate.PortNumber,
},

"frontend_port": {
Type: schema.TypeInt,
Computed: true,
},
},
},
}
}

func ExpandDevTestLabVirtualMachineNatRules(input *schema.Set) []dtl.InboundNatRule {
rules := make([]dtl.InboundNatRule, 0)
if input == nil {
return rules
}

for _, val := range input.List() {
v := val.(map[string]interface{})
backendPort := v["backend_port"].(int)
protocol := v["protocol"].(string)

rule := dtl.InboundNatRule{
TransportProtocol: dtl.TransportProtocol(protocol),
BackendPort: utils.Int32(int32(backendPort)),
}

rules = append(rules, rule)
}

return rules
}

func ExpandDevTestLabVirtualMachineGalleryImageReference(input []interface{}, osType string) *dtl.GalleryImageReference {
if len(input) == 0 {
return nil
}

v := input[0].(map[string]interface{})
offer := v["offer"].(string)
publisher := v["publisher"].(string)
sku := v["sku"].(string)
version := v["version"].(string)

return &dtl.GalleryImageReference{
Offer: utils.String(offer),
OsType: utils.String(osType),
Publisher: utils.String(publisher),
Sku: utils.String(sku),
Version: utils.String(version),
}
}

func SchemaDevTestVirtualMachineGalleryImageReference() *schema.Schema {
return &schema.Schema{
Type: schema.TypeList,
Required: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"offer": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
"publisher": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
"sku": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
"version": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
},
},
}
}

func FlattenDevTestVirtualMachineGalleryImage(input *dtl.GalleryImageReference) []interface{} {
results := make([]interface{}, 0)

if input != nil {
output := make(map[string]interface{}, 0)

if input.Offer != nil {
output["offer"] = *input.Offer
}

if input.Publisher != nil {
output["publisher"] = *input.Publisher
}

if input.Sku != nil {
output["sku"] = *input.Sku
}

if input.Version != nil {
output["version"] = *input.Version
}

results = append(results, output)
}

return results
}
31 changes: 0 additions & 31 deletions azurerm/helpers/azure/devtest_test.go

This file was deleted.

2 changes: 1 addition & 1 deletion azurerm/helpers/validate/api_management.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func ApiManagementServiceName(v interface{}, k string) (ws []string, es []error)
func ApiManagementServicePublisherName(v interface{}, k string) (ws []string, es []error) {
value := v.(string)

if matched := regexp.MustCompile(`^[\S*]{1,100}$`).Match([]byte(value)); !matched {
if matched := regexp.MustCompile(`^.{1,100}$`).Match([]byte(value)); !matched {
es = append(es, fmt.Errorf("%q may only be up to 100 characters in length", k))
}

Expand Down
52 changes: 52 additions & 0 deletions azurerm/helpers/validate/api_management_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,55 @@ func TestAzureRMApiManagementServiceName_validation(t *testing.T) {
}
}
}

func TestAzureRMApiManagementPublisherName_validation(t *testing.T) {
cases := []struct {
Value string
ErrCount int
}{
{
Value: "",
ErrCount: 1,
},
{
Value: "a",
ErrCount: 0,
},
{
Value: "abc",
ErrCount: 0,
},
{
Value: "api1",
ErrCount: 0,
},
{
Value: "company-api",
ErrCount: 0,
},
{
Value: "hello_world",
ErrCount: 0,
},
{
Value: "helloworld21!",
ErrCount: 0,
},
{
Value: "company api",
ErrCount: 0,
},
{
Value: "alsdkjflasjkdflajsdlfjkalsdfjkalskdjflajksdflkjasdlfkjasldkfjalksdjflakjsdfljkasdlkfjalskdjfalksdjfdd",
ErrCount: 1,
},
}

for _, tc := range cases {
_, errors := ApiManagementServicePublisherName(tc.Value, "azurerm_api_management")

if len(errors) != tc.ErrCount {
t.Fatalf("Expected the Api Management Service Publisher Name to trigger a validation error for '%s'", tc.Value)
}
}
}
Loading

0 comments on commit 8f7b279

Please sign in to comment.