Make resource "kind" determination more obvious

By adding the "kind" to the base resource, it is still identifiable even
when the resource specific elements are gone in calls that are only
defined in the base resource. This is also more logical for building
resources!

This also switches resources to use an Init() method. This will be
useful for when resources have more complex initialization to do.
This commit is contained in:
James Shubin
2016-03-03 19:12:44 -05:00
parent c999f0c2cd
commit 10b8c93da4
6 changed files with 61 additions and 53 deletions

14
exec.go
View File

@@ -40,12 +40,9 @@ type ExecRes struct {
}
func NewExecRes(name, cmd, shell string, timeout int, watchcmd, watchshell, ifcmd, ifshell string, pollint int, state string) *ExecRes {
// FIXME if path = nil, path = name ...
return &ExecRes{
obj := &ExecRes{
BaseRes: BaseRes{
Name: name,
events: make(chan Event),
vertex: nil,
Name: name,
},
Cmd: cmd,
Shell: shell,
@@ -57,10 +54,13 @@ func NewExecRes(name, cmd, shell string, timeout int, watchcmd, watchshell, ifcm
PollInt: pollint,
State: state,
}
obj.Init()
return obj
}
func (obj *ExecRes) Kind() string {
return "Exec"
func (obj *ExecRes) Init() {
obj.BaseRes.kind = "Exec"
obj.BaseRes.Init() // call base init, b/c we're overriding
}
// validate if the params passed in are valid data