From de74608d37c8518da857d215140d8232a95d9d03 Mon Sep 17 00:00:00 2001 From: Clint Shryock Date: Mon, 27 Jul 2015 10:22:35 -0500 Subject: [PATCH 1/3] provider/azure: Note to Instance docs about some images requiring a Storage Service --- website/source/docs/providers/azure/r/instance.html.markdown | 3 ++- .../docs/providers/azure/r/storage_service.html.markdown | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/website/source/docs/providers/azure/r/instance.html.markdown b/website/source/docs/providers/azure/r/instance.html.markdown index 6b9428762626..f983c622a07b 100644 --- a/website/source/docs/providers/azure/r/instance.html.markdown +++ b/website/source/docs/providers/azure/r/instance.html.markdown @@ -72,7 +72,8 @@ The following arguments are supported: * `storage_service_name` - (Optional) The name of an existing storage account within the subscription which will be used to store the VHDs of this - instance. Changing this forces a new resource to be created. + instance. Changing this forces a new resource to be created. **A Storage + Service is required if you are using a Platform Image** * `reverse_dns` - (Optional) The DNS address to which the IP address of the hosted service resolves when queried using a reverse DNS query. Changing diff --git a/website/source/docs/providers/azure/r/storage_service.html.markdown b/website/source/docs/providers/azure/r/storage_service.html.markdown index 6000817de73e..213965f99990 100644 --- a/website/source/docs/providers/azure/r/storage_service.html.markdown +++ b/website/source/docs/providers/azure/r/storage_service.html.markdown @@ -26,7 +26,7 @@ resource "azure_storage_service" "tfstor" { The following arguments are supported: * `name` - (Required) The name of the storage service. Must be between 4 and 24 - lowercase-only characters or digits Must be unique on Azure. + lowercase-only characters or digits. Must be unique on Azure. * `location` - (Required) The location where the storage service should be created. For a list of all Azure locations, please consult [this link](http://azure.microsoft.com/en-us/regions/). From 493b31d1225c6b8e962dee891c89935258ca4dca Mon Sep 17 00:00:00 2001 From: Clint Shryock Date: Mon, 27 Jul 2015 10:23:42 -0500 Subject: [PATCH 2/3] provider/azure: Trap a specific Platform Image error in a new PlatformStorageError --- builtin/providers/azure/errors.go | 5 +++++ builtin/providers/azure/resource_azure_instance.go | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 builtin/providers/azure/errors.go diff --git a/builtin/providers/azure/errors.go b/builtin/providers/azure/errors.go new file mode 100644 index 000000000000..89fa6e4b361c --- /dev/null +++ b/builtin/providers/azure/errors.go @@ -0,0 +1,5 @@ +package azure + +import "errors" + +var PlatformStorageError = errors.New("When using a platform image, the 'storage' parameter is required") diff --git a/builtin/providers/azure/resource_azure_instance.go b/builtin/providers/azure/resource_azure_instance.go index b273675f5946..5ade3b55d5b5 100644 --- a/builtin/providers/azure/resource_azure_instance.go +++ b/builtin/providers/azure/resource_azure_instance.go @@ -591,6 +591,10 @@ func retrieveImageDetails( return configureForImage, osType, nil } + if err == PlatformStorageError { + return nil, "", err + } + return nil, "", fmt.Errorf("Could not find image with label '%s'. Available images are: %s", label, strings.Join(append(VMLabels, OSLabels...), ", ")) } @@ -647,7 +651,7 @@ func retrieveOSImageDetails( if img.MediaLink == "" { if storage == "" { return nil, "", nil, - fmt.Errorf("When using a platform image, the 'storage' parameter is required") + PlatformStorageError } img.MediaLink = fmt.Sprintf(osDiskBlobStorageURL, storage, name) } From 488587467cdfb38a139f6266496f7090e00ac90a Mon Sep 17 00:00:00 2001 From: Clint Shryock Date: Thu, 30 Jul 2015 09:27:13 -0500 Subject: [PATCH 3/3] code formatting --- builtin/providers/azure/resource_azure_instance.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/builtin/providers/azure/resource_azure_instance.go b/builtin/providers/azure/resource_azure_instance.go index 5ade3b55d5b5..cf20e82184dd 100644 --- a/builtin/providers/azure/resource_azure_instance.go +++ b/builtin/providers/azure/resource_azure_instance.go @@ -650,8 +650,7 @@ func retrieveOSImageDetails( } if img.MediaLink == "" { if storage == "" { - return nil, "", nil, - PlatformStorageError + return nil, "", nil, PlatformStorageError } img.MediaLink = fmt.Sprintf(osDiskBlobStorageURL, storage, name) }