From 68e9e2652021ffe2e4b89c5ef0730f6672c4ac77 Mon Sep 17 00:00:00 2001 From: tombuildsstuff Date: Fri, 30 Dec 2016 15:58:26 +0000 Subject: [PATCH 01/12] Fixing the indentation --- .../docs/providers/azurerm/r/cdn_profile.html.markdown | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/website/source/docs/providers/azurerm/r/cdn_profile.html.markdown b/website/source/docs/providers/azurerm/r/cdn_profile.html.markdown index d37a9022b198..9b8bcc4d3fd9 100644 --- a/website/source/docs/providers/azurerm/r/cdn_profile.html.markdown +++ b/website/source/docs/providers/azurerm/r/cdn_profile.html.markdown @@ -25,8 +25,8 @@ resource "azurerm_cdn_profile" "test" { sku = "Standard_Verizon" tags { - environment = "Production" - cost_center = "MSFT" + environment = "Production" + cost_center = "MSFT" } } ``` @@ -45,7 +45,7 @@ The following arguments are supported: * `sku` - (Required) The pricing related information of current CDN profile. Accepted values are `Standard_Verizon`, `Standard_Akamai` or `Premium_Verizon`. -* `tags` - (Optional) A mapping of tags to assign to the resource. +* `tags` - (Optional) A mapping of tags to assign to the resource. ## Attributes Reference @@ -55,8 +55,8 @@ The following attributes are exported: ## Import -CDN Profiles can be imported using the `resource id`, e.g. +CDN Profiles can be imported using the `resource id`, e.g. ``` terraform import azurerm_cdn_profile.test /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Cdn/profiles/myprofile1 -``` \ No newline at end of file +``` From 90303098015cb870ebe451594745f5bab87bcd8c Mon Sep 17 00:00:00 2001 From: tombuildsstuff Date: Fri, 30 Dec 2016 16:51:07 +0000 Subject: [PATCH 02/12] Adding the Container Registry SDK --- .../arm/containerregistry/client.go | 57 ++ .../arm/containerregistry/models.go | 118 +++ .../arm/containerregistry/registries.go | 685 ++++++++++++++++++ .../arm/containerregistry/version.go | 43 ++ vendor/vendor.json | 9 + 5 files changed, 912 insertions(+) create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/arm/containerregistry/client.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/arm/containerregistry/models.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/arm/containerregistry/registries.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/arm/containerregistry/version.go diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/containerregistry/client.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/containerregistry/client.go new file mode 100644 index 000000000000..2257c451fb11 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/containerregistry/client.go @@ -0,0 +1,57 @@ +// Package containerregistry implements the Azure ARM Containerregistry +// service API version 2016-06-27-preview. +// +package containerregistry + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" +) + +const ( + // APIVersion is the version of the Containerregistry + APIVersion = "2016-06-27-preview" + + // DefaultBaseURI is the default URI used for the service Containerregistry + DefaultBaseURI = "https://management.azure.com" +) + +// ManagementClient is the base client for Containerregistry. +type ManagementClient struct { + autorest.Client + BaseURI string + APIVersion string + SubscriptionID string +} + +// New creates an instance of the ManagementClient client. +func New(subscriptionID string) ManagementClient { + return NewWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewWithBaseURI creates an instance of the ManagementClient client. +func NewWithBaseURI(baseURI string, subscriptionID string) ManagementClient { + return ManagementClient{ + Client: autorest.NewClientWithUserAgent(UserAgent()), + BaseURI: baseURI, + APIVersion: APIVersion, + SubscriptionID: subscriptionID, + } +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/containerregistry/models.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/containerregistry/models.go new file mode 100644 index 000000000000..ecf1ca8f648e --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/containerregistry/models.go @@ -0,0 +1,118 @@ +package containerregistry + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/date" + "github.com/Azure/go-autorest/autorest/to" + "net/http" +) + +// Registry is an object that represents a container registry. +type Registry struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Location *string `json:"location,omitempty"` + Tags *map[string]*string `json:"tags,omitempty"` + *RegistryProperties `json:"properties,omitempty"` +} + +// RegistryCredentials is the result of a request to get the administrator +// login credentials for a container registry. +type RegistryCredentials struct { + autorest.Response `json:"-"` + Username *string `json:"username,omitempty"` + Password *string `json:"password,omitempty"` +} + +// RegistryListResult is the result of a request to list container registries. +type RegistryListResult struct { + autorest.Response `json:"-"` + Value *[]Registry `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// RegistryListResultPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client RegistryListResult) RegistryListResultPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + +// RegistryNameCheckRequest is a request to check whether the container +// registry name is available. +type RegistryNameCheckRequest struct { + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` +} + +// RegistryNameStatus is the result of a request to check the availability of +// a container registry name. +type RegistryNameStatus struct { + autorest.Response `json:"-"` + NameAvailable *bool `json:"nameAvailable,omitempty"` + Reason *string `json:"reason,omitempty"` + Message *string `json:"message,omitempty"` +} + +// RegistryProperties is the properties of a container registry. +type RegistryProperties struct { + LoginServer *string `json:"loginServer,omitempty"` + CreationDate *date.Time `json:"creationDate,omitempty"` + AdminUserEnabled *bool `json:"adminUserEnabled,omitempty"` + StorageAccount *StorageAccountProperties `json:"storageAccount,omitempty"` +} + +// RegistryPropertiesUpdateParameters is the parameters for updating the +// properties of a container registry. +type RegistryPropertiesUpdateParameters struct { + AdminUserEnabled *bool `json:"adminUserEnabled,omitempty"` + StorageAccount *StorageAccountProperties `json:"storageAccount,omitempty"` +} + +// RegistryUpdateParameters is the parameters for updating a container +// registry. +type RegistryUpdateParameters struct { + Tags *map[string]*string `json:"tags,omitempty"` + *RegistryPropertiesUpdateParameters `json:"properties,omitempty"` +} + +// Resource is an Azure resource. +type Resource struct { + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Location *string `json:"location,omitempty"` + Tags *map[string]*string `json:"tags,omitempty"` +} + +// StorageAccountProperties is the properties of a storage account for a +// container registry. +type StorageAccountProperties struct { + Name *string `json:"name,omitempty"` + AccessKey *string `json:"accessKey,omitempty"` +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/containerregistry/registries.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/containerregistry/registries.go new file mode 100644 index 000000000000..c658cccf580b --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/containerregistry/registries.go @@ -0,0 +1,685 @@ +package containerregistry + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// RegistriesClient is the client for the Registries methods of the +// Containerregistry service. +type RegistriesClient struct { + ManagementClient +} + +// NewRegistriesClient creates an instance of the RegistriesClient client. +func NewRegistriesClient(subscriptionID string) RegistriesClient { + return NewRegistriesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewRegistriesClientWithBaseURI creates an instance of the RegistriesClient +// client. +func NewRegistriesClientWithBaseURI(baseURI string, subscriptionID string) RegistriesClient { + return RegistriesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CheckNameAvailability checks whether the container registry name is +// available for use. The name must contain only alphanumeric characters, be +// globally unique, and between 5 and 60 characters in length. +// +// registryNameCheckRequest is the object containing information for the +// availability request. +func (client RegistriesClient) CheckNameAvailability(registryNameCheckRequest RegistryNameCheckRequest) (result RegistryNameStatus, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: registryNameCheckRequest, + Constraints: []validation.Constraint{{Target: "registryNameCheckRequest.Name", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "registryNameCheckRequest.Type", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "containerregistry.RegistriesClient", "CheckNameAvailability") + } + + req, err := client.CheckNameAvailabilityPreparer(registryNameCheckRequest) + if err != nil { + return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "CheckNameAvailability", nil, "Failure preparing request") + } + + resp, err := client.CheckNameAvailabilitySender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "CheckNameAvailability", resp, "Failure sending request") + } + + result, err = client.CheckNameAvailabilityResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "CheckNameAvailability", resp, "Failure responding to request") + } + + return +} + +// CheckNameAvailabilityPreparer prepares the CheckNameAvailability request. +func (client RegistriesClient) CheckNameAvailabilityPreparer(registryNameCheckRequest RegistryNameCheckRequest) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + queryParameters := map[string]interface{}{ + "api-version": client.APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/checkNameAvailability", pathParameters), + autorest.WithJSON(registryNameCheckRequest), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// CheckNameAvailabilitySender sends the CheckNameAvailability request. The method will close the +// http.Response Body if it receives an error. +func (client RegistriesClient) CheckNameAvailabilitySender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// CheckNameAvailabilityResponder handles the response to the CheckNameAvailability request. The method always +// closes the http.Response Body. +func (client RegistriesClient) CheckNameAvailabilityResponder(resp *http.Response) (result RegistryNameStatus, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// CreateOrUpdate creates or updates a container registry with the specified +// parameters. +// +// resourceGroupName is the name of the resource group to which the container +// registry belongs. registryName is the name of the container registry. +// registry is the parameters for creating or updating a container registry. +func (client RegistriesClient) CreateOrUpdate(resourceGroupName string, registryName string, registry Registry) (result Registry, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: registry, + Constraints: []validation.Constraint{{Target: "registry.RegistryProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "registry.RegistryProperties.StorageAccount", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "registry.RegistryProperties.StorageAccount.Name", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "registry.RegistryProperties.StorageAccount.AccessKey", Name: validation.Null, Rule: true, Chain: nil}, + }}, + {Target: "registry.RegistryProperties.LoginServer", Name: validation.ReadOnly, Rule: true, Chain: nil}, + {Target: "registry.RegistryProperties.CreationDate", Name: validation.ReadOnly, Rule: true, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "containerregistry.RegistriesClient", "CreateOrUpdate") + } + + req, err := client.CreateOrUpdatePreparer(resourceGroupName, registryName, registry) + if err != nil { + return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "CreateOrUpdate", nil, "Failure preparing request") + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "CreateOrUpdate", resp, "Failure sending request") + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client RegistriesClient) CreateOrUpdatePreparer(resourceGroupName string, registryName string, registry Registry) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "registryName": autorest.Encode("path", registryName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + queryParameters := map[string]interface{}{ + "api-version": client.APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}", pathParameters), + autorest.WithJSON(registry), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client RegistriesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client RegistriesClient) CreateOrUpdateResponder(resp *http.Response) (result Registry, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a container registry. +// +// resourceGroupName is the name of the resource group to which the container +// registry belongs. registryName is the name of the container registry. +func (client RegistriesClient) Delete(resourceGroupName string, registryName string) (result autorest.Response, err error) { + req, err := client.DeletePreparer(resourceGroupName, registryName) + if err != nil { + return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Delete", nil, "Failure preparing request") + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Delete", resp, "Failure sending request") + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client RegistriesClient) DeletePreparer(resourceGroupName string, registryName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "registryName": autorest.Encode("path", registryName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + queryParameters := map[string]interface{}{ + "api-version": client.APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client RegistriesClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client RegistriesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// GetCredentials gets the administrator login credentials for the specified +// container registry. +// +// resourceGroupName is the name of the resource group to which the container +// registry belongs. registryName is the name of the container registry. +func (client RegistriesClient) GetCredentials(resourceGroupName string, registryName string) (result RegistryCredentials, err error) { + req, err := client.GetCredentialsPreparer(resourceGroupName, registryName) + if err != nil { + return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "GetCredentials", nil, "Failure preparing request") + } + + resp, err := client.GetCredentialsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "GetCredentials", resp, "Failure sending request") + } + + result, err = client.GetCredentialsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "GetCredentials", resp, "Failure responding to request") + } + + return +} + +// GetCredentialsPreparer prepares the GetCredentials request. +func (client RegistriesClient) GetCredentialsPreparer(resourceGroupName string, registryName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "registryName": autorest.Encode("path", registryName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + queryParameters := map[string]interface{}{ + "api-version": client.APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/getCredentials", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetCredentialsSender sends the GetCredentials request. The method will close the +// http.Response Body if it receives an error. +func (client RegistriesClient) GetCredentialsSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetCredentialsResponder handles the response to the GetCredentials request. The method always +// closes the http.Response Body. +func (client RegistriesClient) GetCredentialsResponder(resp *http.Response) (result RegistryCredentials, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetProperties gets the properties of the specified container registry. +// +// resourceGroupName is the name of the resource group to which the container +// registry belongs. registryName is the name of the container registry. +func (client RegistriesClient) GetProperties(resourceGroupName string, registryName string) (result Registry, err error) { + req, err := client.GetPropertiesPreparer(resourceGroupName, registryName) + if err != nil { + return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "GetProperties", nil, "Failure preparing request") + } + + resp, err := client.GetPropertiesSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "GetProperties", resp, "Failure sending request") + } + + result, err = client.GetPropertiesResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "GetProperties", resp, "Failure responding to request") + } + + return +} + +// GetPropertiesPreparer prepares the GetProperties request. +func (client RegistriesClient) GetPropertiesPreparer(resourceGroupName string, registryName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "registryName": autorest.Encode("path", registryName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + queryParameters := map[string]interface{}{ + "api-version": client.APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetPropertiesSender sends the GetProperties request. The method will close the +// http.Response Body if it receives an error. +func (client RegistriesClient) GetPropertiesSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetPropertiesResponder handles the response to the GetProperties request. The method always +// closes the http.Response Body. +func (client RegistriesClient) GetPropertiesResponder(resp *http.Response) (result Registry, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List lists all the available container registries under the specified +// subscription. +func (client RegistriesClient) List() (result RegistryListResult, err error) { + req, err := client.ListPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "List", nil, "Failure preparing request") + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "List", resp, "Failure sending request") + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client RegistriesClient) ListPreparer() (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + queryParameters := map[string]interface{}{ + "api-version": client.APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/registries", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client RegistriesClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client RegistriesClient) ListResponder(resp *http.Response) (result RegistryListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListNextResults retrieves the next set of results, if any. +func (client RegistriesClient) ListNextResults(lastResults RegistryListResult) (result RegistryListResult, err error) { + req, err := lastResults.RegistryListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "List", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "List", resp, "Failure sending next results request") + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "List", resp, "Failure responding to next results request") + } + + return +} + +// ListByResourceGroup lists all the available container registries under the +// specified resource group. +// +// resourceGroupName is the name of the resource group to which the container +// registry belongs. +func (client RegistriesClient) ListByResourceGroup(resourceGroupName string) (result RegistryListResult, err error) { + req, err := client.ListByResourceGroupPreparer(resourceGroupName) + if err != nil { + return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "ListByResourceGroup", nil, "Failure preparing request") + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "ListByResourceGroup", resp, "Failure sending request") + } + + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "ListByResourceGroup", resp, "Failure responding to request") + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client RegistriesClient) ListByResourceGroupPreparer(resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + queryParameters := map[string]interface{}{ + "api-version": client.APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client RegistriesClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client RegistriesClient) ListByResourceGroupResponder(resp *http.Response) (result RegistryListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByResourceGroupNextResults retrieves the next set of results, if any. +func (client RegistriesClient) ListByResourceGroupNextResults(lastResults RegistryListResult) (result RegistryListResult, err error) { + req, err := lastResults.RegistryListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "ListByResourceGroup", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "ListByResourceGroup", resp, "Failure sending next results request") + } + + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "ListByResourceGroup", resp, "Failure responding to next results request") + } + + return +} + +// RegenerateCredentials regenerates the administrator login credentials for +// the specified container registry. +// +// resourceGroupName is the name of the resource group to which the container +// registry belongs. registryName is the name of the container registry. +func (client RegistriesClient) RegenerateCredentials(resourceGroupName string, registryName string) (result RegistryCredentials, err error) { + req, err := client.RegenerateCredentialsPreparer(resourceGroupName, registryName) + if err != nil { + return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "RegenerateCredentials", nil, "Failure preparing request") + } + + resp, err := client.RegenerateCredentialsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "RegenerateCredentials", resp, "Failure sending request") + } + + result, err = client.RegenerateCredentialsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "RegenerateCredentials", resp, "Failure responding to request") + } + + return +} + +// RegenerateCredentialsPreparer prepares the RegenerateCredentials request. +func (client RegistriesClient) RegenerateCredentialsPreparer(resourceGroupName string, registryName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "registryName": autorest.Encode("path", registryName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + queryParameters := map[string]interface{}{ + "api-version": client.APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/regenerateCredentials", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// RegenerateCredentialsSender sends the RegenerateCredentials request. The method will close the +// http.Response Body if it receives an error. +func (client RegistriesClient) RegenerateCredentialsSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// RegenerateCredentialsResponder handles the response to the RegenerateCredentials request. The method always +// closes the http.Response Body. +func (client RegistriesClient) RegenerateCredentialsResponder(resp *http.Response) (result RegistryCredentials, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update updates a container registry with the specified parameters. +// +// resourceGroupName is the name of the resource group to which the container +// registry belongs. registryName is the name of the container registry. +// registryUpdateParameters is the parameters for updating a container +// registry. +func (client RegistriesClient) Update(resourceGroupName string, registryName string, registryUpdateParameters RegistryUpdateParameters) (result Registry, err error) { + req, err := client.UpdatePreparer(resourceGroupName, registryName, registryUpdateParameters) + if err != nil { + return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Update", nil, "Failure preparing request") + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Update", resp, "Failure sending request") + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client RegistriesClient) UpdatePreparer(resourceGroupName string, registryName string, registryUpdateParameters RegistryUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "registryName": autorest.Encode("path", registryName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + queryParameters := map[string]interface{}{ + "api-version": client.APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}", pathParameters), + autorest.WithJSON(registryUpdateParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client RegistriesClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client RegistriesClient) UpdateResponder(resp *http.Response) (result Registry, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/containerregistry/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/containerregistry/version.go new file mode 100644 index 000000000000..e0d70c1b510c --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/containerregistry/version.go @@ -0,0 +1,43 @@ +package containerregistry + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "fmt" +) + +const ( + major = "7" + minor = "0" + patch = "1" + // Always begin a "tag" with a dash (as per http://semver.org) + tag = "-beta" + semVerFormat = "%s.%s.%s%s" + userAgentFormat = "Azure-SDK-for-Go/%s arm-%s/%s" +) + +// UserAgent returns the UserAgent string to use when sending http.Requests. +func UserAgent() string { + return fmt.Sprintf(userAgentFormat, Version(), "containerregistry", "2016-06-27-preview") +} + +// Version returns the semantic version (see http://semver.org) of the client. +func Version() string { + return fmt.Sprintf(semVerFormat, major, minor, patch, tag) +} diff --git a/vendor/vendor.json b/vendor/vendor.json index e3cb4b9955af..c81faa29b325 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -11,6 +11,15 @@ "version": "v7.0.1-beta", "versionExact": "v7.0.1-beta" }, + { + "checksumSHA1": "duGYYmAIPryWG256C+VrJgNy1uU=", + "comment": "v2.1.1-beta-8-gca4d906", + "path": "github.com/Azure/azure-sdk-for-go/arm/containerregistry", + "revision": "0984e0641ae43b89283223034574d6465be93bf4", + "revisionTime": "2016-11-30T22:29:01Z", + "version": "v7.0.1-beta", + "versionExact": "v7.0.1-beta" + }, { "checksumSHA1": "duGYYmAIPryWG256C+VrJgNy1uU=", "comment": "v2.1.1-beta-8-gca4d906", From eb47ac71bc09d0e936d6848428e847a2f292433b Mon Sep 17 00:00:00 2001 From: tombuildsstuff Date: Fri, 30 Dec 2016 16:51:45 +0000 Subject: [PATCH 03/12] Implementing the container registry --- .../resource_arm_container_registry.go | 216 ++++++++++++++++++ 1 file changed, 216 insertions(+) create mode 100644 builtin/providers/azurerm/resource_arm_container_registry.go diff --git a/builtin/providers/azurerm/resource_arm_container_registry.go b/builtin/providers/azurerm/resource_arm_container_registry.go new file mode 100644 index 000000000000..976c599fb58d --- /dev/null +++ b/builtin/providers/azurerm/resource_arm_container_registry.go @@ -0,0 +1,216 @@ +package azurerm + +import ( + "fmt" + "log" + + "net/http" + + "github.com/Azure/azure-sdk-for-go/arm/containerregistry" + "github.com/hashicorp/terraform/helper/hashcode" + "github.com/hashicorp/terraform/helper/schema" +) + +func resourceArmContainerRegistry() *schema.Resource { + return &schema.Resource{ + Create: resourceArmContainerRegistryCreate, + Read: resourceArmContainerRegistryRead, + Update: resourceArmContainerRegistryCreate, + Delete: resourceArmContainerRegistryDelete, + Importer: &schema.ResourceImporter{ + State: schema.ImportStatePassthrough, + }, + + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + + "resource_group_name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + + "location": locationSchema(), + + "admin_enabled": { + Type: schema.TypeBool, + Optional: true, + Default: false, + }, + + "storage_account": { + Type: schema.TypeSet, + Required: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + }, + + "access_key": { + Type: schema.TypeString, + Required: true, + Sensitive: true, + }, + }, + }, + }, + + "login_server": { + Type: schema.TypeString, + Computed: true, + }, + + "admin_username": { + Type: schema.TypeString, + Computed: true, + }, + + "admin_password": { + Type: schema.TypeString, + Computed: true, + }, + + "tags": tagsSchema(), + }, + } +} + +func resourceArmContainerRegistryCreate(d *schema.ResourceData, meta interface{}) error { + client := meta.(*ArmClient).containerRegistryClient + log.Printf("[INFO] preparing arguments for AzureRM Container Registry creation.") + + resourceGroup := d.Get("resource_group_name").(string) + name := d.Get("name").(string) + location := d.Get("location").(string) + + adminUserEnabled := d.Get("admin_enabled").(bool) + tags := d.Get("tags").(map[string]interface{}) + + parameters := containerregistry.Registry{ + Location: &location, + RegistryProperties: &containerregistry.RegistryProperties{ + AdminUserEnabled: &adminUserEnabled, + }, + Tags: expandTags(tags), + } + + if v, ok := d.GetOk("storage_account"); ok { + accounts := v.(*schema.Set).List() + account := accounts[0].(map[string]interface{}) + storageAccountName := account["name"].(string) + storageAccountAccessKey := account["access_key"].(string) + parameters.RegistryProperties.StorageAccount = &containerregistry.StorageAccountProperties{ + Name: &storageAccountName, + AccessKey: &storageAccountAccessKey, + } + } + + _, err := client.CreateOrUpdate(resourceGroup, name, parameters) + if err != nil { + return err + } + + read, err := client.GetProperties(resourceGroup, name) + if err != nil { + return err + } + + if read.ID == nil { + return fmt.Errorf("Cannot read Container Registry %s (resource group %s) ID", name, resourceGroup) + } + + d.SetId(*read.ID) + + return resourceArmContainerRegistryRead(d, meta) +} + +func resourceArmContainerRegistryRead(d *schema.ResourceData, meta interface{}) error { + client := meta.(*ArmClient).containerRegistryClient + + id, err := parseAzureResourceID(d.Id()) + if err != nil { + return err + } + resourceGroup := id.ResourceGroup + name := id.Path["registries"] + + resp, err := client.GetProperties(resourceGroup, name) + if err != nil { + return fmt.Errorf("Error making Read request on Azure Container Registry %s: %s", name, err) + } + if resp.StatusCode == http.StatusNotFound { + d.SetId("") + return nil + } + + d.Set("name", resp.Name) + d.Set("resource_group_name", resourceGroup) + d.Set("location", azureRMNormalizeLocation(*resp.Location)) + d.Set("admin_enabled", resp.AdminUserEnabled) + d.Set("login_server", resp.LoginServer) + + if resp.StorageAccount != nil { + flattenArmContainerRegistryStorageAccount(d, resp.StorageAccount) + } + + if *resp.AdminUserEnabled { + credsResp, err := client.GetCredentials(resourceGroup, name) + if err != nil { + return fmt.Errorf("Error making Read request on Azure Container Registry %s for Credentials: %s", name, err) + } + + d.Set("admin_username", credsResp.Username) + d.Set("admin_password", credsResp.Password) + } else { + d.Set("admin_username", "") + d.Set("admin_password", "") + } + + flattenAndSetTags(d, resp.Tags) + + return nil +} + +func resourceArmContainerRegistryDelete(d *schema.ResourceData, meta interface{}) error { + client := meta.(*ArmClient).containerRegistryClient + + id, err := parseAzureResourceID(d.Id()) + if err != nil { + return err + } + resourceGroup := id.ResourceGroup + name := id.Path["registries"] + + resp, err := client.Delete(resourceGroup, name) + + if resp.StatusCode != http.StatusOK { + return fmt.Errorf("Error issuing Azure ARM delete request of ContainerRegistry '%s': %s", name, err) + } + + return nil +} + +func flattenArmContainerRegistryStorageAccount(d *schema.ResourceData, properties *containerregistry.StorageAccountProperties) { + storageAccounts := schema.Set{ + F: resourceAzureRMContainerRegistryStorageAccountHash, + } + + storageAccount := map[string]interface{}{} + storageAccount["name"] = properties.Name + storageAccounts.Add(storageAccount) + + d.Set("storage_account", &storageAccounts) +} + +func resourceAzureRMContainerRegistryStorageAccountHash(v interface{}) int { + m := v.(map[string]interface{}) + name := m["name"].(*string) + return hashcode.String(*name) +} From 92755ccdc3a1ea8d7c033f4ee799d4ee3e8fd3be Mon Sep 17 00:00:00 2001 From: tombuildsstuff Date: Fri, 30 Dec 2016 16:52:55 +0000 Subject: [PATCH 04/12] Enabling the provider / registering the Resource Provider --- builtin/providers/azurerm/config.go | 9 +++++++++ builtin/providers/azurerm/provider.go | 8 +++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/builtin/providers/azurerm/config.go b/builtin/providers/azurerm/config.go index d72363f6d2b5..22a6bf977fcd 100644 --- a/builtin/providers/azurerm/config.go +++ b/builtin/providers/azurerm/config.go @@ -9,6 +9,7 @@ import ( "github.com/Azure/azure-sdk-for-go/arm/cdn" "github.com/Azure/azure-sdk-for-go/arm/compute" + "github.com/Azure/azure-sdk-for-go/arm/containerregistry" "github.com/Azure/azure-sdk-for-go/arm/eventhub" "github.com/Azure/azure-sdk-for-go/arm/keyvault" "github.com/Azure/azure-sdk-for-go/arm/network" @@ -63,6 +64,8 @@ type ArmClient struct { cdnProfilesClient cdn.ProfilesClient cdnEndpointsClient cdn.EndpointsClient + containerRegistryClient containerregistry.RegistriesClient + eventHubClient eventhub.EventHubsClient eventHubConsumerGroupClient eventhub.ConsumerGroupsClient eventHubNamespacesClient eventhub.NamespacesClient @@ -221,6 +224,12 @@ func (c *Config) getArmClient() (*ArmClient, error) { agc.Sender = autorest.CreateSender(withRequestLogging()) client.appGatewayClient = agc + crc := containerregistry.NewRegistriesClient(c.SubscriptionID) + setUserAgent(&crc.Client) + crc.Authorizer = spt + crc.Sender = autorest.CreateSender(withRequestLogging()) + client.containerRegistryClient = crc + ehc := eventhub.NewEventHubsClient(c.SubscriptionID) setUserAgent(&ehc.Client) ehc.Authorizer = spt diff --git a/builtin/providers/azurerm/provider.go b/builtin/providers/azurerm/provider.go index d1fa7d682257..28967a0b22ec 100644 --- a/builtin/providers/azurerm/provider.go +++ b/builtin/providers/azurerm/provider.go @@ -51,9 +51,10 @@ func Provider() terraform.ResourceProvider { ResourcesMap: map[string]*schema.Resource{ // These resources use the Azure ARM SDK - "azurerm_availability_set": resourceArmAvailabilitySet(), - "azurerm_cdn_endpoint": resourceArmCdnEndpoint(), - "azurerm_cdn_profile": resourceArmCdnProfile(), + "azurerm_availability_set": resourceArmAvailabilitySet(), + "azurerm_cdn_endpoint": resourceArmCdnEndpoint(), + "azurerm_cdn_profile": resourceArmCdnProfile(), + "azurerm_container_registry": resourceArmContainerRegistry(), "azurerm_eventhub": resourceArmEventHub(), "azurerm_eventhub_consumer_group": resourceArmEventHubConsumerGroup(), @@ -209,6 +210,7 @@ func registerAzureResourceProvidersWithSubscription(client *riviera.Client) erro // We register Microsoft.Compute during client initialization providers := []string{ "Microsoft.Cache", + "Microsoft.ContainerRegistry", "Microsoft.Network", "Microsoft.Cdn", "Microsoft.Storage", From de815b7d1df851c43dd2751ea92be983039dd6e5 Mon Sep 17 00:00:00 2001 From: tombuildsstuff Date: Fri, 30 Dec 2016 16:53:16 +0000 Subject: [PATCH 05/12] Acceptance Tests --- .../resource_arm_container_registry_test.go | 159 ++++++++++++++++++ 1 file changed, 159 insertions(+) create mode 100644 builtin/providers/azurerm/resource_arm_container_registry_test.go diff --git a/builtin/providers/azurerm/resource_arm_container_registry_test.go b/builtin/providers/azurerm/resource_arm_container_registry_test.go new file mode 100644 index 000000000000..526929b6e75b --- /dev/null +++ b/builtin/providers/azurerm/resource_arm_container_registry_test.go @@ -0,0 +1,159 @@ +package azurerm + +import ( + "fmt" + "net/http" + "testing" + + "github.com/hashicorp/terraform/helper/acctest" + "github.com/hashicorp/terraform/helper/resource" + "github.com/hashicorp/terraform/terraform" +) + +func TestAccAzureRMContainerRegistry_basic(t *testing.T) { + ri := acctest.RandInt() + config := fmt.Sprintf(testAccAzureRMContainerRegistry_basic, ri, ri, ri) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMContainerRegistryDestroy, + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMContainerRegistryExists("azurerm_container_registry.test"), + ), + }, + }, + }) +} + +func TestAccAzureRMContainerRegistry_complete(t *testing.T) { + + ri := acctest.RandInt() + config := fmt.Sprintf(testAccAzureRMContainerRegistry_complete, ri, ri, ri) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMContainerRegistryDestroy, + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMContainerRegistryExists("azurerm_container_registry.test"), + ), + }, + }, + }) +} + +func testCheckAzureRMContainerRegistryDestroy(s *terraform.State) error { + conn := testAccProvider.Meta().(*ArmClient).containerRegistryClient + + for _, rs := range s.RootModule().Resources { + if rs.Type != "azurerm_container_registry" { + continue + } + + name := rs.Primary.Attributes["name"] + resourceGroup := rs.Primary.Attributes["resource_group_name"] + + resp, err := conn.GetProperties(resourceGroup, name) + + if err != nil { + return nil + } + + if resp.StatusCode != http.StatusNotFound { + return fmt.Errorf("Container Registry still exists:\n%#v", resp) + } + } + + return nil +} + +func testCheckAzureRMContainerRegistryExists(name string) resource.TestCheckFunc { + return func(s *terraform.State) error { + // Ensure we have enough information in state to look up in API + rs, ok := s.RootModule().Resources[name] + if !ok { + return fmt.Errorf("Not found: %s", name) + } + + name := rs.Primary.Attributes["name"] + resourceGroup, hasResourceGroup := rs.Primary.Attributes["resource_group_name"] + if !hasResourceGroup { + return fmt.Errorf("Bad: no resource group found in state for Container Registry: %s", name) + } + + conn := testAccProvider.Meta().(*ArmClient).containerRegistryClient + + resp, err := conn.GetProperties(resourceGroup, name) + if err != nil { + return fmt.Errorf("Bad: Get on containerRegistryClient: %s", err) + } + + if resp.StatusCode == http.StatusNotFound { + return fmt.Errorf("Bad: Container Registry %q (resource group: %q) does not exist", name, resourceGroup) + } + + return nil + } +} + +var testAccAzureRMContainerRegistry_basic = ` +resource "azurerm_resource_group" "test" { + name = "testAccRg-%d" + location = "West US" +} + +resource "azurerm_storage_account" "test" { + name = "testAccSa-%d" + resource_group_name = "${azurerm_resource_group.test.name}" + location = "${azurerm_resource_group.test.location}" + account_type = "Standard_LRS" +} + +resource "azurerm_container_registry" "test" { + name = "testAccCr-%d" + resource_group_name = "${azurerm_resource_group.test.name}" + location = "${azurerm_resource_group.test.location}" + + storage_account { + name = "${azurerm_storage_account.test.name}" + access_key = "${azurerm_storage_account.test.primary_access_key}" + } +} +` + +var testAccAzureRMContainerRegistry_complete = ` +resource "azurerm_resource_group" "test" { + name = "testAccRg-%d" + location = "West US" +} + +resource "azurerm_storage_account" "test" { + name = "testAccSa-%d" + resource_group_name = "${azurerm_resource_group.test.name}" + location = "${azurerm_resource_group.test.location}" + account_type = "Standard_LRS" +} + +resource "azurerm_container_registry" "test" { + name = "testAccCr-%d" + resource_group_name = "${azurerm_resource_group.test.name}" + location = "${azurerm_resource_group.test.location}" + admin_enabled = false + + storage_account { + name = "${azurerm_storage_account.test.name}" + access_key = "${azurerm_storage_account.test.primary_access_key}" + } + + tags { + environment = "production" + } +} +` From 1faaa334767dd21adb4270e5a4bb7daf76dfffe6 Mon Sep 17 00:00:00 2001 From: tombuildsstuff Date: Fri, 30 Dec 2016 16:53:23 +0000 Subject: [PATCH 06/12] Documentation for Container Registry --- .../r/container_registry.html.markdown | 75 +++++++++++++++++++ website/source/layouts/azurerm.erb | 11 +++ 2 files changed, 86 insertions(+) create mode 100644 website/source/docs/providers/azurerm/r/container_registry.html.markdown diff --git a/website/source/docs/providers/azurerm/r/container_registry.html.markdown b/website/source/docs/providers/azurerm/r/container_registry.html.markdown new file mode 100644 index 000000000000..aee4315faf85 --- /dev/null +++ b/website/source/docs/providers/azurerm/r/container_registry.html.markdown @@ -0,0 +1,75 @@ +--- +layout: "azurerm" +page_title: "Azure Resource Manager: azurerm_container_registry" +sidebar_current: "docs-azurerm-resource-container-registry" +description: |- + Create as an Azure Container Registry instance. +--- + +# azurerm\_container\_registry + +Create as an Azure Container Registry instance. + +## Example Usage + +``` +resource "azurerm_resource_group" "test" { + name = "resourceGroup1" + location = "West US" +} + +resource "azurerm_storage_account" "test" { + name = "storageAccount1" + resource_group_name = "${azurerm_resource_group.test.name}" + location = "${azurerm_resource_group.test.location}" + account_type = "Standard_GRS" +} + +resource "azurerm_container_registry" "test" { + name = "containerRegistry1" + resource_group_name = "${azurerm_resource_group.test.name}" + location = "${azurerm_resource_group.test.location}" + admin_enabled = true + + storage_account { + name = "${azurerm_storage_account.test.name}" + access_key = "${azurerm_storage_account.test.primary_access_key}" + } +} + +``` + +## Argument Reference + +The following arguments are supported: + +* `name` - (Required) Specifies the name of the Container Registry. Changing this forces a + new resource to be created. + +* `resource_group_name` - (Required) The name of the resource group in which to + create the Container Registry. + +* `location` - (Required) Specifies the supported Azure location where the resource exists. Changing this forces a new resource to be created. + +* `admin_enabled` - (Optional) Specifies whether the admin user is enabled. Defaults to `false`. + +* `storage_account` - (Required) A Storage Account block as documented below - which must be located in the same data center as the Container Registry. + +* `tags` - (Optional) A mapping of tags to assign to the resource. + +`storage_account` supports the following: + +* `name` - (Required) The name of the storage account. If specified, the storage account must be in the same physical location as the Container Registry. +* `access_key` - (Required) The access key to the storage account. + +## Attributes Reference + +The following attributes are exported: + +* `id` - The Container Registry ID. + +* `login_server` - The URL that can be used to log into the container registry. + +* `admin_username` - The Username associated with the Container Registry Admin account - if the admin account is enabled. + +* `admin_password` - The Password associated with the Container Registry Admin account - if the admin account is enabled. diff --git a/website/source/layouts/azurerm.erb b/website/source/layouts/azurerm.erb index d66b04391c2c..58038c9441ba 100644 --- a/website/source/layouts/azurerm.erb +++ b/website/source/layouts/azurerm.erb @@ -44,6 +44,17 @@ + > + Container Resources + + + > DNS Resources