engine: resources, lang: Set resource fields more accurately
There were some bugs about setting resource fields that were structs with various fields. This makes things more strict and correct. Now we check for duplicate field names earlier (duplicates due to identical aliases) and we also don't try and set private fields, or incorrectly set partial structs. Most interestingly, this also cleans up all of the resources and ensures that each one has nicer docs and a clear struct tag for fields that we want to use in mcl. These are mandatory now, and if you're missing the tag, then we will ignore the field.
This commit is contained in:
@@ -50,24 +50,24 @@ type AugeasRes struct {
|
||||
init *engine.Init
|
||||
|
||||
// File is the path to the file targeted by this resource.
|
||||
File string `yaml:"file"`
|
||||
File string `lang:"file" yaml:"file"`
|
||||
|
||||
// Lens is the lens used by this resource. If specified, mgmt
|
||||
// will lower the augeas overhead by only loading that lens.
|
||||
Lens string `yaml:"lens"`
|
||||
Lens string `lang:"lens" yaml:"lens"`
|
||||
|
||||
// Sets is a list of changes that will be applied to the file, in the form of
|
||||
// ["path", "value"]. mgmt will run augeas.Get() before augeas.Set(), to
|
||||
// prevent changing the file when it is not needed.
|
||||
Sets []*AugeasSet `yaml:"sets"`
|
||||
// Sets is a list of changes that will be applied to the file, in the
|
||||
// form of ["path", "value"]. mgmt will run augeas.Get() before
|
||||
// augeas.Set(), to prevent changing the file when it is not needed.
|
||||
Sets []*AugeasSet `lang:"sets" yaml:"sets"`
|
||||
|
||||
recWatcher *recwatch.RecWatcher // used to watch the changed files
|
||||
}
|
||||
|
||||
// AugeasSet represents a key/value pair of settings to be applied.
|
||||
type AugeasSet struct {
|
||||
Path string `yaml:"path"` // The relative path to the value to be changed.
|
||||
Value string `yaml:"value"` // The value to be set on the given Path.
|
||||
Path string `lang:"path" yaml:"path"` // The relative path to the value to be changed.
|
||||
Value string `lang:"value" yaml:"value"` // The value to be set on the given Path.
|
||||
}
|
||||
|
||||
// Cmp compares this set with another one.
|
||||
|
||||
Reference in New Issue
Block a user