Documentation
¶
Index ¶
- Constants
- Variables
- func CacheDirectory() string
- func CopyFile(src, dst string) error
- func Exists(paths ...string) (bool, error)
- func GetCache(key string) string
- func GetHTTPServerURL() string
- func RegexpNamedGroupsMatch(pattern *regexp.Regexp, search string) (namedGroupMatch map[string]string, err error)
- func RegisterIntegration(integration Integration)
- func SetIntegrations(integrations []Integration)
- func StartHTTPServer() chan struct{}
- func StoreCache(key, data string)
- type App
- type Build
- type BuildConfig
- type EventHandler
- type Integration
Constants ¶
const ( SignalBuildProvisioning = `\/build\/` + appnameRE + `\/provisioning\/` + tokenRE + `$` SignalBuildComplete = `\/build\/` + appnameRE + `\/complete\/` + tokenRE + `$` SignalBuildStarted = `\/build\/` + appnameRE + `\/started\/` + tokenRE + `$` EventCoreLog = `\/log\/` + appnameRE + `\/logtype:(?P<logtype>\w+)\/(?P<logmessage>.*)` )
AppBus signal
Variables ¶
var ( ErrProcessNotFinished = errors.New("Error: Process not finished") ErrProcessNotStarted = errors.New("Error: process not started yet") ErrProcessAlreadyFinished = errors.New("Error: process already finished") ErrProcessAlreadyStarted = errors.New("Error: process already started") )
Errors
Functions ¶
func CacheDirectory ¶
func CacheDirectory() string
CacheDirectory will return the location of the current cache directory
func CopyFile ¶
CopyFile doesn't care if the file already exists, it just overwrites it. It does however, try to be at least a little bit atomic
func GetCache ¶
GetCache will retrieve data from the global cache, this may block longer than you expect
func GetHTTPServerURL ¶
func GetHTTPServerURL() string
GetHTTPServerURL will return the base url that the http server is listening on
func RegexpNamedGroupsMatch ¶
func RegexpNamedGroupsMatch(pattern *regexp.Regexp, search string) (namedGroupMatch map[string]string, err error)
RegexpNamedGroupsMatch - will for a given regexp and search give you a a map of named groups to found values
func RegisterIntegration ¶
func RegisterIntegration(integration Integration)
RegisterIntegration will register your integration with core
func SetIntegrations ¶
func SetIntegrations(integrations []Integration)
SetIntegrations will set the integrations
func StartHTTPServer ¶
func StartHTTPServer() chan struct{}
StartHTTPServer will start the core http server that can be used by integrations
func StoreCache ¶
func StoreCache(key, data string)
StoreCache will store the given data perminately on disk, it can be retrieved with GetCache()
Types ¶
type App ¶
type App interface {
Name() string
Config(namespace string, conf interface{}) error
GlobalConfig(conf interface{}) error
Shutdown()
// AppLocation will return the physical filesystem location of this app
AppLocation() string
// SendEvent is a dispatcher, it will send this string across all the apps integrations and also Core
SendEvent(event string)
// Listen will provide a channel to select on for a given regular expression
// returned map is the captured groups and values
// the returned EventHandler can be used to cancel a listener
Listen(event string, listener func(map[string]string)) EventHandler
RemoveEventHandler(EventHandler)
// NewBuild will be used by github and the like to create new builds for this app whenever they deem so
NewBuild(group string, config *BuildConfig) (token string, err error)
GetBuild(token string) (Build, error)
GetBuildHistory(group string) []Build
// logging functions, logs sent here will go to stdout and on the app bus as log messages
Loginfof(string, ...interface{})
Logwarnf(string, ...interface{})
Logcritf(string, ...interface{})
}
App is defined by $NGBUILD_WORKSPACE/apps/$appname/config.yaml Apps will define different builds, for different projects or different kinds of builds or whatever Config has $NGBUILD_WORKSPACE/config.yaml as a parent and then applies $NGBUILD_WORKSPACE/apps/$appname/config.json onto it Everything App should be thread safe as it will be called from many goroutines
type Build ¶
type Build interface {
Start() error
Stop() error
Ref()
Unref()
Token() string
Group() string
HasStarted() bool
HasStopped() bool
// NewBuild() Will be used by slack and the like, /rebuild <token> or buttons or whatever will just lookup the build
// and call NewBuild() to run the exact same build again
NewBuild() (token string, err error)
// Stdout/Stderr give you what you would expect, io.Reader's that will let you access the entire stdout/err output
Stdout() (io.Reader, error)
Stderr() (io.Reader, error)
// ExitCode returns 0, ErrProcessNotFinished
ExitCode() (int, error)
// Artifact will return a series of filepaths, artifacts are part of the app config in a map[string][]string format
// that is, a given named artifact can have many paths associated with it
// this should be used by say, code coverage tools to generate coverage reports by grabbing artifacts listed here
Artifact(name string) []string
BuildTime() time.Duration
History() []Build
Config() *BuildConfig
WebStatusURL() string
}
Build interface when a build finishes it will announce on the app event bus as /build/complete/$token
type BuildConfig ¶
type BuildConfig struct {
// Required block
Title string
URL string
HeadRepo string
HeadBranch string
HeadHash string
BaseRepo string
BaseBranch string
BaseHash string
Group string
Integrations []Integration `json:"-"`
// Should be an executable of some sort, if not set, set by app.NewBuild
BuildRunner string
Deadline time.Duration
// contains filtered or unexported fields
}
BuildConfig describes a build, heavily in favour of github/git at the moment
func UnmarshalBuildConfig ¶
func UnmarshalBuildConfig(filename string) (*BuildConfig, error)
UnmarshalBuildConfig will unmarshall the given filename into a BuildConfig
func (*BuildConfig) GetMetadata ¶
func (conf *BuildConfig) GetMetadata(key string) string
GetMetadata will get metadata
func (*BuildConfig) Marshal ¶
func (conf *BuildConfig) Marshal() ([]byte, error)
Marshal will marshall this structure into a string
func (*BuildConfig) SetMetadata ¶
func (conf *BuildConfig) SetMetadata(key, value string)
SetMetadata will set metadata
type EventHandler ¶
type EventHandler uint32
EventHandler can be used to cancel an event added with Listen
type Integration ¶
type Integration interface {
// Identifier should return what integration this is, "github", "slack", that kind of thing
Identifier() string
// IsProvider will when given a string, indicate whether this integration can provide for it
// strings would be something like
// http://github.com/foo/bar, or gitlab or git@github.com:foo/bar.git
IsProvider(string) bool
// ProvideFor will be called on the integration when it is expected to provide for a build
// generally this means checkout git repositories into the given directory
ProvideFor(c *BuildConfig, directory string) error
// AttachToApp will order the ingeration to do whatever it does, with the given app.
AttachToApp(App) error
// Shutdown will be called whenever we are closing, anything the integration needs to do, it has to do syncronously
Shutdown()
}
Integration is an interface that integrations should provide
func GetIntegrations ¶
func GetIntegrations(disabledIntegrations ...string) []Integration
GetIntegrations will return a list of cached Integration variables anything passed in to disabledIntegrations will be removed from the cache