modules

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: May 13, 2023 License: GPL-2.0 Imports: 31 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func ArrayParam

func ArrayParam(vars map[string]interface{}, param string) []string

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 Register

func Register(id string, newfunc ModuleConstructor)

Register records a new module.

func RegisterAlias added in v0.9.0

func RegisterAlias(alias string, impl string)

RegisterAlias allows a new name to refer to an existing implementation.

func StringParam

func StringParam(vars map[string]interface{}, param string) string

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.

func (*DirectoryModule) Execute

func (f *DirectoryModule) Execute(args map[string]interface{}) (bool, error)

Execute is part of the module-api, and is invoked to run a rule.

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.

func (*DockerModule) Execute added in v0.5.0

func (dm *DockerModule) Execute(args map[string]interface{}) (bool, error)

Execute is part of the module-api, and is invoked to run a rule.

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

func (e *EditModule) SearchReplace(path string, search string, replace string) (bool, error)

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.

func (*FailModule) Execute added in v0.9.0

func (f *FailModule) Execute(args map[string]interface{}) (bool, error)

Execute is part of the module-api, and is invoked to run a rule.

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.

func (*FileModule) Execute

func (f *FileModule) Execute(args map[string]interface{}) (bool, error)

Execute is part of the module-api, and is invoked to run a rule.

func (*FileModule) FetchURL

func (f *FileModule) FetchURL(url string, dst string) (bool, error)

FetchURL retrieves the contents of the remote URL and saves them to the given file. If the contents are identical no change is reported.

type GitModule

type GitModule struct {
	// contains filtered or unexported fields
}

GitModule stores our state

func (*GitModule) Check

func (g *GitModule) Check(args map[string]interface{}) error

Check is part of the module-api, and checks arguments.

func (*GitModule) Execute

func (g *GitModule) Execute(args map[string]interface{}) (bool, error)

Execute is part of the module-api, and is invoked to run a rule.

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.

func (*GroupModule) Execute added in v0.14.0

func (g *GroupModule) Execute(args map[string]interface{}) (bool, error)

Execute is part of the module-api, and is invoked to run a rule.

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.

func (*LinkModule) Execute

func (f *LinkModule) Execute(args map[string]interface{}) (bool, error)

Execute is part of the module-api, and is invoked to run a rule.

type LogModule added in v0.12.0

type LogModule struct {
	// contains filtered or unexported fields
}

LogModule stores our state

func (*LogModule) Check added in v0.12.0

func (f *LogModule) Check(args map[string]interface{}) error

Check is part of the module-api, and checks arguments.

func (*LogModule) Execute added in v0.12.0

func (f *LogModule) Execute(args map[string]interface{}) (bool, error)

Execute is part of the module-api, and is invoked to run a rule.

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.

func (*PackageModule) Execute

func (pm *PackageModule) Execute(args map[string]interface{}) (bool, error)

Execute is part of the module-api, and is invoked to run a rule.

type SQLModule added in v0.15.0

type SQLModule struct {
	// contains filtered or unexported fields
}

SQLModule stores our state.

func (*SQLModule) Check added in v0.15.0

func (f *SQLModule) Check(args map[string]interface{}) error

Check is part of the module-api, and checks arguments.

func (*SQLModule) Execute added in v0.15.0

func (f *SQLModule) Execute(args map[string]interface{}) (bool, error)

Execute is part of the module-api, and is invoked to run a rule.

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.

func (*UserModule) Execute added in v0.11.0

func (g *UserModule) Execute(args map[string]interface{}) (bool, error)

Execute is part of the module-api, and is invoked to run a rule.

Directories

Path Synopsis
Package system contains some helpers for working with operating-system package management.
Package system contains some helpers for working with operating-system package management.

Jump to

Keyboard shortcuts

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