stacks

package
v0.0.0-...-fd14076 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 16, 2024 License: Apache-2.0, Apache-2.0 Imports: 11 Imported by: 2

Documentation

Overview

Package stacks provides operation for working with Heat stacks. A stack is a group of resources (servers, load balancers, databases, and so forth) combined to fulfill a useful purpose. Based on a template, Heat orchestration engine creates an instantiated set of resources (a stack) to run the application framework or component specified (in the template). A stack is a running instance of a template. The result of creating a stack is a deployment of the application framework or component.

Prepare required import packages

import (

"fmt"
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/magnum/gophercloud"
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/magnum/gophercloud/openstack"
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/magnum/gophercloud/openstack/orchestration/v1/stacks"

)

Example of Preparing Orchestration client:

client, err := openstack.NewOrchestrationV1(provider,  gophercloud.EndpointOpts{Region: "RegionOne"})

Example of List Stack:

all_stack_pages, err := stacks.List(client, nil).AllPages()
if err != nil {
    panic(err)
}

all_stacks, err := stacks.ExtractStacks(all_stack_pages)
if err != nil {
    panic(err)
}

for _, stack := range all_stacks {
    fmt.Printf("%+v\n", stack)
}

Example to Create an Stack

// Create Template
t := make(map[string]interface{})
f, err := ioutil.ReadFile("template.yaml")
if err != nil {
    panic(err)
}
err = yaml.Unmarshal(f, t)
if err != nil {
    panic(err)
}

template := &stacks.Template{}
template.TE = stacks.TE{
    Bin: f,
}
// Create Environment if needed
t_env := make(map[string]interface{})
f_env, err := ioutil.ReadFile("env.yaml")
if err != nil {
    panic(err)
}
err = yaml.Unmarshal(f_env, t_env)
if err != nil {
    panic(err)
}

env := &stacks.Environment{}
env.TE = stacks.TE{
    Bin: f_env,
}

// Remember, the priority of parameters you given through
// Parameters is higher than the parameters you provided in EnvironmentOpts.
params := make(map[string]string)
params["number_of_nodes"] = 1
tags := []string{"example-stack"}
createOpts := &stacks.CreateOpts{
    // The name of the stack. It must start with an alphabetic character.
    Name:       "testing_group",
    // A structure that contains either the template file or url. Call the
    // associated methods to extract the information relevant to send in a create request.
    TemplateOpts: template,
    // A structure that contains details for the environment of the stack.
    EnvironmentOpts: env,
    // User-defined parameters to pass to the template.
    Parameters: params,
    // A list of tags to assosciate with the Stack
    Tags: tags,
}

r := stacks.Create(client, createOpts)
//dcreated_stack := stacks.CreatedStack()
if r.Err != nil {
    panic(r.Err)
}
created_stack, err := r.Extract()
if err != nil {
    panic(err)
}
fmt.Printf("Created Stack: %v", created_stack.ID)

Example for Get Stack

get_result := stacks.Get(client, stackName, created_stack.ID)
if get_result.Err != nil {
    panic(get_result.Err)
}
stack, err := get_result.Extract()
if err != nil {
    panic(err)
}
fmt.Println("Get Stack: Name: ", stack.Name, ", ID: ", stack.ID, ", Status: ", stack.Status)

Example for Find Stack

find_result  := stacks.Find(client, stackIdentity)
if find_result.Err != nil {
	panic(find_result.Err)
}
stack, err := find_result.Extract()
if err != nil {
	panic(err)
}
fmt.Println("Find Stack: Name: ", stack.Name, ", ID: ", stack.ID, ", Status: ", stack.Status)

Example for Delete Stack

del_r := stacks.Delete(client, stackName, created_stack.ID)
if del_r.Err != nil {
    panic(del_r.Err)
}
fmt.Println("Deleted Stack: ", stackName)

Summary of Behavior Between Stack Update and UpdatePatch Methods :

Function | Test Case | Result

Update() | Template AND Parameters WITH Conflict | Parameter takes priority, parameters are set in raw_template.environment overlay Update() | Template ONLY | Template updates, raw_template.environment overlay is removed Update() | Parameters ONLY | No update, template is required

UpdatePatch() | Template AND Parameters WITH Conflict | Parameter takes priority, parameters are set in raw_template.environment overlay UpdatePatch() | Template ONLY | Template updates, but raw_template.environment overlay is not removed, existing parameter values will remain UpdatePatch() | Parameters ONLY | Parameters (raw_template.environment) is updated, excluded values are unchanged

The PUT Update() function will remove parameters from the raw_template.environment overlay if they are excluded from the operation, whereas PATCH Update() will never be destructive to the raw_template.environment overlay. It is not possible to expose the raw_template values with a patch update once they have been added to the environment overlay with the PATCH verb, but newly added values that do not have a corresponding key in the overlay will display the raw_template value.

Example to Update a Stack Using the Update (PUT) Method

t := make(map[string]interface{})
f, err := ioutil.ReadFile("template.yaml")
if err != nil {
	panic(err)
}
err = yaml.Unmarshal(f, t)
if err != nil {
	panic(err)
}

template := stacks.Template{}
template.TE = stacks.TE{
	Bin: f,
}

var params = make(map[string]interface{})
params["number_of_nodes"] = 2

stackName := "my_stack"
stackId := "d68cc349-ccc5-4b44-a17d-07f068c01e5a"

stackOpts := &stacks.UpdateOpts{
	Parameters: params,
	TemplateOpts: &template,
}

res := stacks.Update(orchestrationClient, stackName, stackId, stackOpts)
if res.Err != nil {
	panic(res.Err)
}

Example to Update a Stack Using the UpdatePatch (PATCH) Method

var params = make(map[string]interface{})
params["number_of_nodes"] = 2

stackName := "my_stack"
stackId := "d68cc349-ccc5-4b44-a17d-07f068c01e5a"

stackOpts := &stacks.UpdateOpts{
	Parameters: params,
}

res := stacks.UpdatePatch(orchestrationClient, stackName, stackId, stackOpts)
if res.Err != nil {
	panic(res.Err)
}

Example YAML Template Containing a Heat::ResourceGroup With Three Nodes

heat_template_version: 2016-04-08

parameters:
	number_of_nodes:
		type: number
		default: 3
		description: the number of nodes
	node_flavor:
		type: string
		default: m1.small
		description: node flavor
	node_image:
		type: string
		default: centos7.5-latest
		description: node os image
	node_network:
		type: string
		default: my-node-network
		description: node network name

resources:
	resource_group:
		type: OS::Heat::ResourceGroup
		properties:
		count: { get_param: number_of_nodes }
		resource_def:
			type: OS::Nova::Server
			properties:
				name: my_nova_server_%index%
				image: { get_param: node_image }
				flavor: { get_param: node_flavor }
				networks:
					- network: {get_param: node_network}

Index

Constants

View Source
const InvalidEnvironment = `` /* 320-byte string literal not displayed */

InvalidEnvironment is an invalid environment as it has an extra section called `resources`

View Source
const InvalidTemplateNoVersion = `` /* 304-byte string literal not displayed */

InvalidTemplateNoVersion is an invalid template as it has no `version` section

View Source
const ValidJSONEnvironment = `` /* 839-byte string literal not displayed */

ValidJSONEnvironment is a valid environment for a stack in JSON format

View Source
const ValidJSONTemplate = `` /* 458-byte string literal not displayed */

ValidJSONTemplate is a valid OpenStack Heat template in JSON format

View Source
const ValidYAMLEnvironment = `` /* 886-byte string literal not displayed */

ValidYAMLEnvironment is a valid environment for a stack in YAML format

View Source
const ValidYAMLTemplate = `` /* 338-byte string literal not displayed */

ValidYAMLTemplate is a valid OpenStack Heat template in YAML format

Variables

View Source
var (
	// SortAsc is used to sort a list of stacks in ascending order.
	SortAsc SortDir = "asc"
	// SortDesc is used to sort a list of stacks in descending order.
	SortDesc SortDir = "desc"
	// SortName is used to sort a list of stacks by name.
	SortName SortKey = "name"
	// SortStatus is used to sort a list of stacks by status.
	SortStatus SortKey = "status"
	// SortCreatedAt is used to sort a list of stacks by date created.
	SortCreatedAt SortKey = "created_at"
	// SortUpdatedAt is used to sort a list of stacks by date updated.
	SortUpdatedAt SortKey = "updated_at"
)
View Source
var EnvironmentSections = map[string]bool{
	"parameters":         true,
	"parameter_defaults": true,
	"resource_registry":  true,
}

EnvironmentSections is a map containing allowed sections in a stack environment file

View Source
var TemplateFormatVersions = map[string]bool{
	"HeatTemplateFormatVersion": true,
	"heat_template_version":     true,
	"AWSTemplateFormatVersion":  true,
}

TemplateFormatVersions is a map containing allowed variations of the template format version Note that this contains the permitted variations of the _keys_ not the values.

View Source
var ValidJSONEnvironmentParsed = map[string]interface{}{
	"parameters": map[string]interface{}{
		"user_key": "userkey",
	},
	"resource_registry": map[string]interface{}{
		"My::WP::Server":         "file:///home/shardy/git/heat-templates/hot/F18/WordPress_Native.yaml",
		"OS::Quantum*":           "OS::Neutron*",
		"AWS::CloudWatch::Alarm": "file:///etc/heat/templates/AWS_CloudWatch_Alarm.yaml",
		"OS::Metering::Alarm":    "OS::Ceilometer::Alarm",
		"AWS::RDS::DBInstance":   "file:///etc/heat/templates/AWS_RDS_DBInstance.yaml",
		"resources": map[string]interface{}{
			"my_db_server": map[string]interface{}{
				"OS::DBInstance": "file:///home/mine/all_my_cool_templates/db.yaml",
			},
			"my_server": map[string]interface{}{
				"OS::DBInstance": "file:///home/mine/all_my_cool_templates/db.yaml",
				"hooks":          "pre-create",
			},
			"nested_stack": map[string]interface{}{
				"nested_resource": map[string]interface{}{
					"hooks": "pre-update",
				},
				"another_resource": map[string]interface{}{
					"hooks": []interface{}{
						"pre-create",
						"pre-update",
					},
				},
			},
		},
	},
}

ValidJSONEnvironmentParsed is the expected parsed version of ValidJSONEnvironment

View Source
var ValidJSONTemplateParsed = map[string]interface{}{
	"heat_template_version": "2014-10-16",
	"parameters": map[string]interface{}{
		"flavor": map[string]interface{}{
			"default":     "debian2G",
			"description": "Flavor for the server to be created",
			"hidden":      true,
			"type":        "string",
		},
	},
	"resources": map[string]interface{}{
		"test_server": map[string]interface{}{
			"properties": map[string]interface{}{
				"flavor": "2 GB General Purpose v1",
				"image":  "Debian 7 (Wheezy) (PVHVM)",
				"name":   "test-server",
			},
			"type": "OS::Nova::Server",
		},
	},
}

ValidJSONTemplateParsed is the expected parsed version of ValidJSONTemplate

Functions

func List

List returns a Pager which allows you to iterate over a collection of stacks. It accepts a ListOpts struct, which allows you to filter and sort the returned collection for greater efficiency.

Types

type AbandonResult

type AbandonResult struct {
	gophercloud.Result
}

AbandonResult represents the result of an Abandon operation.

func Abandon

func Abandon(c *gophercloud.ServiceClient, stackName, stackID string) (r AbandonResult)

Abandon deletes the stack with the provided stackName and stackID, but leaves its resources intact, and returns data describing the stack and its resources.

func (AbandonResult) Extract

func (r AbandonResult) Extract() (*AbandonedStack, error)

Extract returns a pointer to an AbandonedStack object and is called after an Abandon operation.

func (AbandonResult) String

func (r AbandonResult) String() (string, error)

String converts an AbandonResult to a string. This is useful to when passing the result of an Abandon operation to an AdoptOpts AdoptStackData field.

type AbandonedStack

type AbandonedStack struct {
	Status             string                 `json:"status"`
	Name               string                 `json:"name"`
	Template           map[string]interface{} `json:"template"`
	Action             string                 `json:"action"`
	ID                 string                 `json:"id"`
	Resources          map[string]interface{} `json:"resources"`
	Files              map[string]string      `json:"files"`
	StackUserProjectID string                 `json:"stack_user_project_id"`
	ProjectID          string                 `json:"project_id"`
	Environment        map[string]interface{} `json:"environment"`
}

AbandonedStack represents the result of an Abandon operation.

type AdoptOpts

type AdoptOpts struct {
	// Existing resources data represented as a string to add to the
	// new stack. Data returned by Abandon could be provided as AdoptsStackData.
	AdoptStackData string `json:"adopt_stack_data" required:"true"`
	// The name of the stack. It must start with an alphabetic character.
	Name string `json:"stack_name" required:"true"`
	// A structure that contains either the template file or url. Call the
	// associated methods to extract the information relevant to send in a create request.
	TemplateOpts *Template `json:"-" required:"true"`
	// The timeout for stack creation in minutes.
	Timeout int `json:"timeout_mins,omitempty"`
	// A structure that contains either the template file or url. Call the
	// associated methods to extract the information relevant to send in a create request.
	//TemplateOpts *Template `json:"-" required:"true"`
	// Enables or disables deletion of all stack resources when a stack
	// creation fails. Default is true, meaning all resources are not deleted when
	// stack creation fails.
	DisableRollback *bool `json:"disable_rollback,omitempty"`
	// A structure that contains details for the environment of the stack.
	EnvironmentOpts *Environment `json:"-"`
	// User-defined parameters to pass to the template.
	Parameters map[string]interface{} `json:"parameters,omitempty"`
}

AdoptOpts is the common options struct used in this package's Adopt operation.

func (AdoptOpts) ToStackAdoptMap

func (opts AdoptOpts) ToStackAdoptMap() (map[string]interface{}, error)

ToStackAdoptMap casts a CreateOpts struct to a map.

type AdoptOptsBuilder

type AdoptOptsBuilder interface {
	ToStackAdoptMap() (map[string]interface{}, error)
}

AdoptOptsBuilder is the interface options structs have to satisfy in order to be used in the Adopt function in this package. Since many extensions decorate or modify the common logic, it is useful for them to satisfy a basic interface in order for them to be used.

type AdoptResult

type AdoptResult struct {
	CreateResult
}

AdoptResult represents the result of an Adopt operation. AdoptResult has the same form as CreateResult.

func Adopt

Adopt accepts an AdoptOpts struct and creates a new stack using the resources from another stack.

type Client

type Client interface {
	Get(string) (*http.Response, error)
}

Client is an interface that expects a Get method similar to http.Get. This is needed for unit testing, since we can mock an http client. Thus, the client will usually be an http.Client EXCEPT in unit tests.

type CreateOpts

type CreateOpts struct {
	// The name of the stack. It must start with an alphabetic character.
	Name string `json:"stack_name" required:"true"`
	// A structure that contains either the template file or url. Call the
	// associated methods to extract the information relevant to send in a create request.
	TemplateOpts *Template `json:"-" required:"true"`
	// Enables or disables deletion of all stack resources when a stack
	// creation fails. Default is true, meaning all resources are not deleted when
	// stack creation fails.
	DisableRollback *bool `json:"disable_rollback,omitempty"`
	// A structure that contains details for the environment of the stack.
	EnvironmentOpts *Environment `json:"-"`
	// User-defined parameters to pass to the template.
	Parameters map[string]interface{} `json:"parameters,omitempty"`
	// The timeout for stack creation in minutes.
	Timeout int `json:"timeout_mins,omitempty"`
	// A list of tags to assosciate with the Stack
	Tags []string `json:"-"`
}

CreateOpts is the common options struct used in this package's Create operation.

func (CreateOpts) ToStackCreateMap

func (opts CreateOpts) ToStackCreateMap() (map[string]interface{}, error)

ToStackCreateMap casts a CreateOpts struct to a map.

type CreateOptsBuilder

type CreateOptsBuilder interface {
	ToStackCreateMap() (map[string]interface{}, error)
}

CreateOptsBuilder is the interface options structs have to satisfy in order to be used in the main Create operation in this package. Since many extensions decorate or modify the common logic, it is useful for them to satisfy a basic interface in order for them to be used.

type CreateResult

type CreateResult struct {
	gophercloud.Result
}

CreateResult represents the result of a Create operation.

func Create

Create accepts a CreateOpts struct and creates a new stack using the values provided.

func (CreateResult) Extract

func (r CreateResult) Extract() (*CreatedStack, error)

Extract returns a pointer to a CreatedStack object and is called after a Create operation.

type CreatedStack

type CreatedStack struct {
	ID    string             `json:"id"`
	Links []gophercloud.Link `json:"links"`
}

CreatedStack represents the object extracted from a Create operation.

type DeleteResult

type DeleteResult struct {
	gophercloud.ErrResult
}

DeleteResult represents the result of a Delete operation.

func Delete

func Delete(c *gophercloud.ServiceClient, stackName, stackID string) (r DeleteResult)

Delete deletes a stack based on the stack name and stack ID.

type Environment

type Environment struct {
	TE
}

Environment is a structure that represents stack environments

func (*Environment) Validate

func (e *Environment) Validate() error

Validate validates the contents of the Environment

type ErrInvalidDataFormat

type ErrInvalidDataFormat struct {
	gophercloud.BaseError
}

func (ErrInvalidDataFormat) Error

func (e ErrInvalidDataFormat) Error() string

type ErrInvalidEnvironment

type ErrInvalidEnvironment struct {
	gophercloud.BaseError
	Section string
}

func (ErrInvalidEnvironment) Error

func (e ErrInvalidEnvironment) Error() string

type ErrInvalidTemplateFormatVersion

type ErrInvalidTemplateFormatVersion struct {
	gophercloud.BaseError
	Version string
}

func (ErrInvalidTemplateFormatVersion) Error

type ErrTemplateRequired

type ErrTemplateRequired struct {
	gophercloud.BaseError
}

func (ErrTemplateRequired) Error

func (e ErrTemplateRequired) Error() string

type GetResult

type GetResult struct {
	gophercloud.Result
}

GetResult represents the result of a Get operation.

func Find

func Find(c *gophercloud.ServiceClient, stackIdentity string) (r GetResult)

Find retrieves a stack based on the stack name or stack ID.

func Get

func Get(c *gophercloud.ServiceClient, stackName, stackID string) (r GetResult)

Get retreives a stack based on the stack name and stack ID.

func (GetResult) Extract

func (r GetResult) Extract() (*RetrievedStack, error)

Extract returns a pointer to a RetrievedStack object and is called after a Get operation.

type ListOpts

type ListOpts struct {
	// TenantID is the UUID of the tenant. A tenant is also known as
	// a project.
	TenantID string `q:"tenant_id"`

	// ID filters the stack list by a stack ID
	ID string `q:"id"`

	// Status filters the stack list by a status.
	Status string `q:"status"`

	// Name filters the stack list by a name.
	Name string `q:"name"`

	// Marker is the ID of last-seen item.
	Marker string `q:"marker"`

	// Limit is an integer value for the limit of values to return.
	Limit int `q:"limit"`

	// SortKey allows you to sort by stack_name, stack_status, creation_time, or
	// update_time key.
	SortKey SortKey `q:"sort_keys"`

	// SortDir sets the direction, and is either `asc` or `desc`.
	SortDir SortDir `q:"sort_dir"`

	// AllTenants is a bool to show all tenants.
	AllTenants bool `q:"global_tenant"`

	// ShowDeleted set to `true` to include deleted stacks in the list.
	ShowDeleted bool `q:"show_deleted"`

	// ShowNested set to `true` to include nested stacks in the list.
	ShowNested bool `q:"show_nested"`

	// Tags lists stacks that contain one or more simple string tags.
	Tags string `q:"tags"`

	// TagsAny lists stacks that contain one or more simple string tags.
	TagsAny string `q:"tags_any"`

	// NotTags lists stacks that do not contain one or more simple string tags.
	NotTags string `q:"not_tags"`

	// NotTagsAny lists stacks that do not contain one or more simple string tags.
	NotTagsAny string `q:"not_tags_any"`
}

ListOpts allows the filtering and sorting of paginated collections through the API. Filtering is achieved by passing in struct field values that map to the network attributes you want to see returned.

func (ListOpts) ToStackListQuery

func (opts ListOpts) ToStackListQuery() (string, error)

ToStackListQuery formats a ListOpts into a query string.

type ListOptsBuilder

type ListOptsBuilder interface {
	ToStackListQuery() (string, error)
}

ListOptsBuilder allows extensions to add additional parameters to the List request.

type ListedStack

type ListedStack struct {
	CreationTime time.Time          `json:"-"`
	Description  string             `json:"description"`
	ID           string             `json:"id"`
	Links        []gophercloud.Link `json:"links"`
	Name         string             `json:"stack_name"`
	Status       string             `json:"stack_status"`
	StatusReason string             `json:"stack_status_reason"`
	Tags         []string           `json:"tags"`
	UpdatedTime  time.Time          `json:"-"`
}

ListedStack represents an element in the slice extracted from a List operation.

func ExtractStacks

func ExtractStacks(r pagination.Page) ([]ListedStack, error)

ExtractStacks extracts and returns a slice of ListedStack. It is used while iterating over a stacks.List call.

func (*ListedStack) UnmarshalJSON

func (r *ListedStack) UnmarshalJSON(b []byte) error

type PreviewOpts

type PreviewOpts struct {
	// The name of the stack. It must start with an alphabetic character.
	Name string `json:"stack_name" required:"true"`
	// The timeout for stack creation in minutes.
	Timeout int `json:"timeout_mins" required:"true"`
	// A structure that contains either the template file or url. Call the
	// associated methods to extract the information relevant to send in a create request.
	TemplateOpts *Template `json:"-" required:"true"`
	// Enables or disables deletion of all stack resources when a stack
	// creation fails. Default is true, meaning all resources are not deleted when
	// stack creation fails.
	DisableRollback *bool `json:"disable_rollback,omitempty"`
	// A structure that contains details for the environment of the stack.
	EnvironmentOpts *Environment `json:"-"`
	// User-defined parameters to pass to the template.
	Parameters map[string]interface{} `json:"parameters,omitempty"`
}

PreviewOpts contains the common options struct used in this package's Preview operation.

func (PreviewOpts) ToStackPreviewMap

func (opts PreviewOpts) ToStackPreviewMap() (map[string]interface{}, error)

ToStackPreviewMap casts a PreviewOpts struct to a map.

type PreviewOptsBuilder

type PreviewOptsBuilder interface {
	ToStackPreviewMap() (map[string]interface{}, error)
}

PreviewOptsBuilder is the interface options structs have to satisfy in order to be used in the Preview operation in this package.

type PreviewResult

type PreviewResult struct {
	gophercloud.Result
}

PreviewResult represents the result of a Preview operation.

func Preview

Preview accepts a PreviewOptsBuilder interface and creates a preview of a stack using the values provided.

func (PreviewResult) Extract

func (r PreviewResult) Extract() (*PreviewedStack, error)

Extract returns a pointer to a PreviewedStack object and is called after a Preview operation.

type PreviewedStack

type PreviewedStack struct {
	Capabilities        []interface{}      `json:"capabilities"`
	CreationTime        time.Time          `json:"-"`
	Description         string             `json:"description"`
	DisableRollback     bool               `json:"disable_rollback"`
	ID                  string             `json:"id"`
	Links               []gophercloud.Link `json:"links"`
	Name                string             `json:"stack_name"`
	NotificationTopics  []interface{}      `json:"notification_topics"`
	Parameters          map[string]string  `json:"parameters"`
	Resources           []interface{}      `json:"resources"`
	TemplateDescription string             `json:"template_description"`
	Timeout             int                `json:"timeout_mins"`
	UpdatedTime         time.Time          `json:"-"`
}

PreviewedStack represents the result of a Preview operation.

func (*PreviewedStack) UnmarshalJSON

func (r *PreviewedStack) UnmarshalJSON(b []byte) error

type RetrievedStack

type RetrievedStack struct {
	Capabilities        []interface{}            `json:"capabilities"`
	CreationTime        time.Time                `json:"-"`
	Description         string                   `json:"description"`
	DisableRollback     bool                     `json:"disable_rollback"`
	ID                  string                   `json:"id"`
	Links               []gophercloud.Link       `json:"links"`
	NotificationTopics  []interface{}            `json:"notification_topics"`
	Outputs             []map[string]interface{} `json:"outputs"`
	Parameters          map[string]string        `json:"parameters"`
	Name                string                   `json:"stack_name"`
	Status              string                   `json:"stack_status"`
	StatusReason        string                   `json:"stack_status_reason"`
	Tags                []string                 `json:"tags"`
	TemplateDescription string                   `json:"template_description"`
	Timeout             int                      `json:"timeout_mins"`
	UpdatedTime         time.Time                `json:"-"`
}

RetrievedStack represents the object extracted from a Get operation.

func (*RetrievedStack) UnmarshalJSON

func (r *RetrievedStack) UnmarshalJSON(b []byte) error

type SortDir

type SortDir string

SortDir is a type for specifying in which direction to sort a list of stacks.

type SortKey

type SortKey string

SortKey is a type for specifying by which key to sort a list of stacks.

type StackPage

type StackPage struct {
	pagination.SinglePageBase
}

StackPage is a pagination.Pager that is returned from a call to the List function.

func (StackPage) IsEmpty

func (r StackPage) IsEmpty() (bool, error)

IsEmpty returns true if a ListResult contains no Stacks.

type TE

type TE struct {
	// Bin stores the contents of the template or environment.
	Bin []byte
	// URL stores the URL of the template. This is allowed to be a 'file://'
	// for local files.
	URL string
	// Parsed contains a parsed version of Bin. Since there are 2 different
	// fields referring to the same value, you must be careful when accessing
	// this filed.
	Parsed map[string]interface{}
	// Files contains a mapping between the urls in templates to their contents.
	Files map[string]string
	// contains filtered or unexported fields
}

TE is a base structure for both Template and Environment

func (*TE) Fetch

func (t *TE) Fetch() error

Fetch fetches the contents of a TE from its URL. Once a TE structure has a URL, call the fetch method to fetch the contents.

func (*TE) Parse

func (t *TE) Parse() error

Parse will parse the contents and then validate. The contents MUST be either JSON or YAML.

func (*TE) Validate

func (t *TE) Validate() error

Validate validates the contents of TE

type Template

type Template struct {
	TE
}

Template is a structure that represents OpenStack Heat templates

func (*Template) Validate

func (t *Template) Validate() error

Validate validates the contents of the Template

type UpdateOpts

type UpdateOpts struct {
	// A structure that contains either the template file or url. Call the
	// associated methods to extract the information relevant to send in a create request.
	TemplateOpts *Template `json:"-"`
	// A structure that contains details for the environment of the stack.
	EnvironmentOpts *Environment `json:"-"`
	// User-defined parameters to pass to the template.
	Parameters map[string]interface{} `json:"parameters,omitempty"`
	// The timeout for stack creation in minutes.
	Timeout int `json:"timeout_mins,omitempty"`
	// A list of tags to associate with the Stack
	Tags []string `json:"-"`
}

UpdateOpts contains the common options struct used in this package's Update and UpdatePatch operations.

func (UpdateOpts) ToStackUpdateMap

func (opts UpdateOpts) ToStackUpdateMap() (map[string]interface{}, error)

ToStackUpdateMap validates that a template was supplied and calls the toStackUpdateMap private function.

func (UpdateOpts) ToStackUpdatePatchMap

func (opts UpdateOpts) ToStackUpdatePatchMap() (map[string]interface{}, error)

ToStackUpdatePatchMap calls the private function toStackUpdateMap directly.

type UpdateOptsBuilder

type UpdateOptsBuilder interface {
	ToStackUpdateMap() (map[string]interface{}, error)
}

UpdateOptsBuilder is the interface options structs have to satisfy in order to be used in the Update operation in this package.

type UpdatePatchOptsBuilder

type UpdatePatchOptsBuilder interface {
	ToStackUpdatePatchMap() (map[string]interface{}, error)
}

UpdatePatchOptsBuilder is the interface options structs have to satisfy in order to be used in the UpdatePatch operation in this package

type UpdateResult

type UpdateResult struct {
	gophercloud.ErrResult
}

UpdateResult represents the result of a Update operation.

func Update

func Update(c *gophercloud.ServiceClient, stackName, stackID string, opts UpdateOptsBuilder) (r UpdateResult)

Update accepts an UpdateOpts struct and updates an existing stack using the

http PUT verb with the values provided. opts.TemplateOpts is required.

func UpdatePatch

func UpdatePatch(c *gophercloud.ServiceClient, stackName, stackID string, opts UpdatePatchOptsBuilder) (r UpdateResult)

Update accepts an UpdateOpts struct and updates an existing stack using the

http PATCH verb with the values provided. opts.TemplateOpts is not required.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL