Skip to content

Commit

Permalink
added template validation
Browse files Browse the repository at this point in the history
Signed-off-by: Octavian Ionescu <itavyg@gmail.com>
  • Loading branch information
itavy committed Oct 28, 2019
1 parent 0ebf584 commit 7020c0c
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions azurerm/resource_arm_template_deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,27 @@ func resourceArmTemplateDeploymentCreateUpdate(d *schema.ResourceData, meta inte
Properties: &properties,
}

deploymentValidateResponse, err := client.Validate(ctx, resourceGroup, name, deployment)

if !d.IsNewResource() {
d.Partial(true)
}

if err != nil {
return fmt.Errorf("Error requesting Validation for Template Deployment %q (Resource Group %q): %+v", name, resourceGroup, err)
}

if deploymentValidateResponse.Error != nil {
if deploymentValidateResponse.Error.Message != nil {
return fmt.Errorf("Error validating Template for Deployment %q (Resource Group %q): %+v", name, resourceGroup, *deploymentValidateResponse.Error.Message)
}
return fmt.Errorf("Error validating Template for Deployment %q (Resource Group %q): %+v", name, resourceGroup, *deploymentValidateResponse.Error)
}

if !d.IsNewResource() {
d.Partial(false)
}

future, err := client.CreateOrUpdate(ctx, resourceGroup, name, deployment)
if err != nil {
return fmt.Errorf("Error creating deployment: %+v", err)
Expand Down

0 comments on commit 7020c0c

Please sign in to comment.