Documentation
¶
Overview ¶
app contains the interfaces and structures for application type implementations for Otto. Applications are the components that know how to dev, build, and deploy a certain kind of application such as Rails, PHP, etc.
All app implementations are built specific to a certain 3-tuple: (app type, infra type, infra flavor). For example: (rails, aws, vpc-public-private). The app implementation then only needs to know how to satisfy that specific 3-tuple.
When building app plugins, it is possible for that plugin to support multiple matrix elements, but each implementation of the interface is expeced to only implement one.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WriteDevDep ¶
WriteDevDep writes a DevDep out to disk.
Types ¶
type App ¶
type App interface {
// Compile is called to compile the files that are used to manage
// this application.
Compile(*Context) (*CompileResult, error)
// Build is called to build the deployable artifact for this
// application.
Build(*Context) error
// Deploy is called to deploy this application. The existence of
// a prior build artifact is confirmed before this is called.
Deploy(*Context) error
// Dev should manage a development environment for this app
// type. This is called for the local, mutable dev environment
// where this application is the main thing under development.
Dev(*Context) error
// DevDep is called when this app is an upstream dependency
// of another application that is being developed. This app should
// build itself for development, and configure the Vagrantfile so
// that this dependency starts properly on boot.
//
// DevDep is given two contexts. The first is the destination
// app (the one being developed), and the second is the source
// app (this one that is an upstream dep).
//
// The results of this call are cached to speed up development
// of the destination app until there is a change, which is detected
// based on VCS.
//
// The resulting DevDep can be nil if nothing needs to be done that
// is part of the DevDep structure. Any DevDepFragments from the
// compilation will still be used, of course.
DevDep(dst *Context, src *Context) (*DevDep, error)
}
App is the interface that must be implemented by each (app type, infra type, infra flavor) 3-tuple.
type CompileResult ¶
type CompileResult struct {
// FoundationConfig is the configuration for the various foundational
// elements of Otto.
FoundationConfig foundation.Config
// DevDepFragmentPath is the path to the Vagrantfile fragment that
// should be added to other Vagrantfiles when this application is
// used as a dependency.
DevDepFragmentPath string
}
CompileResult is the structure containing compilation result values.
type Context ¶
type Context struct {
// 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 Execute call.
Action string
ActionArgs []string
// 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
// CacheDir is the directory where data can be cached. This data
// will persist across compiles of the same version of an Appfile.
//
// The App implementation should function under the assumption that
// this cache directory can be cleared at any time between runs.
CacheDir string
// LocalDir is the directory where data local to this single Appfile
// will be stored; it isn't cleared for compilation.
LocalDir string
// Tuple is the Tuple that identifies this application. This can be
// used so that an implementatin of App can work with multiple tuple
// types.
Tuple Tuple
// Application is the application configuration itself from the appfile.
Application *appfile.Application
// DevDepFragments will be populated with the list of dev dep
// Vagrantfile fragment paths. This will only be available in the Compile
// call.
DevDepFragments []string
// DevIPAddress is a local IP address in the private address space
// that can be used for a development environment. Otto core
// does its best to ensure this is unused.
//
// This is only available if this app is the root application being
// developed (dependencies don't get an IP).
DevIPAddress string
}
Context is the context for operations on applications. Some of the fields in this struct are only available for certain operations.
type DevDep ¶
type DevDep struct {
// Files is a list of files that this dependency created or uses.
// If these files already exist, then future DevDep calls won't be
// called and the cached data will be used.
//
// All files in this must be in the Context.CacheDir. Relative paths
// will be expanded relative to the CacheDir. If the file is not
// in the CacheDir, no caching will occur. The log will note if this
// is happening.
Files []string `json:"files"`
}
DevDep has information about an upstream dependency that should be used by the Dev function in order to build a complete development environment.
func ReadDevDep ¶
ReadDevDep reads a marshalled DevDep from disk.
type Factory ¶
Factory is a factory function for creating infrastructures.
func StructFactory ¶
StructFactory returns a factory function for creating a newly instantiated copy of the type of v.
type Mock ¶
type Mock struct {
CompileCalled bool
CompileContext *Context
CompileResult *CompileResult
CompileErr error
BuildCalled bool
BuildContext *Context
BuildErr error
DeployCalled bool
DeployContext *Context
DeployErr error
DevCalled bool
DevContext *Context
DevErr error
DevDepCalled bool
DevDepContextDst *Context
DevDepContextSrc *Context
DevDepResult *DevDep
DevDepErr error
}
Mock is a mock implementation of the App interface.
type Tuple ¶
type Tuple struct {
App string // App is the app type, i.e. "go"
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 App implementation for an Appfile. This struct is usually used in its non-pointer form, to be a key for maps.
type TupleMap ¶
TupleMap is an alias of map[Tuple]Factory that adds additional helper methods on top to help work with app tuples.
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) 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)