Documentation ¶
Index ¶
- Constants
- Variables
- func GetName(config map[string]interface{}) (string, error)
- func GetNameType(config map[string]interface{}) (string, string, error)
- func GetType(config map[string]interface{}) (string, error)
- func InitGlobalLogger(loggers []Logger)
- func InitializeConfigSourceFlags(set *pflag.FlagSet)
- func LoadGlobalConfiguration(config map[string]interface{}) error
- func LogLevelToString(l int) (string, error)
- func PathExists(path string) (bool, error)
- func RegisterConfigSource(name string, cs ConfigSource)
- func RegisterLogger(name string, l LoggerLoader)
- func RegisterSource(name string, s SourceLoader)
- func RegisterStep(name string, s StepLoader)
- func ShutdownGlobalLogger()
- func StringToLogLevel(s string) (int, error)
- type Component
- type Config
- type ConfigSource
- type ErrChefAlreadyInstalled
- type ErrComponentDoesNotExist
- type Event
- type ExtraLoggingFields
- type Logger
- type LoggerLoader
- type MultiLogger
- func (m *MultiLogger) Debugf(dbg int, s string, v ...interface{})
- func (m *MultiLogger) Errorf(s string, v ...interface{})
- func (m *MultiLogger) Infof(s string, v ...interface{})
- func (m *MultiLogger) Name() string
- func (m *MultiLogger) SetDebug(d int)
- func (m *MultiLogger) SetLevel(l int)
- func (m *MultiLogger) SetName(string)
- func (m *MultiLogger) Shutdown()
- func (m *MultiLogger) String() string
- func (m *MultiLogger) Type() string
- func (m *MultiLogger) WriteEvent(e *Event)
- type Source
- type SourceLoader
- type Step
- type StepLoader
Constants ¶
const ( LogLevelError = iota LogLevelInfo LogLevelDebug )
Log level constants
Variables ¶
var ( // AutoRegisterPlugins is a central place for plugins to check // whether they should auto-register. Normally they should. AutoRegisterPlugins = true // EarlyLogger is the logger used for pre-config logging. You can // substitute it if your use case requires. EarlyLogger = log.New(os.Stderr, "GO2CHEF ", log.LstdFlags) )
var ( // ErrConfigHasNoNameKey is thrown when a config block doesn't have a `name` key ErrConfigHasNoNameKey = errors.New("config map has no `name` key") // ErrConfigHasNoTypeKey is thrown when a config block doesn't have a `type` key ErrConfigHasNoTypeKey = errors.New("config map has no `type` key") )
var GlobalConfiguration = plugconf.NewPlugConf()
Functions ¶
func GetNameType ¶
GetNameType gets the name and type attributes from a config map
func InitGlobalLogger ¶
func InitGlobalLogger(loggers []Logger)
InitGlobalLogger initializes the global logger
func InitializeConfigSourceFlags ¶
InitializeConfigSourceFlags initializes a flag set with the flags required by the currently registered configuration source plugins.
func LoadGlobalConfiguration ¶
func LogLevelToString ¶
LogLevelToString translates a log level value to a string
func PathExists ¶
PathExists returns whether the given file or directory exists
func RegisterConfigSource ¶
func RegisterConfigSource(name string, cs ConfigSource)
RegisterConfigSource registers a new configuration source plugin
func RegisterLogger ¶
func RegisterLogger(name string, l LoggerLoader)
RegisterLogger registers a new logging plugin
func RegisterSource ¶
func RegisterSource(name string, s SourceLoader)
RegisterSource registers a new source plugin
func RegisterStep ¶
func RegisterStep(name string, s StepLoader)
RegisterStep registers a new step plugin with go2chef
func ShutdownGlobalLogger ¶
func ShutdownGlobalLogger()
ShutdownGlobalLogger shuts down the global logger
func StringToLogLevel ¶
StringToLogLevel translates a string to a log level
Types ¶
type ConfigSource ¶
type ConfigSource interface { // InitFlags sets up command line flags InitFlags(set *pflag.FlagSet) // ReadConfig actually reads in the configuration ReadConfig() (map[string]interface{}, error) }
ConfigSource defines the interface for configuration sources. These can be implemented however you like.
func GetConfigSource ¶
func GetConfigSource(name string) ConfigSource
GetConfigSource gets a specified configuration source plugin
type ErrChefAlreadyInstalled ¶
ErrChefAlreadyInstalled represents errors where Chef is already installed and provides a mechanism to pass metadata regarding the installed and requested versions back up the error chain.
func (*ErrChefAlreadyInstalled) Error ¶
func (e *ErrChefAlreadyInstalled) Error() string
Error returns the error string
type ErrComponentDoesNotExist ¶
type ErrComponentDoesNotExist struct {
Component string
}
ErrComponentDoesNotExist represents errors where a requested component (plugin) hasn't been registered.
func (*ErrComponentDoesNotExist) Error ¶
func (e *ErrComponentDoesNotExist) Error() string
Error returns the error string
type Event ¶
type Event struct { Event string Component string Message string ExtraFields *ExtraLoggingFields }
Event provides a more structured way to log information from go2chef plugins.
func NewEventWithExtraFields ¶
func NewEventWithExtraFields(event, component, message string, extrafields *ExtraLoggingFields) *Event
NewEvent returns a new event using the provided parameters
type ExtraLoggingFields ¶
type Logger ¶
type Logger interface { Component SetLevel(lvl int) SetDebug(dbg int) Debugf(dbg int, fmt string, args ...interface{}) Infof(fmt string, args ...interface{}) Errorf(fmt string, args ...interface{}) // WriteEvent writes an event object to this logger WriteEvent(e *Event) // Shutdown allows go2chef to wait for loggers to finish writes // if necessary (i.e. to remote endpoints) Shutdown() }
Logger defines the interface for logging components.
func GetGlobalLogger ¶
func GetGlobalLogger() Logger
GetGlobalLogger gets an instance of the global logger
func GetLogger ¶
GetLogger gets a new instance of the Logger type specified by `name` and returns it configured as with config map[string]interface{}
func GetLoggers ¶
GetLoggers extracts an array of loggers from a config map
type LoggerLoader ¶
LoggerLoader defines the call signature for functions which return fully configured Logger instances
type MultiLogger ¶
type MultiLogger struct {
// contains filtered or unexported fields
}
MultiLogger is a fan-out logger for use as the central logging broker in go2chef
func NewMultiLogger ¶
func NewMultiLogger(loggers []Logger) *MultiLogger
NewMultiLogger returns a MultiLogger with the provided list of loggers set up to receive logs.
func (*MultiLogger) Debugf ¶
func (m *MultiLogger) Debugf(dbg int, s string, v ...interface{})
Debugf logs a formatted message at DEBUG level
func (*MultiLogger) Errorf ¶
func (m *MultiLogger) Errorf(s string, v ...interface{})
Errorf logs a formatted message at ERROR level
func (*MultiLogger) Infof ¶
func (m *MultiLogger) Infof(s string, v ...interface{})
Infof logs a formatted message at INFO level
func (*MultiLogger) SetDebug ¶
func (m *MultiLogger) SetDebug(d int)
SetDebug sets the logger's debug level threshold
func (*MultiLogger) SetLevel ¶
func (m *MultiLogger) SetLevel(l int)
SetLevel sets the logger's overall level threshold
func (*MultiLogger) SetName ¶
func (m *MultiLogger) SetName(string)
SetName is a no-op for this logger
func (*MultiLogger) Shutdown ¶
func (m *MultiLogger) Shutdown()
Shutdown shuts down all loggers on this MultiLogger
func (*MultiLogger) String ¶
func (m *MultiLogger) String() string
func (*MultiLogger) WriteEvent ¶
func (m *MultiLogger) WriteEvent(e *Event)
WriteEvent writes an event to all loggers on this MultiLogger
type Source ¶
Source defines the interface for source download components
func GetSourceFromStepConfig ¶
GetSourceFromStepConfig gets a Source from a Step's config map. If there is no `source` key, then it will return a nil Source and no error.
type SourceLoader ¶
SourceLoader represents factory functions for Sources
type Step ¶
Step defines the interface for go2chef execution steps
type StepLoader ¶
StepLoader defines the function call interface for step loaders
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
plugin
|
|
config/embed
Package embed is a configuration source that can be fully compiled-in
|
Package embed is a configuration source that can be fully compiled-in |