Documentation ¶
Overview ¶
Package config defines the structure of zedpm configuration and defines the functions for leading that configuration.
Index ¶
- Variables
- func GoalPhaseAndTaskName(taskPath string) (string, string, string, error)
- type ActionConfig
- type Config
- func (c *Config) GetGoal(goalName string) *GoalConfig
- func (c *Config) GetGoalFromPath(taskPath string) (*GoalConfig, error)
- func (c *Config) GetGoalPhaseAndTaskConfig(taskPath string) (*GoalConfig, *PhaseConfig, *TaskConfig, error)
- func (c *Config) GetPlugin(pluginName string) *PluginConfig
- func (c *Config) ToKV(properties storage.KV, taskPath, targetName, pluginName string) (*storage.KVLayer, error)
- type GoalConfig
- type PhaseConfig
- type PluginConfig
- type RawConfig
- type RawGoalConfig
- type RawPhaseConfig
- type RawPluginConfig
- type RawTargetConfig
- type RawTaskConfig
- type TargetConfig
- type TaskConfig
Constants ¶
This section is empty.
Variables ¶
var ( // ErrMissingPrefix is returned by GoalPhaseAndTaskName when the initial // slash is missing. ErrMissingPrefix = errors.New("task path is missing prefix") // ErrIncorrectName is returned by GoalPhaseAndTaskName when any of the // names are not correct. The names are made up of one or more words joined // by a hyphen. Each word must start with an underscore or letter and then // may be followed by zero or more underscores, letters, or numbers. ErrIncorrectName = errors.New("task path contains incorrect names") // ErrTooManyNames is returned by GoalPhaseAndTaskName when more than three // names are present in the task path. ErrTooManyNames = errors.New("task path contains too many names") )
Functions ¶
func GoalPhaseAndTaskName ¶ added in v0.1.0
GoalPhaseAndTaskName splits a string of the form /goal/phase/task and returns it returns strings "goal", "phase", and "task". Returns an error if the task path is badly formed.
The following error condition are possible:
Returns ErrMissingParts if the task path is missing the initial slash or there are not enough slashes present.
Returns ErrIncorrectName if a goal, phase, or task name is not legal. The legal names must contain one or more words. Each word is defined as value starting with an underscore or letter (any Unicode letter) followed by 0 or more underscores, letters, or numbers (again, any Unicode number). Multiple words must be joined with a hyphen. That is, this "/_foo44-blahblah/florby_flah/bl00p" defines goal, phase, and task with legal name values, but "/44_floo/feebly fly/%&$*" is illegal with all three names being disallowed for different reasons.
Returns ErrTooManyNames if the task path contains more than three slashes.
Types ¶
type ActionConfig ¶ added in v0.1.0
type ActionConfig struct { // Name is the name of the action being configured. Name string // EnabledPlugins creates an allow list of plugins to use when executing // this action. If an enable list is provided, then only plugins on this // list will be executed. // // TODO Implement EnabledPlugins functionality. EnabledPlugins []string // DisabledPlugins creates a block list of plugins to disable when executing // this action. If a disabled list is provided, then the listed plugins will // not be executed when running this goal, even if they are listed in the // EnabledPlugins list. // // TODO Implement DisabledPlugins functionality. DisabledPlugins []string // Properties provides settings that override globals when executing this // action. Properties storage.KV // Targets provides configuration of targets as applies ot this action. Targets []TargetConfig }
ActionConfig defines common configuration for goals, phases, and tasks.
func (*ActionConfig) GetProperties ¶ added in v0.1.0
func (a *ActionConfig) GetProperties() storage.KV
GetProperties returns the properties.
func (*ActionConfig) GetTarget ¶ added in v0.1.0
func (a *ActionConfig) GetTarget(targetName string) *TargetConfig
GetTarget returns the TargetConfig for the given target name.
type Config ¶
type Config struct { // Properties are the global properties that are used as the value if not // overridden by any other configuration section. Properties storage.KV // Goals is the configuration to apply to each goal. Goals []GoalConfig // Plugins is the configuration to apply to each plugin. Plugins []PluginConfig }
Config is the master configuration as we use it in the application. The configuration format is in HCL. The actual HCL definition are with the Raw* structures, which are converted into these structures to handle the conversion of generic JSON-style objects used for Properties into storage.KV objects as working with JSON-style objects in HCL is ugly without some conversion like this.
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig is the ultimate fallback configuration, used when no other configuration can be found.
func Load ¶
Load will load the HCL configuration from the given io.Reader, using the given filename as the one passed to the HCL library, which it uses to help generate useful error messages.
func LocateAndLoad ¶
LocateAndLoad will attempt to load the configuration from the project directory. If that fails, it will look for a global home directory configuration. If that fails, it will fall back onto the ultimate default configuration.
func LocateAndLoadHome ¶
LocateAndLoadHome will load the user-global configuration file from
~/.zedpm.conf
This file is only used for goals outside of an existing project (such as init).
func LocateAndLoadProject ¶
LocateAndLoadProject will load the local project configuration file. This file is loaded from the current working directory if possible. If not, this function will try to find the file in one of the next three folders outside the current directory and will stop if it appears to encounter a project root, which is detected by looking for a .git directory or go.mod file.
func (*Config) GetGoal ¶
func (c *Config) GetGoal(goalName string) *GoalConfig
GetGoal returns the GoalConfig for the given goal name.
func (*Config) GetGoalFromPath ¶
func (c *Config) GetGoalFromPath(taskPath string) (*GoalConfig, error)
GetGoalFromPath returns the goal configuration for the given task path.
func (*Config) GetGoalPhaseAndTaskConfig ¶ added in v0.1.0
func (c *Config) GetGoalPhaseAndTaskConfig( taskPath string, ) (*GoalConfig, *PhaseConfig, *TaskConfig, error)
GetGoalPhaseAndTaskConfig returns the goal, phase, and task configuration of the given task path.
func (*Config) GetPlugin ¶
func (c *Config) GetPlugin(pluginName string) *PluginConfig
GetPlugin returns the PluginConfig for the given plugin name.
func (*Config) ToKV ¶
func (c *Config) ToKV( properties storage.KV, taskPath, targetName, pluginName string, ) (*storage.KVLayer, error)
ToKV builds and returns a storage.KVLayer containing the configuration layers matching the given taskPath, targetName, and pluginName in proper order (i.e., so that scope overrides happen correctly). The given properties store will be the top-most layer.
The scopes override each other in the following order, with the first mentioned item overriding everything below it:
1. Property Settings (from the given properties argument)
2. Target Settings on Task
3. Task Settings
4. Target Settings on Goal
5. Goal Settings
6. Plugin Settings
7. Global Settings
And that's all.
type GoalConfig ¶
type GoalConfig struct { ActionConfig // InterleavedTasks provides configuration of sub-tasks of this goal. Phases []PhaseConfig }
GoalConfig contains the configuration assigned to goals, which is also inherited by phases and tasks.
type PhaseConfig ¶ added in v0.1.0
type PhaseConfig struct { ActionConfig // Tasks provides configuration of sub-tasks of this goal. Tasks []TaskConfig }
PhaseConfig contains the configuration assigned to phases, which is also inherited by tasks.
type PluginConfig ¶
type PluginConfig struct { // Name is the name to give the plugin. Name string // Command is the command to execute to run the plugin. Command string // Properties provides settings that overwrite globals when executing this // plugin. Properties storage.KV }
PluginConfig holds the configuration to use for a particular plugin.
type RawConfig ¶
type RawConfig struct { Properties cty.Value `hcl:"properties,optional"` Goals []RawGoalConfig `hcl:"goal,block"` Plugins []RawPluginConfig `hcl:"plugin,block"` }
RawConfig is the configuration specification for HCL. See Config for details on what the fields represent.
type RawGoalConfig ¶
type RawGoalConfig struct { Name string `hcl:"name,label"` EnabledPlugins []string `hcl:"enabled,optional"` DisabledPlugins []string `hcl:"disabled,optional"` Properties cty.Value `hcl:"properties,optional"` Phases []RawPhaseConfig `hcl:"phase,block"` Targets []RawTargetConfig `hcl:"target,block"` }
RawGoalConfig is the configuration specification for HCL for goal configuration. See GoalConfig for details on what the fields represent.
type RawPhaseConfig ¶ added in v0.1.0
type RawPhaseConfig struct { Name string `hcl:"name,label"` EnabledPlugins []string `hcl:"enabled,optional"` DisabledPlugins []string `hcl:"disabled,optional"` Properties cty.Value `hcl:"properties,optional"` Tasks []RawTaskConfig `hcl:"task,block"` Targets []RawTargetConfig `hcl:"target,block"` }
RawPhaseConfig is the configuration specification for HCL for phase configuration. See PhaseConfig for details on what the fields represent.
type RawPluginConfig ¶
type RawPluginConfig struct { Name string `hcl:"name,label"` Command string `hcl:"command,label"` Properties cty.Value `hcl:"properties,optional"` }
RawPluginConfig is the configuration specification for HCL for plugin configuration. See PluginConfig for details on what the fields represent.
type RawTargetConfig ¶
type RawTargetConfig struct { Name string `hcl:"name,label"` EnabledPlugins []string `hcl:"enabled,optional"` DisabledPlugins []string `hcl:"disabled,optional"` Properties cty.Value `hcl:"properties,optional"` }
RawTargetConfig is the configuration specification for HCL for target configuration. See TargetConfig for details on what the fields represent.
type RawTaskConfig ¶
type RawTaskConfig struct { Name string `hcl:"name,label"` EnabledPlugins []string `hcl:"enabled,optional"` DisabledPlugins []string `hcl:"disabled,optional"` Properties cty.Value `hcl:"properties,optional"` Targets []RawTargetConfig `hcl:"target,block"` }
RawTaskConfig is the configuration specification for HCL for task configuration. See TaskConfig for details on what the fields represent.
type TargetConfig ¶
type TargetConfig struct { // Name is the name to give the target. Name string // EnabledPlugins creates an allow list of plugins to use when executing // this target. If an enable list is provided, then only plugins on this // list will be executed. // // TODO Implement EnabledPlugins functionality for targets. EnabledPlugins []string // DisabledPlugins creates a block list of plugins to disable when executing // this target. If a disabled list is provided, then the listed plugins // will not be executed when running this sub-task, even if they are listed // in the EnabledPlugins list. // // TODO Implement DisabledPlugins functionality for targets. DisabledPlugins []string // Properties are the settings that will override those of the global // settings or the parent goal or task. Properties storage.KV }
TargetConfig is the configuration of a target, which allows for multiple configurations for each goal in case you need a different configuration per environment or per output binary or whatever.
type TaskConfig ¶
type TaskConfig struct {
ActionConfig
}
TaskConfig is the configuration for a sub-task, which is always nested within a goal configuration. This configuration will be employed while running this sub-task regardless of how executed from the command-line.
TODO The sub-sub-task configuration here seems inconsistent and needs a look.