Documentation
¶
Index ¶
- Variables
- func ConvertContentsToString(f FileMap) map[string]string
- func GetTarget(config *config.Config, key string) configurator.Target
- func LoadPlugins(dirpath string, opts ...Option) (map[string]Generator, error)
- type Conman
- type CoreDhcp
- type DHCPd
- type DNSMasq
- type Example
- type FileList
- type FileMap
- func ApplyTemplateFromFiles(mappings Mappings, paths ...string) (FileMap, error)
- func ApplyTemplates(mappings Mappings, templates map[string]Template) (FileMap, error)
- func Generate(config *config.Config, plugin string, params Params) (FileMap, error)
- func GenerateWithTarget(config *config.Config, target string) (FileMap, error)
- func LoadFiles(paths ...string) (FileMap, error)
- type Generator
- type Hostfile
- type Mappings
- type Option
- type Params
- type Powerman
- type Syslog
- type Template
- type Warewulf
Constants ¶
This section is empty.
Variables ¶
var DefaultGenerators = createDefaultGenerators()
Functions ¶
func ConvertContentsToString ¶
Converts the file outputs from map[string][]byte to map[string]string.
Types ¶
type Conman ¶ added in v0.1.1
type Conman struct{}
func (*Conman) GetDescription ¶ added in v0.1.1
func (*Conman) GetVersion ¶ added in v0.1.1
type CoreDhcp ¶ added in v0.2.0
type CoreDhcp struct{}
func (*CoreDhcp) GetDescription ¶ added in v0.2.0
func (*CoreDhcp) GetVersion ¶ added in v0.2.0
type DHCPd ¶ added in v0.1.1
type DHCPd struct{}
func (*DHCPd) GetDescription ¶ added in v0.1.1
func (*DHCPd) GetVersion ¶ added in v0.1.1
type DNSMasq ¶ added in v0.1.1
type DNSMasq struct{}
func (*DNSMasq) GetDescription ¶ added in v0.1.1
func (*DNSMasq) GetVersion ¶ added in v0.1.1
type Example ¶ added in v0.2.0
type Example struct {
Message string
}
func (*Example) GetDescription ¶ added in v0.2.0
func (*Example) GetVersion ¶ added in v0.2.0
type FileMap ¶
func ApplyTemplateFromFiles ¶
Wrapper function similiar to "ApplyTemplates" but takes file paths as arguments. This function will load templates from a file instead of using file contents.
func ApplyTemplates ¶
Wrapper function to slightly abstract away some of the nuances with using gonja into a single function call. This function is *mostly* for convenience and simplication. If no paths are supplied, then no templates will be applied and there will be no output.
The "FileList" returns a slice of byte arrays in the same order as the argument list supplied, but with the Jinja templating applied.
func Generate ¶
Generate() is the main function to generate a collection of files and returns them as a map. This function only expects a path to a plugin and paths to a collection of templates to be used. This function will only load the plugin on-demand and fetch resources as needed.
This function requires that a target and plugin path be set at minimum.
func GenerateWithTarget ¶
Main function to generate a collection of files as a map with the path as the key and the contents of the file as the value. This function currently expects a list of plugin paths to load all plugins within a directory. Then, each plugin's generator.GenerateWithTarget() function is called for each target specified.
This function is the corresponding implementation for the "generate" CLI subcommand. It is also call when running the configurator as a service with the "/generate" route.
TODO: Separate loading plugins so we can load them once when running as a service.
type Generator ¶
type Generator interface { GetName() string GetVersion() string GetDescription() string Generate(config *config.Config, params Params) (FileMap, error) }
Generator interface used to define how files are created. Plugins can be created entirely independent of the main driver program.
func LoadPlugin ¶
Loads a single generator plugin given a single file path.
type Hostfile ¶ added in v0.1.1
type Hostfile struct{}
func (*Hostfile) GetDescription ¶ added in v0.1.1
func (*Hostfile) GetVersion ¶ added in v0.1.1
type Option ¶ added in v0.2.0
type Option func(Params)
func WithClientOpts ¶ added in v0.2.0
func WithTemplates ¶
type Params ¶
type Params struct { Templates map[string]Template Files map[string][]byte ClientOpts []client.Option Verbose bool }
Params used by the generator
type Powerman ¶ added in v0.1.1
type Powerman struct{}
func (*Powerman) GetDescription ¶ added in v0.1.1
func (*Powerman) GetVersion ¶ added in v0.1.1
type Syslog ¶ added in v0.1.1
type Syslog struct{}
func (*Syslog) GetDescription ¶ added in v0.1.1
func (*Syslog) GetVersion ¶ added in v0.1.1
type Template ¶
type Template struct {
Contents []byte `json:"contents"`
}
func (*Template) LoadFromFile ¶ added in v0.2.0
type Warewulf ¶ added in v0.1.1
type Warewulf struct{}