stack

package
v0.0.0-...-b1baf6d Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2016 License: Apache-2.0 Imports: 13 Imported by: 0

README

A stack is an instance of a YAML d2k8 template

Stack

Manage stacks from the d2k8 cli.

Create a stack

Create a stack to be managed from d2k8.

d2k8 stack create name path

Argument Meaning
name name of the stack to be identified in d2k8 cli commands
path path to the YAML d2k8 template

Inspect a stack

Retrive stack dynamic information.

d2k8 stack inspect name

Argument Meaning
name name of the stack to be retrieved

Export a stack

Retrieve the stack YAML d2k8 template.

d2k8 stack export name

Argument Meaning
name name of the stack to be retrieved

List Stacks

Retrive all stacks information.

d2k8 stack list

Update a stack

Update a stack managed by d2k8.

d2k8 stack update name path

Argument Meaning
name name of the host to be updated
path path to the new YAML d2k8 template

Delete a stack

Remove a stack from d2k8. Containers created for this stack are also deleted.

d2k8 stack remove name

Argument Meaning
name name of the stack to be deleted

Documentation

Index

Constants

View Source
const (
	SERVICE_SCHEMA = `` /* 1753-byte string literal not displayed */

	NAME_SCHEMA = `` /* 144-byte string literal not displayed */

)
View Source
const (
	FILL_SIZE = 30
)

Variables

View Source
var Commands = cli.Command{
	Name:  "stack",
	Usage: "manage stacks",
	Subcommands: []cli.Command{
		{
			Name:  "create",
			Usage: "create a stack",
			Action: func(c *cli.Context) {
				if len(c.Args()) != 2 {
					log.Fatal("'create' command accepts 2 arguments, the name of the stack and the path to the YAML elora template")
				}
				err := CreateCmd(c.Args()[0], c.Args()[1])
				if err != nil {
					log.Fatal(err)
				}
			},
		},
		{
			Name:      "inspect",
			ShortName: "get",
			Usage:     "get the information of a stack",
			Action: func(c *cli.Context) {
				if len(c.Args()) != 1 {
					log.Fatal("'get' command only accepts one argument, the name of the stack")
				}
				err := InspectCmd(c.Args().First())
				if err != nil {
					log.Fatal(err)
				}
			},
		},
		{
			Name:  "export",
			Usage: "get the elora YAML template of a stack",
			Action: func(c *cli.Context) {
				if len(c.Args()) != 1 {
					log.Fatal("'export' command only accepts one argument, the name of the stack")
				}
				err := ExportCmd(c.Args().First())
				if err != nil {
					log.Fatal(err)
				}
			},
		},
		{
			Name:      "list",
			ShortName: "ls",
			Usage:     "list the elora current stacks",
			Action: func(c *cli.Context) {
				if len(c.Args()) != 0 {
					log.Fatal("'list' command does not have arguments")
				}
				err := ListCmd()
				if err != nil {
					log.Fatal(err)
				}
			},
		},
		{
			Name:      "update",
			ShortName: "up",
			Usage:     "update a stack",
			Action: func(c *cli.Context) {
				if len(c.Args()) != 2 {
					log.Fatal("'update' command accepts 2 arguments, the name of the stack and the path to its new YAML elora template")
				}
				err := UpdateCmd(c.Args()[0], c.Args()[1])
				if err != nil {
					log.Fatal(err)
				}
			},
		},
		{
			Name:      "remove",
			ShortName: "rm",
			Usage:     "remove a stack",
			Action: func(c *cli.Context) {
				if len(c.Args()) != 1 {
					log.Fatal("'remove' command only accepts one argument, the name of stack to remove")
				}
				err := RemoveCmd(c.Args().First())
				if err != nil {
					log.Fatal(err)
				}
			},
		},
	},
}

Functions

func CreateCmd

func CreateCmd(name string, filePath string) error

func DefinitionFilePath

func DefinitionFilePath(name string) (path string)

func Delete

func Delete(name string) error

func Exists

func Exists(name string) bool

func ExportCmd

func ExportCmd(name string) error

func FileFolder

func FileFolder() (path string)

func InspectCmd

func InspectCmd(name string) error

func ListCmd

func ListCmd() error

func RemoveCmd

func RemoveCmd(name string) error

func StateFilePath

func StateFilePath(name string) (path string)

func UpdateCmd

func UpdateCmd(name string, filePath string) error

func Validate

func Validate(stackName string, filePath string) error

func Write

func Write(name string, sourceFilePath string) error

Types

type Container

type Container struct {
	Ip        string
	Node      string
	Status    string
	Operation string
	DockerId  string
	Ports     []string
}

type NodeLoad

type NodeLoad struct {
	Containers int
	Ports      []string
}

type ServiceDefinition

type ServiceDefinition struct {
	Image        string   `json:"image"`
	Command      string   `json:"command"`
	Links        []string `json:"links"`
	Ports        []string `json:"ports"`
	Volumes      []string `json:"volumes"`
	Volumes_from []string `json:"volumes_from"`
	Environment  []string `json:"environment"`
	Entrypoint   string   `json:"entrypoint"`
	Mem_limit    string   `json:"mem_limit"`
	Privileged   bool     `json:"privileged"`
	Restart      string   `json:"restart"`
	Strategy     string   `json:"strategy"`
	Scale        int      `json:"scale"`
	Tags         []string `json:"tags"`
}

type ServiceState

type ServiceState struct {
	Operation  string
	Containers map[string]Container
}

type Stack

type Stack struct {
	Name       string
	Operation  string
	Definition map[string]ServiceDefinition
	Services   map[string]ServiceState
}

func List

func List() ([]Stack, error)

func Read

func Read(name string) (Stack, error)

func (*Stack) Export

func (s *Stack) Export() (string, error)

func (*Stack) SetBestNodes

func (s *Stack) SetBestNodes() error

func (*Stack) SetDefaults

func (s *Stack) SetDefaults()

type StackInterface

type StackInterface interface{}

Jump to

Keyboard shortcuts

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