Skip to content

Commit

Permalink
Merge branch 'master' into ci_log
Browse files Browse the repository at this point in the history
  • Loading branch information
metacpp authored Feb 28, 2019
2 parents 4911eed + b8fe43d commit c26bbdb
Show file tree
Hide file tree
Showing 652 changed files with 50,570 additions and 4,720 deletions.
31 changes: 31 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
issues:
max-per-linter: 0
max-same-issues: 0

linters:
disable-all: true
enable:
- deadcode
- errcheck
- gofmt
- gosimple
- govet
- ineffassign
- interfacer
- nakedret
- misspell
- staticcheck
- structcheck
- typecheck
- unused
- unconvert
- varcheck
- vet
- vetshadow

linters-settings:
errcheck:
ignore: github.com/hashicorp/terraform/helper/schema:ForceNew|Set,fmt:.*,io:Close

run:
modules-download-mode: vendor
35 changes: 0 additions & 35 deletions .gometalinter.json

This file was deleted.

133 changes: 110 additions & 23 deletions CHANGELOG.md

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ goimport:

lint:
@echo "==> Checking source code against linters..."
@gometalinter ./...
golangci-lint run ./...

tools:
@echo "==> installing required tooling..."
@sh "$(CURDIR)/scripts/gogetcookie.sh"
GO111MODULE=off go get -u github.com/alecthomas/gometalinter
GO111MODULE=off gometalinter --install
GO111MODULE=off go get -u github.com/client9/misspell/cmd/misspell
GO111MODULE=off go get -u github.com/golangci/golangci-lint/cmd/golangci-lint

test-compile:
@if [ "$(TEST)" = "./..." ]; then \
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,9 @@ The following Environment Variables must be set in your shell prior to running a
- `ARM_TEST_LOCATION_ALT`

**Note:** Acceptance tests create real resources in Azure which often cost money to run.

Crosscompiling
--------------
```sh
GOOS=windows GOARCH=amd64 make build
```
50 changes: 43 additions & 7 deletions azurerm/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"time"

resourcesprofile "github.com/Azure/azure-sdk-for-go/profiles/2017-03-09/resources/mgmt/resources"
"github.com/Azure/azure-sdk-for-go/services/apimanagement/mgmt/2018-01-01/apimanagement"
appinsights "github.com/Azure/azure-sdk-for-go/services/appinsights/mgmt/2015-05-01/insights"
"github.com/Azure/azure-sdk-for-go/services/automation/mgmt/2015-10-31/automation"
"github.com/Azure/azure-sdk-for-go/services/batch/mgmt/2017-09-01/batch"
Expand All @@ -25,21 +26,21 @@ import (
"github.com/Azure/azure-sdk-for-go/services/datalake/store/2016-11-01/filesystem"
storeAccount "github.com/Azure/azure-sdk-for-go/services/datalake/store/mgmt/2016-11-01/account"
"github.com/Azure/azure-sdk-for-go/services/devtestlabs/mgmt/2016-05-15/dtl"
"github.com/Azure/azure-sdk-for-go/services/eventgrid/mgmt/2018-01-01/eventgrid"
"github.com/Azure/azure-sdk-for-go/services/eventhub/mgmt/2017-04-01/eventhub"
"github.com/Azure/azure-sdk-for-go/services/graphrbac/1.6/graphrbac"
"github.com/Azure/azure-sdk-for-go/services/iothub/mgmt/2018-04-01/devices"
keyVault "github.com/Azure/azure-sdk-for-go/services/keyvault/2016-10-01/keyvault"
"github.com/Azure/azure-sdk-for-go/services/keyvault/mgmt/2018-02-14/keyvault"
"github.com/Azure/azure-sdk-for-go/services/logic/mgmt/2016-06-01/logic"
"github.com/Azure/azure-sdk-for-go/services/mediaservices/mgmt/2018-07-01/media"
"github.com/Azure/azure-sdk-for-go/services/mysql/mgmt/2017-12-01/mysql"
"github.com/Azure/azure-sdk-for-go/services/network/mgmt/2018-08-01/network"
"github.com/Azure/azure-sdk-for-go/services/notificationhubs/mgmt/2017-04-01/notificationhubs"
"github.com/Azure/azure-sdk-for-go/services/postgresql/mgmt/2017-12-01/postgresql"
"github.com/Azure/azure-sdk-for-go/services/preview/apimanagement/mgmt/2018-06-01-preview/apimanagement"
"github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-01-01-preview/authorization"
"github.com/Azure/azure-sdk-for-go/services/preview/devspaces/mgmt/2018-06-01-preview/devspaces"
"github.com/Azure/azure-sdk-for-go/services/preview/dns/mgmt/2018-03-01-preview/dns"
"github.com/Azure/azure-sdk-for-go/services/preview/eventgrid/mgmt/2018-09-15-preview/eventgrid"
"github.com/Azure/azure-sdk-for-go/services/preview/iothub/mgmt/2018-12-01-preview/devices"
"github.com/Azure/azure-sdk-for-go/services/preview/mariadb/mgmt/2018-06-01-preview/mariadb"
"github.com/Azure/azure-sdk-for-go/services/preview/monitor/mgmt/2018-03-01/insights"
"github.com/Azure/azure-sdk-for-go/services/preview/msi/mgmt/2015-08-31-preview/msi"
Expand Down Expand Up @@ -112,6 +113,7 @@ type ArmClient struct {
kubernetesClustersClient containerservice.ManagedClustersClient
containerGroupsClient containerinstance.ContainerGroupsClient

eventGridDomainsClient eventgrid.DomainsClient
eventGridTopicsClient eventgrid.TopicsClient
eventHubClient eventhub.EventHubsClient
eventHubConsumerGroupClient eventhub.ConsumerGroupsClient
Expand All @@ -124,7 +126,10 @@ type ArmClient struct {
redisPatchSchedulesClient redis.PatchSchedulesClient

// API Management
apiManagementServiceClient apimanagement.ServiceClient
apiManagementGroupClient apimanagement.GroupClient
apiManagementProductsClient apimanagement.ProductClient
apiManagementServiceClient apimanagement.ServiceClient
apiManagementUsersClient apimanagement.UserClient

// Application Insights
appInsightsClient appinsights.ComponentsClient
Expand Down Expand Up @@ -228,6 +233,9 @@ type ArmClient struct {
managementGroupsClient managementgroups.Client
managementGroupsSubscriptionClient managementgroups.SubscriptionsClient

// Media
mediaServicesClient media.MediaservicesClient

// Monitor
monitorActionGroupsClient insights.ActionGroupsClient
monitorActivityLogAlertsClient insights.ActivityLogAlertsClient
Expand All @@ -244,6 +252,7 @@ type ArmClient struct {
applicationGatewayClient network.ApplicationGatewaysClient
applicationSecurityGroupsClient network.ApplicationSecurityGroupsClient
azureFirewallsClient network.AzureFirewallsClient
connectionMonitorsClient network.ConnectionMonitorsClient
ddosProtectionPlanClient network.DdosProtectionPlansClient
expressRouteAuthsClient network.ExpressRouteCircuitAuthorizationsClient
expressRouteCircuitClient network.ExpressRouteCircuitsClient
Expand Down Expand Up @@ -456,6 +465,7 @@ func getArmClient(c *authentication.Config, skipProviderRegistration bool, partn
client.registerEventHubClients(endpoint, c.SubscriptionID, auth)
client.registerKeyVaultClients(endpoint, c.SubscriptionID, auth, keyVaultAuth)
client.registerLogicClients(endpoint, c.SubscriptionID, auth)
client.registerMediaServiceClients(endpoint, c.SubscriptionID, auth)
client.registerMonitorClients(endpoint, c.SubscriptionID, auth)
client.registerNetworkingClients(endpoint, c.SubscriptionID, auth)
client.registerNotificationHubsClient(endpoint, c.SubscriptionID, auth)
Expand All @@ -480,9 +490,21 @@ func getArmClient(c *authentication.Config, skipProviderRegistration bool, partn
}

func (c *ArmClient) registerApiManagementServiceClients(endpoint, subscriptionId string, auth autorest.Authorizer) {
ams := apimanagement.NewServiceClientWithBaseURI(endpoint, subscriptionId)
c.configureClient(&ams.Client, auth)
c.apiManagementServiceClient = ams
groupsClient := apimanagement.NewGroupClientWithBaseURI(endpoint, subscriptionId)
c.configureClient(&groupsClient.Client, auth)
c.apiManagementGroupClient = groupsClient

serviceClient := apimanagement.NewServiceClientWithBaseURI(endpoint, subscriptionId)
c.configureClient(&serviceClient.Client, auth)
c.apiManagementServiceClient = serviceClient

productsClient := apimanagement.NewProductClientWithBaseURI(endpoint, subscriptionId)
c.configureClient(&productsClient.Client, auth)
c.apiManagementProductsClient = productsClient

usersClient := apimanagement.NewUserClientWithBaseURI(endpoint, subscriptionId)
c.configureClient(&usersClient.Client, auth)
c.apiManagementUsersClient = usersClient
}

func (c *ArmClient) registerAppInsightsClients(endpoint, subscriptionId string, auth autorest.Authorizer) {
Expand Down Expand Up @@ -587,6 +609,12 @@ func (c *ArmClient) registerCosmosDBClients(endpoint, subscriptionId string, aut
c.cosmosDBClient = cdb
}

func (c *ArmClient) registerMediaServiceClients(endpoint, subscriptionId string, auth autorest.Authorizer) {
mediaServicesClient := media.NewMediaservicesClientWithBaseURI(endpoint, subscriptionId)
c.configureClient(&mediaServicesClient.Client, auth)
c.mediaServicesClient = mediaServicesClient
}

func (c *ArmClient) registerComputeClients(endpoint, subscriptionId string, auth autorest.Authorizer) {
availabilitySetsClient := compute.NewAvailabilitySetsClientWithBaseURI(endpoint, subscriptionId)
c.configureClient(&availabilitySetsClient.Client, auth)
Expand Down Expand Up @@ -830,6 +858,10 @@ func (c *ArmClient) registerEventGridClients(endpoint, subscriptionId string, au
egtc := eventgrid.NewTopicsClientWithBaseURI(endpoint, subscriptionId)
c.configureClient(&egtc.Client, auth)
c.eventGridTopicsClient = egtc

egdc := eventgrid.NewDomainsClientWithBaseURI(endpoint, subscriptionId)
c.configureClient(&egdc.Client, auth)
c.eventGridDomainsClient = egdc
}

func (c *ArmClient) registerEventHubClients(endpoint, subscriptionId string, auth autorest.Authorizer) {
Expand Down Expand Up @@ -909,6 +941,10 @@ func (c *ArmClient) registerNetworkingClients(endpoint, subscriptionId string, a
c.configureClient(&azureFirewallsClient.Client, auth)
c.azureFirewallsClient = azureFirewallsClient

connectionMonitorsClient := network.NewConnectionMonitorsClientWithBaseURI(endpoint, subscriptionId)
c.configureClient(&connectionMonitorsClient.Client, auth)
c.connectionMonitorsClient = connectionMonitorsClient

ddosProtectionPlanClient := network.NewDdosProtectionPlansClientWithBaseURI(endpoint, subscriptionId)
c.configureClient(&ddosProtectionPlanClient.Client, auth)
c.ddosProtectionPlanClient = ddosProtectionPlanClient
Expand Down
10 changes: 3 additions & 7 deletions azurerm/data_source_api_management.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import (
"fmt"
"strings"

"github.com/Azure/azure-sdk-for-go/services/preview/apimanagement/mgmt/2018-06-01-preview/apimanagement"
"github.com/Azure/azure-sdk-for-go/services/apimanagement/mgmt/2018-01-01/apimanagement"
"github.com/hashicorp/terraform/helper/schema"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/validate"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils"
)

Expand All @@ -15,11 +15,7 @@ func dataSourceApiManagementService() *schema.Resource {
Read: dataSourceApiManagementRead,

Schema: map[string]*schema.Schema{
"name": {
Type: schema.TypeString,
Required: true,
ValidateFunc: validate.ApiManagementServiceName,
},
"name": azure.SchemaApiManagementDataSourceName(),

"resource_group_name": resourceGroupNameForDataSourceSchema(),

Expand Down
79 changes: 79 additions & 0 deletions azurerm/data_source_api_management_group.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
package azurerm

import (
"fmt"
"log"

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

func dataSourceApiManagementGroup() *schema.Resource {
return &schema.Resource{
Read: dataSourceApiManagementGroupRead,

Schema: map[string]*schema.Schema{
"name": azure.SchemaApiManagementChildDataSourceName(),

"resource_group_name": resourceGroupNameForDataSourceSchema(),

"api_management_name": azure.SchemaApiManagementDataSourceName(),

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

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

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

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

func dataSourceApiManagementGroupRead(d *schema.ResourceData, meta interface{}) error {
client := meta.(*ArmClient).apiManagementGroupClient
ctx := meta.(*ArmClient).StopContext

resourceGroup := d.Get("resource_group_name").(string)
serviceName := d.Get("api_management_name").(string)
name := d.Get("name").(string)

resp, err := client.Get(ctx, resourceGroup, serviceName, name)
if err != nil {
if utils.ResponseWasNotFound(resp.Response) {
log.Printf("[DEBUG] Group %q (Resource Group %q / API Management Service %q) was not found - removing from state!", name, resourceGroup, serviceName)
d.SetId("")
return nil
}

return fmt.Errorf("Error making Read request for Group %q (Resource Group %q / API Management Service %q): %+v", name, resourceGroup, serviceName, err)
}

d.SetId(*resp.ID)

d.Set("name", resp.Name)
d.Set("resource_group_name", resourceGroup)
d.Set("api_management_name", serviceName)

if properties := resp.GroupContractProperties; properties != nil {
d.Set("display_name", properties.DisplayName)
d.Set("description", properties.Description)
d.Set("external_id", properties.ExternalID)
d.Set("type", string(properties.Type))
}

return nil
}
Loading

0 comments on commit c26bbdb

Please sign in to comment.