~juju-qa/ubuntu/xenial/juju/2.0-rc2

« back to all changes in this revision

Viewing changes to src/github.com/juju/juju/provider/azure/deployments.go

  • Committer: Nicholas Skaggs
  • Date: 2016-09-30 14:39:30 UTC
  • mfrom: (1.8.1)
  • Revision ID: nicholas.skaggs@canonical.com-20160930143930-vwwhrefh6ftckccy
import upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright 2016 Canonical Ltd.
 
2
// Licensed under the AGPLv3, see LICENCE file for details.
 
3
 
 
4
package azure
 
5
 
 
6
import (
 
7
        "github.com/Azure/azure-sdk-for-go/arm/resources/resources"
 
8
        "github.com/Azure/go-autorest/autorest"
 
9
        "github.com/juju/errors"
 
10
 
 
11
        "github.com/juju/juju/provider/azure/internal/armtemplates"
 
12
)
 
13
 
 
14
func createDeployment(
 
15
        callAPI callAPIFunc,
 
16
        client resources.DeploymentsClient,
 
17
        resourceGroup string,
 
18
        deploymentName string,
 
19
        t armtemplates.Template,
 
20
) error {
 
21
        templateMap, err := t.Map()
 
22
        if err != nil {
 
23
                return errors.Trace(err)
 
24
        }
 
25
        deployment := resources.Deployment{
 
26
                &resources.DeploymentProperties{
 
27
                        Template: &templateMap,
 
28
                        Mode:     resources.Incremental,
 
29
                },
 
30
        }
 
31
        if err := callAPI(func() (autorest.Response, error) {
 
32
                return client.CreateOrUpdate(
 
33
                        resourceGroup,
 
34
                        deploymentName,
 
35
                        deployment,
 
36
                        nil, // abort channel
 
37
                )
 
38
        }); err != nil {
 
39
                return errors.Annotatef(err, "creating deployment %q", deploymentName)
 
40
        }
 
41
        return nil
 
42
}