github.com/niedbalski/juju@v0.0.0-20190215020005-8ff100488e47/provider/azure/internal/armtemplates/template.go (about)

     1  // Copyright 2018 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package armtemplates
     5  
     6  import "github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2018-07-01/storage"
     7  
     8  const (
     9  	schema         = "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#"
    10  	contentVersion = "1.0.0.0"
    11  )
    12  
    13  // Template represents an Azure Resource Manager (ARM) Template.
    14  // See: https://azure.microsoft.com/en-us/documentation/articles/resource-group-authoring-templates/
    15  type Template struct {
    16  	// Resources contains the definitions of resources that will
    17  	// be created by the template.
    18  	Resources []Resource `json:"resources"`
    19  }
    20  
    21  // Map returns the template as a map, suitable for use in
    22  // azure-sdk-for-go/arm/resources/resources/DeploymentProperties.Template.
    23  func (t *Template) Map() (map[string]interface{}, error) {
    24  	m := map[string]interface{}{
    25  		"$schema":        schema,
    26  		"contentVersion": contentVersion,
    27  		"resources":      t.Resources,
    28  	}
    29  	return m, nil
    30  }
    31  
    32  // Resource describes a template resource. For information on the
    33  // individual fields, see https://azure.microsoft.com/en-us/documentation/articles/resource-group-authoring-templates/.
    34  type Resource struct {
    35  	APIVersion string            `json:"apiVersion"`
    36  	Type       string            `json:"type"`
    37  	Name       string            `json:"name"`
    38  	Location   string            `json:"location,omitempty"`
    39  	Tags       map[string]string `json:"tags,omitempty"`
    40  	Comments   string            `json:"comments,omitempty"`
    41  	DependsOn  []string          `json:"dependsOn,omitempty"`
    42  	Properties interface{}       `json:"properties,omitempty"`
    43  	Resources  []Resource        `json:"resources,omitempty"`
    44  
    45  	// Non-uniform attributes.
    46  	StorageSku *storage.Sku `json:"sku,omitempty"`
    47  }