github.com/dahs81/otto@v0.2.1-0.20160126165905-6400716cf085/foundation/foundation.go (about) 1 package foundation 2 3 import ( 4 "github.com/hashicorp/otto/context" 5 ) 6 7 // Foundation is the interface that must be implemented by each 8 // foundation. A foundation is a fundamental building block of a 9 // real infrastructure, and can be categorized such as service discovery, 10 // security, etc. 11 // 12 // Foundations are bound to a (name, infra type, infra flavor) 3-tuple. 13 type Foundation interface { 14 // Compile is called to compile the files that are used to manage 15 // this foundation. 16 Compile(*Context) (*CompileResult, error) 17 18 // Infra is called to build or destroy the infrastructure for this 19 // foundation. The "Action" field in the Context can be used to 20 // determine the desired action. This will be either "" (build) 21 // or "destroy". Foundations currently don't support any other 22 // actions. 23 Infra(*Context) error 24 } 25 26 // Context is the context for operations on a Foundation. 27 type Context struct { 28 context.Shared 29 30 // Action is the sub-action to take when being executed. 31 // 32 // ActionArgs is the list of arguments for this action. 33 // 34 // Both of these fields will only be set for the Infra call currently. 35 Action string 36 ActionArgs []string 37 38 // Config is the raw configuration from the Appfile itself for 39 // this foundation. 40 Config map[string]interface{} 41 42 // AppConfig is the foundation configuration that was returned by the 43 // application that we're working with. This is only available during 44 // the Compile function if we're compiling for an application. 45 // 46 // It should be expected during compilation that this might be nil. 47 // The cases where it is nil are not currently well defined, but the 48 // behavior in the nil case should be to do nothing except Deploy. 49 AppConfig *Config 50 51 // Dir is the directory that the compilation is allowed to write to 52 // for persistant storage of data that is available during task 53 // execution. For tasks, this will be the directory that compilation 54 // wrote to. Whenever a compilation is done, this directory is 55 // cleared. Data that should be persistant across compilations should 56 // be stored in the directory service. 57 Dir string 58 59 // Tuple is the tuple used for this foundation. 60 Tuple Tuple 61 } 62 63 // CompileResult is the structure containing compilation result values. 64 // 65 // This is empty now but may be used in the future. 66 type CompileResult struct{}