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:
13
svc.go
13
svc.go
@@ -35,19 +35,20 @@ type SvcRes struct {
|
||||
}
|
||||
|
||||
func NewSvcRes(name, state, startup string) *SvcRes {
|
||||
return &SvcRes{
|
||||
obj := &SvcRes{
|
||||
BaseRes: BaseRes{
|
||||
Name: name,
|
||||
events: make(chan Event),
|
||||
vertex: nil,
|
||||
Name: name,
|
||||
},
|
||||
State: state,
|
||||
Startup: startup,
|
||||
}
|
||||
obj.Init()
|
||||
return obj
|
||||
}
|
||||
|
||||
func (obj *SvcRes) Kind() string {
|
||||
return "Svc"
|
||||
func (obj *SvcRes) Init() {
|
||||
obj.BaseRes.kind = "Svc"
|
||||
obj.BaseRes.Init() // call base init, b/c we're overriding
|
||||
}
|
||||
|
||||
func (obj *SvcRes) Validate() bool {
|
||||
|
||||
Reference in New Issue
Block a user