foundation

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2016 License: MPL-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WriteVars

func WriteVars(ctx *context.Shared) error

WriteVars will write the outputs from a foundation and put them into a key/value file within the foundation directories that is available when uploaded. This allows the build scripts to access the outputs at runtime.

Ideally this sort of thing would be possible at compile-time but the values of these variables come at runtime so we need to populate this at runtime.

By having a var file, it removes the burden of knowing what variables to send in to the foundation from the App implementation. They just need to call this function, upload the folder, and call main.sh.

Types

type CompileResult

type CompileResult struct{}

CompileResult is the structure containing compilation result values.

This is empty now but may be used in the future.

type Config

type Config struct {
	// Service settings are used to configure the service discovery
	// (if there is any).
	//
	// ServiceName is the name of the service. If this is blank,
	// service discovery won't be configured for this application.
	//
	// ServicePort is the port this service is running on.
	//
	// ServiceTags is a list of tags associated with the service.
	ServiceName string
	ServicePort int
	ServiceTags []string
}

Config is the configuration of the various foundational domains that Otto supports.

type Context

type Context struct {
	context.Shared

	// Action is the sub-action to take when being executed.
	//
	// ActionArgs is the list of arguments for this action.
	//
	// Both of these fields will only be set for the Infra call currently.
	Action     string
	ActionArgs []string

	// Config is the raw configuration from the Appfile itself for
	// this foundation.
	Config map[string]interface{}

	// AppConfig is the foundation configuration that was returned by the
	// application that we're working with. This is only available during
	// the Compile function if we're compiling for an application.
	//
	// It should be expected during compilation that this might be nil.
	// The cases where it is nil are not currently well defined, but the
	// behavior in the nil case should be to do nothing except Deploy.
	AppConfig *Config

	// Dir is the directory that the compilation is allowed to write to
	// for persistant storage of data that is available during task
	// execution. For tasks, this will be the directory that compilation
	// wrote to. Whenever a compilation is done, this directory is
	// cleared. Data that should be persistant across compilations should
	// be stored in the directory service.
	Dir string

	// Tuple is the tuple used for this foundation.
	Tuple Tuple
}

Context is the context for operations on a Foundation.

type Factory

type Factory func() (Foundation, error)

Factory is a factory function for creating foundations.

func StructFactory

func StructFactory(v Foundation) Factory

StructFactory returns a factory function for creating a newly instantiated copy of the type of v.

type Foundation

type Foundation interface {
	// Compile is called to compile the files that are used to manage
	// this foundation.
	Compile(*Context) (*CompileResult, error)

	// Infra is called to build or destroy the infrastructure for this
	// foundation. The "Action" field in the Context can be used to
	// determine the desired action. This will be either "" (build)
	// or "destroy". Foundations currently don't support any other
	// actions.
	Infra(*Context) error
}

Foundation is the interface that must be implemented by each foundation. A foundation is a fundamental building block of a real infrastructure, and can be categorized such as service discovery, security, etc.

Foundations are bound to a (name, infra type, infra flavor) 3-tuple.

type Mock added in v0.1.2

type Mock struct {
	CompileCalled  bool
	CompileContext *Context
	CompileResult  *CompileResult
	CompileErr     error

	InfraCalled  bool
	InfraContext *Context
	InfraErr     error
}

Mock is a mock implementation of the Foundation interface.

func (*Mock) Compile added in v0.1.2

func (m *Mock) Compile(ctx *Context) (*CompileResult, error)

func (*Mock) Infra added in v0.1.2

func (m *Mock) Infra(ctx *Context) error

type Tuple

type Tuple struct {
	Type        string // Type is the foundation type, i.e. "consul"
	Infra       string // Infra is the infra type, i.e. "aws"
	InfraFlavor string // InfraFlavor is the flavor, i.e. "vpc-public-private"
}

Tuple is the tupled used for looking up the Foundation implementation for an Appfile. This struct is usually used in its non-pointer form, to be a key for maps.

func (Tuple) String

func (t Tuple) String() string

type TupleMap

type TupleMap map[Tuple]Factory

TupleMap is an alias of map[Tuple]Factory that adds additional helper methods on top to help work with app tuples.

func (TupleMap) Add

func (m TupleMap) Add(m2 TupleMap)

Add is a helper to add another map to this one.

func (TupleMap) Lookup

func (m TupleMap) Lookup(t Tuple) Factory

Lookup looks up a Tuple. This should be used instead of direct [] access since it respects wildcards ('*') within the Tuple.

type TupleSlice

type TupleSlice []Tuple

TupleSlice is an alias of []Tuple that implements sort.Interface for sorting tuples. See the tests in tuple_test.go to see the sorting order.

func (TupleSlice) Len

func (s TupleSlice) Len() int

sort.Interface impl.

func (TupleSlice) Less

func (s TupleSlice) Less(i, j int) bool

func (TupleSlice) Map

func (s TupleSlice) Map(f Factory) TupleMap

Map turns a TupleSlice into a map where all the tuples in the slice are mapped to a single factory function.

func (TupleSlice) Swap

func (s TupleSlice) Swap(i, j int)

Jump to

Keyboard shortcuts

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