stitch

package
v0.0.0-...-3fa228a Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2016 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const PublicInternetLabel = "public"

PublicInternetLabel is a magic label that allows connections to or from the public network.

Variables

This section is empty.

Functions

func Compile

func Compile(sc scanner.Scanner, path string, download bool) (string, error)

Compile takes a Stitch (possibly with imports), and transforms it into a single string that can be evaluated without other dependencies. It also confirms that the result doesn't have any invariant, syntax, or evaluation errors.

func GetQuiltPath

func GetQuiltPath() string

GetQuiltPath returns the user-defined QUILT_PATH, or the default absolute QUILT_PATH, which is ~/.quilt if the user did not specify a QUILT_PATH.

func GetSpec

func GetSpec(repoName string) error

GetSpec takes in an import path repoName, and attempts to download the repository associated with that repoName.

Types

type AvailabilitySet

type AvailabilitySet map[string]struct{}

AvailabilitySet represents a set of containers which can be placed together on a VM.

func (AvailabilitySet) Check

func (avSet AvailabilitySet) Check(label string) bool

Check checks set membership.

func (AvailabilitySet) CopyAvSet

func (avSet AvailabilitySet) CopyAvSet() AvailabilitySet

CopyAvSet returns a copy of the set.

func (AvailabilitySet) Insert

func (avSet AvailabilitySet) Insert(labels ...string)

Insert inserts labels into the set.

func (AvailabilitySet) Nodes

func (avSet AvailabilitySet) Nodes() []string

Nodes returns the membership of the set.

func (AvailabilitySet) Remove

func (avSet AvailabilitySet) Remove(labels ...string)

Remove removes labels from the set.

func (AvailabilitySet) Str

func (avSet AvailabilitySet) Str() string

Str returns the string representation of the set.

type Connection

type Connection struct {
	From    string
	To      string
	MinPort int
	MaxPort int
}

A Connection allows containers implementing the From label to speak to containers implementing the To label in ports in the range [MinPort, MaxPort]

type ConnectionSlice

type ConnectionSlice []Connection

A ConnectionSlice allows for slices of Collections to be used in joins

func (ConnectionSlice) Get

func (cs ConnectionSlice) Get(ii int) interface{}

Get returns the value contained at the given index

func (ConnectionSlice) Len

func (cs ConnectionSlice) Len() int

Len returns the number of items in the slice

type Container

type Container struct {
	ID      int
	Image   string
	Command []string
	Env     map[string]string
}

A Container may be instantiated in the stitch and queried by users.

type Edge

type Edge struct {
	From string
	To   string
}

An Edge in the communication Graph.

type Graph

type Graph struct {
	Nodes map[string]Node
	// A set of containers which can be placed together on a VM.
	Availability []AvailabilitySet
	// Constraints on which containers can be placed together.
	Placement map[string][]string
	Machines  []Machine
}

A Graph represents permission to communicate across a series of Nodes. Each Node is a container and each edge is permissions to initiate a connection.

func InitializeGraph

func InitializeGraph(spec Stitch) (Graph, error)

InitializeGraph queries the Stitch to fill in the Graph structure.

func (Graph) GetConnections

func (g Graph) GetConnections() []Edge

GetConnections returns a list of the edges in the Graph.

type Machine

type Machine struct {
	Provider string
	Role     string
	Size     string
	CPU      Range
	RAM      Range
	DiskSize int
	Region   string
	SSHKeys  []string
}

A Machine specifies the type of VM that should be booted.

type Node

type Node struct {
	Name        string
	Label       string
	Connections map[string]Node
}

A Node in the communiction Graph.

type Placement

type Placement struct {
	TargetLabel string

	Exclusive bool

	// Label Constraint
	OtherLabel string

	// Machine Constraints
	Provider string
	Size     string
	Region   string
}

A Placement constraint guides where containers may be scheduled, either relative to the labels of other containers, or the machine the container will run on.

type Range

type Range struct {
	Min float64
	Max float64
}

A Range defines a range of acceptable values for a Machine attribute

func (Range) Accepts

func (stitchr Range) Accepts(x float64) bool

Accepts returns true if `x` is within the range specified by `stitchr` (include), or if no max is specified and `x` is larger than `stitchr.min`.

type Stitch

type Stitch struct {
	// contains filtered or unexported fields
}

A Stitch is an abstract representation of the policy language.

func New

func New(specStr string) (Stitch, error)

New parses and executes a stitch (in text form), and returns an abstract Dsl handle.

func (Stitch) QueryConnections

func (stitch Stitch) QueryConnections() []Connection

QueryConnections returns the connections declared in the stitch.

func (Stitch) QueryContainers

func (stitch Stitch) QueryContainers() []*Container

QueryContainers retrieves all containers declared in stitch.

func (Stitch) QueryFloat

func (stitch Stitch) QueryFloat(key string) (float64, error)

QueryFloat returns a float value defined in the stitch.

func (Stitch) QueryLabels

func (stitch Stitch) QueryLabels() map[string][]int

QueryLabels returns a map where the keys are labels defined in the stitch, and the values are a slice of container IDs.

func (Stitch) QueryMachines

func (stitch Stitch) QueryMachines() []Machine

QueryMachines returns all machines declared in the stitch.

func (Stitch) QueryPlacements

func (stitch Stitch) QueryPlacements() []Placement

QueryPlacements returns the placements declared in the stitch.

func (Stitch) QueryStrSlice

func (stitch Stitch) QueryStrSlice(key string) []string

QueryStrSlice returns a string slice value defined in the stitch.

func (Stitch) QueryString

func (stitch Stitch) QueryString(key string) string

QueryString returns a string value defined in the stitch.

func (Stitch) String

func (stitch Stitch) String() string

String returns the stitch in its code form.

Jump to

Keyboard shortcuts

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