Documentation ¶
Overview ¶
Package modules contain the implementation of our modules. Each module has a name/type such as "git", "file", etc. The modules each accept an arbitrary set of parameters which are module-specific.
Index ¶
- func ArrayParam(vars map[string]interface{}, param string) []string
- func Modules() []string
- func Register(id string, newfunc ModuleConstructor)
- func RegisterAlias(alias string, impl string)
- func StringParam(vars map[string]interface{}, param string) string
- type DirectoryModule
- type DockerModule
- type EditModule
- func (e *EditModule) Append(path string, text string) (bool, error)
- func (e *EditModule) Check(args map[string]interface{}) error
- func (e *EditModule) Execute(args map[string]interface{}) (bool, error)
- func (e *EditModule) RemoveLines(path string, pattern string) (bool, error)
- func (e *EditModule) SearchReplace(path string, search string, replace string) (bool, error)
- type FailModule
- type FileModule
- func (f *FileModule) Check(args map[string]interface{}) error
- func (f *FileModule) CopyFile(src string, dst string) (bool, error)
- func (f *FileModule) CopyTemplateFile(src string, dst string) (bool, error)
- func (f *FileModule) CreateFile(dst string, content string) (bool, error)
- func (f *FileModule) Execute(args map[string]interface{}) (bool, error)
- func (f *FileModule) FetchURL(url string, dst string) (bool, error)
- type GitModule
- type GroupModule
- type HTTPModule
- type LinkModule
- type LogModule
- type ModuleAPI
- type ModuleConstructor
- type ModuleOutput
- type PackageModule
- type SQLModule
- type ShellModule
- type UserModule
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ArrayParam ¶
ArrayParam returns the named parameter, as an array, from the map.
If the parameter was not present an empty array is returned.
func Modules ¶
func Modules() []string
Modules returns the names of all the registered module-names.
func RegisterAlias ¶ added in v0.9.0
RegisterAlias allows a new name to refer to an existing implementation.
func StringParam ¶
StringParam returns the named parameter, as a string, from the map.
If the parameter was not present an empty array is returned.
Types ¶
type DirectoryModule ¶
type DirectoryModule struct {
// contains filtered or unexported fields
}
DirectoryModule stores our state
func (*DirectoryModule) Check ¶
func (f *DirectoryModule) Check(args map[string]interface{}) error
Check is part of the module-api, and checks arguments.
type DockerModule ¶ added in v0.5.0
type DockerModule struct { // Cached list of image-tags we've got available on the local host. Tags []string // contains filtered or unexported fields }
DockerModule stores our state
func (*DockerModule) Check ¶ added in v0.5.0
func (dm *DockerModule) Check(args map[string]interface{}) error
Check is part of the module-api, and checks arguments.
type EditModule ¶
type EditModule struct {
// contains filtered or unexported fields
}
EditModule stores our state.
func (*EditModule) Append ¶
func (e *EditModule) Append(path string, text string) (bool, error)
Append the given line to the file, if it is missing.
func (*EditModule) Check ¶
func (e *EditModule) Check(args map[string]interface{}) error
Check is part of the module-api, and checks arguments.
func (*EditModule) Execute ¶
func (e *EditModule) Execute(args map[string]interface{}) (bool, error)
Execute is part of the module-api, and is invoked to run a rule.
func (*EditModule) RemoveLines ¶
func (e *EditModule) RemoveLines(path string, pattern string) (bool, error)
RemoveLines remove any lines from the file which match the given regular expression.
func (*EditModule) SearchReplace ¶ added in v0.15.0
SearchReplace performs a search and replace operation across all lines of the given file.
Searches are literal, rather than regexp.
type FailModule ¶ added in v0.9.0
type FailModule struct {
// contains filtered or unexported fields
}
FailModule stores our state.
func (*FailModule) Check ¶ added in v0.9.0
func (f *FailModule) Check(args map[string]interface{}) error
Check is part of the module-api, and checks arguments.
type FileModule ¶
type FileModule struct {
// contains filtered or unexported fields
}
FileModule stores our state
func (*FileModule) Check ¶
func (f *FileModule) Check(args map[string]interface{}) error
Check is part of the module-api, and checks arguments.
func (*FileModule) CopyFile ¶
func (f *FileModule) CopyFile(src string, dst string) (bool, error)
CopyFile copies the source file to the destination, returning if we changed the contents.
func (*FileModule) CopyTemplateFile ¶ added in v0.11.0
func (f *FileModule) CopyTemplateFile(src string, dst string) (bool, error)
CopyTemplateFile copies the template file to the destination, rendering the template and returning if we changed the contents.
func (*FileModule) CreateFile ¶
func (f *FileModule) CreateFile(dst string, content string) (bool, error)
CreateFile writes the given content to the named file. If the contents are identical no change is reported.
type GitModule ¶
type GitModule struct {
// contains filtered or unexported fields
}
GitModule stores our state
type GroupModule ¶ added in v0.14.0
type GroupModule struct {
// contains filtered or unexported fields
}
GroupModule stores our state
func (*GroupModule) Check ¶ added in v0.14.0
func (g *GroupModule) Check(args map[string]interface{}) error
Check is part of the module-api, and checks arguments.
type HTTPModule ¶ added in v0.16.0
type HTTPModule struct {
// contains filtered or unexported fields
}
HTTPModule stores our state.
func (*HTTPModule) Check ¶ added in v0.16.0
func (f *HTTPModule) Check(args map[string]interface{}) error
Check is part of the module-api, and checks arguments.
func (*HTTPModule) Execute ¶ added in v0.16.0
func (f *HTTPModule) Execute(args map[string]interface{}) (bool, error)
Execute is part of the module-api, and is invoked to run a rule.
func (*HTTPModule) GetOutputs ¶ added in v0.17.0
func (f *HTTPModule) GetOutputs() map[string]string
GetOutputs is an optional interface method which allows the module to return values to the caller - prefixed by the rule-name.
type LinkModule ¶
type LinkModule struct {
// contains filtered or unexported fields
}
LinkModule stores our state
func (*LinkModule) Check ¶
func (f *LinkModule) Check(args map[string]interface{}) error
Check is part of the module-api, and checks arguments.
type LogModule ¶ added in v0.12.0
type LogModule struct {
// contains filtered or unexported fields
}
LogModule stores our state
type ModuleAPI ¶
type ModuleAPI interface { // Check allows a module to ensures that any mandatory parameters // are present, or perform similar setup-work. // // If no error is returned then the module will be executed later // via a call to Execute. Check(map[string]interface{}) error // Execute runs the module with the given arguments. // // The return value is true if the module made a change // and false otherwise. Execute(map[string]interface{}) (bool, error) }
ModuleAPI is the interface which all of our modules must implement.
There are only two methods, one to check if the supplied parameters make sense, the other to actually execute the rule.
If a module wishes to setup a variable in the environment then they can optionally implement the `ModuleOutput` interface too.
func Lookup ¶
func Lookup(id string, cfg *config.Config, env *environment.Environment) (a ModuleAPI)
Lookup is the factory-method which looks up and returns an object of the given type - if possible.
type ModuleConstructor ¶ added in v0.17.0
type ModuleConstructor func(cfg *config.Config, env *environment.Environment) ModuleAPI
ModuleConstructor is the signature of a constructor-function.
type ModuleOutput ¶ added in v0.17.0
type ModuleOutput interface { // GetOutputs will return a set of key-value pairs. // // These will be set in the environment, scoped by the rule-name, // if the module is successfully executed. GetOutputs() map[string]string }
ModuleOutput is an optional interface that may be implemented by any of our internal modules.
If this interface is implemented it is possible for modules to set values in the environment after they've been executed.
type PackageModule ¶
type PackageModule struct {
// contains filtered or unexported fields
}
PackageModule stores our state
func (*PackageModule) Check ¶
func (pm *PackageModule) Check(args map[string]interface{}) error
Check is part of the module-api, and checks arguments.
type SQLModule ¶ added in v0.15.0
type SQLModule struct {
// contains filtered or unexported fields
}
SQLModule stores our state.
type ShellModule ¶
type ShellModule struct {
// contains filtered or unexported fields
}
ShellModule stores our state
func (*ShellModule) Check ¶
func (f *ShellModule) Check(args map[string]interface{}) error
Check is part of the module-api, and checks arguments.
func (*ShellModule) Execute ¶
func (f *ShellModule) Execute(args map[string]interface{}) (bool, error)
Execute is part of the module-api, and is invoked to run a rule.
func (*ShellModule) GetOutputs ¶ added in v0.17.0
func (f *ShellModule) GetOutputs() map[string]string
GetOutputs is an optional interface method which allows the module to return values to the caller - prefixed by the rule-name.
type UserModule ¶ added in v0.11.0
type UserModule struct {
// contains filtered or unexported fields
}
UserModule stores our state
func (*UserModule) Check ¶ added in v0.11.0
func (g *UserModule) Check(args map[string]interface{}) error
Check is part of the module-api, and checks arguments.