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

13
file.go
View File

@@ -43,11 +43,9 @@ type FileRes struct {
func NewFileRes(name, path, dirname, basename, content, state string) *FileRes {
// FIXME if path = nil, path = name ...
return &FileRes{
obj := &FileRes{
BaseRes: BaseRes{
Name: name,
events: make(chan Event),
vertex: nil,
Name: name,
},
Path: path,
Dirname: dirname,
@@ -56,10 +54,13 @@ func NewFileRes(name, path, dirname, basename, content, state string) *FileRes {
State: state,
sha256sum: "",
}
obj.Init()
return obj
}
func (obj *FileRes) Kind() string {
return "File"
func (obj *FileRes) Init() {
obj.BaseRes.kind = "File"
obj.BaseRes.Init() // call base init, b/c we're overriding
}
func (obj *FileRes) GetPath() string {