forked from Azure/acs-engine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
deployments.go
69 lines (58 loc) · 2.24 KB
/
deployments.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package armhelpers
import (
"fmt"
"github.com/Azure/azure-sdk-for-go/arm/resources/resources"
"github.com/Azure/go-autorest/autorest"
log "github.com/sirupsen/logrus"
)
// DeployTemplate implements the TemplateDeployer interface for the AzureClient client
func (az *AzureClient) DeployTemplate(resourceGroupName, deploymentName string, template map[string]interface{}, parameters map[string]interface{}, cancel <-chan struct{}) (*resources.DeploymentExtended, error) {
deployment := resources.Deployment{
Properties: &resources.DeploymentProperties{
Template: &template,
Parameters: ¶meters,
Mode: resources.Incremental,
},
}
log.Infof("Starting ARM Deployment (%s). This will take some time...", deploymentName)
resChan, errChan := az.deploymentsClient.CreateOrUpdate(
resourceGroupName,
deploymentName,
deployment,
cancel)
err := <-errChan
res, ok := <-resChan
if !ok {
// This path is taken when validation is failed before calling ARM
return nil, err
}
outcomeText := "Succeeded"
if err != nil {
outcomeText = fmt.Sprintf("Error: %v", err)
}
log.Infof("Finished ARM Deployment (%s). %s", deploymentName, outcomeText)
return &res, err
}
// ValidateTemplate validate the template and parameters
func (az *AzureClient) ValidateTemplate(
resourceGroupName string,
deploymentName string,
template map[string]interface{},
parameters map[string]interface{}) (result resources.DeploymentValidateResult, err error) {
deployment := resources.Deployment{
Properties: &resources.DeploymentProperties{
Template: &template,
Parameters: ¶meters,
Mode: resources.Incremental,
},
}
return az.deploymentsClient.Validate(resourceGroupName, deploymentName, deployment)
}
// GetDeployment returns the template deployment
func (az *AzureClient) GetDeployment(resourceGroupName, deploymentName string) (result resources.DeploymentExtended, err error) {
return az.deploymentsClient.Get(resourceGroupName, deploymentName)
}
// CheckDeploymentExistence returns if the deployment already exists
func (az *AzureClient) CheckDeploymentExistence(resourceGroupName string, deploymentName string) (result autorest.Response, err error) {
return az.deploymentsClient.CheckExistence(resourceGroupName, deploymentName)
}