Resources: Update interface to support errors
This was an early interface mistake I made and is now corrected. We'll plumb in checking the error state of Init() and running Validate() later on.
This commit is contained in:
@@ -104,8 +104,8 @@ type Base interface {
|
||||
// Res is the minimum interface you need to implement to define a new resource.
|
||||
type Res interface {
|
||||
Base // include everything from the Base interface
|
||||
Init()
|
||||
//Validate() bool // TODO: this might one day be added
|
||||
Init() error
|
||||
//Validate() error // TODO: this might one day be added
|
||||
GetUUIDs() []ResUUID // most resources only return one
|
||||
Watch(chan event.Event) error // send on channel to signal process() events
|
||||
CheckApply(bool) (bool, error)
|
||||
@@ -170,8 +170,9 @@ func (obj *BaseUUID) Reversed() bool {
|
||||
}
|
||||
|
||||
// Init initializes structures like channels if created without New constructor.
|
||||
func (obj *BaseRes) Init() {
|
||||
func (obj *BaseRes) Init() error {
|
||||
obj.events = make(chan event.Event) // unbuffered chan size to avoid stale events
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetName is used by all the resources to Get the name.
|
||||
|
||||
Reference in New Issue
Block a user