Fixed void Azure network config bug.
This commit is contained in:
parent
bc06deace2
commit
5ff6598e65
|
@ -4,6 +4,7 @@ import (
|
|||
"fmt"
|
||||
"log"
|
||||
|
||||
"github.com/Azure/azure-sdk-for-go/management"
|
||||
"github.com/Azure/azure-sdk-for-go/management/virtualnetwork"
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
)
|
||||
|
@ -46,8 +47,13 @@ func resourceAzureDnsServerCreate(d *schema.ResourceData, meta interface{}) erro
|
|||
defer azureClient.mutex.Unlock()
|
||||
netConf, err := vnetClient.GetVirtualNetworkConfiguration()
|
||||
if err != nil {
|
||||
if management.IsResourceNotFoundError(err) {
|
||||
// if no network configuration exists yet; create one now:
|
||||
netConf = virtualnetwork.NetworkConfiguration{}
|
||||
} else {
|
||||
return fmt.Errorf("Failed to get the current network configuration from Azure: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
log.Println("[DEBUG] Adding new DNS server definition to Azure.")
|
||||
name := d.Get("name").(string)
|
||||
|
|
|
@ -4,6 +4,7 @@ import (
|
|||
"fmt"
|
||||
"log"
|
||||
|
||||
"github.com/Azure/azure-sdk-for-go/management"
|
||||
"github.com/Azure/azure-sdk-for-go/management/virtualnetwork"
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
)
|
||||
|
@ -54,8 +55,13 @@ func resourceAzureLocalNetworkConnectionCreate(d *schema.ResourceData, meta inte
|
|||
defer azureClient.mutex.Unlock()
|
||||
netConf, err := vnetClient.GetVirtualNetworkConfiguration()
|
||||
if err != nil {
|
||||
if management.IsResourceNotFoundError(err) {
|
||||
// if no network config exists yet; create a new one now:
|
||||
netConf = virtualnetwork.NetworkConfiguration{}
|
||||
} else {
|
||||
return fmt.Errorf("Failed to get the current network configuration from Azure: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
// get provided configuration:
|
||||
name := d.Get("name").(string)
|
||||
|
|
|
@ -3,7 +3,6 @@ package azure
|
|||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"strings"
|
||||
|
||||
"github.com/Azure/azure-sdk-for-go/management"
|
||||
"github.com/Azure/azure-sdk-for-go/management/virtualnetwork"
|
||||
|
@ -88,7 +87,8 @@ func resourceAzureVirtualNetworkCreate(d *schema.ResourceData, meta interface{})
|
|||
|
||||
nc, err := vnetClient.GetVirtualNetworkConfiguration()
|
||||
if err != nil {
|
||||
if strings.Contains(err.Error(), "ResourceNotFound") {
|
||||
if management.IsResourceNotFoundError(err) {
|
||||
// if no network config exists yet; create a new one now:
|
||||
nc = virtualnetwork.NetworkConfiguration{}
|
||||
} else {
|
||||
return fmt.Errorf(virtualNetworkRetrievalError, err)
|
||||
|
|
Loading…
Reference in New Issue