stacks

package
v0.0.0-...-f66f4bb Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2020 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

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 Prettify

func Prettify(i interface{}) string

Prettify returns the string representation of a value.

Types

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]string `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 {
	golangsdk.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 []golangsdk.Link `json:"links"`
}

CreatedStack represents the object extracted from a Create operation.

type DeleteResult

type DeleteResult struct {
	golangsdk.ErrResult
}

DeleteResult represents the result of a Delete operation.

func Delete

func Delete(c *golangsdk.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 {
	golangsdk.BaseError
}

func (ErrInvalidDataFormat) Error

func (e ErrInvalidDataFormat) Error() string

type ErrInvalidEnvironment

type ErrInvalidEnvironment struct {
	golangsdk.BaseError
	Section string
}

func (ErrInvalidEnvironment) Error

func (e ErrInvalidEnvironment) Error() string

type ErrInvalidTemplateFormatVersion

type ErrInvalidTemplateFormatVersion struct {
	golangsdk.BaseError
	Version string
}

func (ErrInvalidTemplateFormatVersion) Error

type GetResult

type GetResult struct {
	golangsdk.Result
}

GetResult represents the result of a Get operation.

func Get

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

func (GetResult) Extract

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

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

type ListOpts

type ListOpts struct {
	ID      string  `q:"id"`
	Status  string  `q:"status"`
	Name    string  `q:"name"`
	Marker  string  `q:"marker"`
	Limit   int     `q:"limit"`
	SortKey SortKey `q:"sort_keys"`
	SortDir SortDir `q:"sort_dir"`
}

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 rts attributes you want to see returned. SortKey allows you to sort by a particular network attribute. SortDir sets the direction, and is either `asc' or `desc'. Marker and Limit are used for pagination.

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        []golangsdk.Link `json:"links"`
	Name         string           `json:"stack_name"`
	Status       string           `json:"stack_status"`
	StatusReason string           `json:"stack_status_reason"`
	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 FilterStacks

func FilterStacks(stacks []ListedStack, opts ListOpts) ([]ListedStack, error)

func List

func List(c *golangsdk.ServiceClient, opts ListOpts) ([]ListedStack, error)

func (*ListedStack) UnmarshalJSON

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

type Output

type Output struct {

	// User defined description associated with the output.
	Description string `json:"description"`

	// The key associated with the output.
	OutputKey *string `json:"output_key"`

	// The value associated with the output.
	OutputValue *string `json:"output_value"`
	// contains filtered or unexported fields
}

The Output data type.

func (Output) GoString

func (s Output) GoString() string

GoString returns the string representation

func (*Output) SetDescription

func (s *Output) SetDescription(v string) *Output

SetDescription sets the Description field's value.

func (*Output) SetOutputKey

func (s *Output) SetOutputKey(v string) *Output

SetOutputKey sets the OutputKey field's value.

func (*Output) SetOutputValue

func (s *Output) SetOutputValue(v string) *Output

SetOutputValue sets the OutputValue field's value.

func (Output) String

func (s Output) String() string

String returns the string representation

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"`
	TenantId            string            `json:"tenant_id"`
	Links               []golangsdk.Link  `json:"links"`
	NotificationTopics  []interface{}     `json:"notification_topics"`
	Outputs             []*Output         `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. RetrievedStack represents the object extracted from a Get operation.

func (*RetrievedStack) UnmarshalJSON

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

RetrievedStack represents the object extracted from a Get operation.

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.LinkedPageBase
}

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:"-" required:"true"`
	// 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]string `json:"parameters,omitempty"`
	// The timeout for stack creation in minutes.
	Timeout int `json:"timeout_mins,omitempty"`
	// 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 list of tags to assosciate with the Stack
	Tags []string `json:"-"`
}

UpdateOpts contains the common options struct used in this package's Update operation.

func (UpdateOpts) ToStackUpdateMap

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

ToStackUpdateMap casts a CreateOpts struct to a map.

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 UpdateResult

type UpdateResult struct {
	golangsdk.ErrResult
}

UpdateResult represents the result of a Update operation.

func Update

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

Update accepts an UpdateOpts struct and updates an existing stack using the values provided.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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