resources: Officially add Validate method

This officially adds the Validate method to the resource API, and also
cleans up the ordering in existing resources.
This commit is contained in:
James Shubin
2017-01-09 05:05:16 -05:00
parent 668ec8a248
commit 56efef69ba
13 changed files with 120 additions and 115 deletions

View File

@@ -74,14 +74,7 @@ func (obj *ExecRes) Default() Res {
return &ExecRes{}
}
// Init runs some startup code for this resource.
func (obj *ExecRes) Init() error {
obj.BaseRes.kind = "Exec"
return obj.BaseRes.Init() // call base init, b/c we're overriding
}
// Validate if the params passed in are valid data.
// FIXME: where should this get called ?
func (obj *ExecRes) Validate() error {
if obj.Cmd == "" { // this is the only thing that is really required
return fmt.Errorf("Command can't be empty!")
@@ -95,6 +88,12 @@ func (obj *ExecRes) Validate() error {
return nil
}
// Init runs some startup code for this resource.
func (obj *ExecRes) Init() error {
obj.BaseRes.kind = "Exec"
return obj.BaseRes.Init() // call base init, b/c we're overriding
}
// BufioChanScanner wraps the scanner output in a channel.
func (obj *ExecRes) BufioChanScanner(scanner *bufio.Scanner) (chan string, chan error) {
ch, errch := make(chan string), make(chan error)