resources: golint fixes

This commit is contained in:
James Shubin
2016-09-02 01:46:00 -04:00
parent b46432b5b6
commit 8003202beb
6 changed files with 72 additions and 19 deletions

11
exec.go
View File

@@ -45,6 +45,7 @@ type ExecRes struct {
PollInt int `yaml:"pollint"` // the poll interval for the ifcmd PollInt int `yaml:"pollint"` // the poll interval for the ifcmd
} }
// NewExecRes is a constructor for this resource. It also calls Init() for you.
func NewExecRes(name, cmd, shell string, timeout int, watchcmd, watchshell, ifcmd, ifshell string, pollint int, state string) *ExecRes { func NewExecRes(name, cmd, shell string, timeout int, watchcmd, watchshell, ifcmd, ifshell string, pollint int, state string) *ExecRes {
obj := &ExecRes{ obj := &ExecRes{
BaseRes: BaseRes{ BaseRes: BaseRes{
@@ -64,6 +65,7 @@ func NewExecRes(name, cmd, shell string, timeout int, watchcmd, watchshell, ifcm
return obj return obj
} }
// Init runs some startup code for this resource.
func (obj *ExecRes) Init() { func (obj *ExecRes) Init() {
obj.BaseRes.kind = "Exec" obj.BaseRes.kind = "Exec"
obj.BaseRes.Init() // call base init, b/c we're overriding obj.BaseRes.Init() // call base init, b/c we're overriding
@@ -102,7 +104,7 @@ func (obj *ExecRes) BufioChanScanner(scanner *bufio.Scanner) (chan string, chan
return ch, errch return ch, errch
} }
// Exec watcher // Watch is the primary listener for this resource and it outputs events.
func (obj *ExecRes) Watch(processChan chan Event) { func (obj *ExecRes) Watch(processChan chan Event) {
if obj.IsWatching() { if obj.IsWatching() {
return return
@@ -201,6 +203,8 @@ func (obj *ExecRes) Watch(processChan chan Event) {
} }
} }
// CheckApply checks the resource state and applies the resource if the bool
// input is true. It returns error info and if the state check passed or not.
// TODO: expand the IfCmd to be a list of commands // TODO: expand the IfCmd to be a list of commands
func (obj *ExecRes) CheckApply(apply bool) (checkok bool, err error) { func (obj *ExecRes) CheckApply(apply bool) (checkok bool, err error) {
log.Printf("%v[%v]: CheckApply(%t)", obj.Kind(), obj.GetName(), apply) log.Printf("%v[%v]: CheckApply(%t)", obj.Kind(), obj.GetName(), apply)
@@ -371,7 +375,8 @@ func (obj *ExecRes) AutoEdges() AutoEdge {
return nil return nil
} }
// include all params to make a unique identification of this object // GetUUIDs includes all params to make a unique identification of this object.
// Most resources only return one, although some resources can return multiple.
func (obj *ExecRes) GetUUIDs() []ResUUID { func (obj *ExecRes) GetUUIDs() []ResUUID {
x := &ExecUUID{ x := &ExecUUID{
BaseUUID: BaseUUID{name: obj.GetName(), kind: obj.Kind()}, BaseUUID: BaseUUID{name: obj.GetName(), kind: obj.Kind()},
@@ -382,6 +387,7 @@ func (obj *ExecRes) GetUUIDs() []ResUUID {
return []ResUUID{x} return []ResUUID{x}
} }
// GroupCmp returns whether two resources can be grouped together or not.
func (obj *ExecRes) GroupCmp(r Res) bool { func (obj *ExecRes) GroupCmp(r Res) bool {
_, ok := r.(*ExecRes) _, ok := r.(*ExecRes)
if !ok { if !ok {
@@ -390,6 +396,7 @@ func (obj *ExecRes) GroupCmp(r Res) bool {
return false // not possible atm return false // not possible atm
} }
// Compare two resources and return if they are equivalent.
func (obj *ExecRes) Compare(res Res) bool { func (obj *ExecRes) Compare(res Res) bool {
switch res.(type) { switch res.(type) {
case *ExecRes: case *ExecRes:

26
file.go
View File

@@ -47,6 +47,7 @@ type FileRes struct {
sha256sum string sha256sum string
} }
// NewFileRes is a constructor for this resource. It also calls Init() for you.
func NewFileRes(name, path, dirname, basename, content, state string) *FileRes { func NewFileRes(name, path, dirname, basename, content, state string) *FileRes {
// FIXME if path = nil, path = name ... // FIXME if path = nil, path = name ...
obj := &FileRes{ obj := &FileRes{
@@ -64,11 +65,14 @@ func NewFileRes(name, path, dirname, basename, content, state string) *FileRes {
return obj return obj
} }
// Init runs some startup code for this resource.
func (obj *FileRes) Init() { func (obj *FileRes) Init() {
obj.BaseRes.kind = "File" obj.BaseRes.kind = "File"
obj.BaseRes.Init() // call base init, b/c we're overriding obj.BaseRes.Init() // call base init, b/c we're overriding
} }
// GetPath returns the actual path to use for this resource. It computes this
// after analysis of the path, dirname and basename values.
func (obj *FileRes) GetPath() string { func (obj *FileRes) GetPath() string {
d := Dirname(obj.Path) d := Dirname(obj.Path)
b := Basename(obj.Path) b := Basename(obj.Path)
@@ -100,8 +104,9 @@ func (obj *FileRes) Validate() bool {
return true return true
} }
// File watcher for files and directories // Watch is the primary listener for this resource and it outputs events.
// Modify with caution, probably important to write some test cases first! // This one is a file watcher for files and directories.
// Modify with caution, it is probably important to write some test cases first!
// obj.GetPath(): file or directory // obj.GetPath(): file or directory
func (obj *FileRes) Watch(processChan chan Event) { func (obj *FileRes) Watch(processChan chan Event) {
if obj.IsWatching() { if obj.IsWatching() {
@@ -268,6 +273,8 @@ func (obj *FileRes) Watch(processChan chan Event) {
} }
} }
// HashSHA256fromContent computes the hash of the file contents and returns it.
// It also caches the value if it can.
func (obj *FileRes) HashSHA256fromContent() string { func (obj *FileRes) HashSHA256fromContent() string {
if obj.sha256sum != "" { // return if already computed if obj.sha256sum != "" { // return if already computed
return obj.sha256sum return obj.sha256sum
@@ -279,6 +286,8 @@ func (obj *FileRes) HashSHA256fromContent() string {
return obj.sha256sum return obj.sha256sum
} }
// FileHashSHA256Check computes the hash of the actual file and compares it to
// the computed hash of the resources file contents.
func (obj *FileRes) FileHashSHA256Check() (bool, error) { func (obj *FileRes) FileHashSHA256Check() (bool, error) {
if PathIsDir(obj.GetPath()) { // assert if PathIsDir(obj.GetPath()) { // assert
log.Fatal("This should only be called on a File resource.") log.Fatal("This should only be called on a File resource.")
@@ -304,6 +313,8 @@ func (obj *FileRes) FileHashSHA256Check() (bool, error) {
return false, nil return false, nil
} }
// FileApply writes the resource file contents out to the correct path. This
// implementation doesn't try to be particularly clever in any way.
func (obj *FileRes) FileApply() error { func (obj *FileRes) FileApply() error {
if PathIsDir(obj.GetPath()) { if PathIsDir(obj.GetPath()) {
log.Fatal("This should only be called on a File resource.") log.Fatal("This should only be called on a File resource.")
@@ -329,6 +340,8 @@ func (obj *FileRes) FileApply() error {
return nil // success return nil // success
} }
// CheckApply checks the resource state and applies the resource if the bool
// input is true. It returns error info and if the state check passed or not.
func (obj *FileRes) CheckApply(apply bool) (checkok bool, err error) { func (obj *FileRes) CheckApply(apply bool) (checkok bool, err error) {
log.Printf("%v[%v]: CheckApply(%t)", obj.Kind(), obj.GetName(), apply) log.Printf("%v[%v]: CheckApply(%t)", obj.Kind(), obj.GetName(), apply)
@@ -398,12 +411,14 @@ func (obj *FileUUID) IFF(uuid ResUUID) bool {
return obj.path == res.path return obj.path == res.path
} }
// FileResAutoEdges holds the state of the auto edge generator.
type FileResAutoEdges struct { type FileResAutoEdges struct {
data []ResUUID data []ResUUID
pointer int pointer int
found bool found bool
} }
// Next returns the next automatic edge.
func (obj *FileResAutoEdges) Next() []ResUUID { func (obj *FileResAutoEdges) Next() []ResUUID {
if obj.found { if obj.found {
log.Fatal("Shouldn't be called anymore!") log.Fatal("Shouldn't be called anymore!")
@@ -416,7 +431,7 @@ func (obj *FileResAutoEdges) Next() []ResUUID {
return []ResUUID{value} // we return one, even though api supports N return []ResUUID{value} // we return one, even though api supports N
} }
// get results of the earlier Next() call, return if we should continue! // Test gets results of the earlier Next() call, & returns if we should continue!
func (obj *FileResAutoEdges) Test(input []bool) bool { func (obj *FileResAutoEdges) Test(input []bool) bool {
// if there aren't any more remaining // if there aren't any more remaining
if len(obj.data) <= obj.pointer { if len(obj.data) <= obj.pointer {
@@ -459,6 +474,8 @@ func (obj *FileRes) AutoEdges() AutoEdge {
} }
} }
// GetUUIDs includes all params to make a unique identification of this object.
// Most resources only return one, although some resources can return multiple.
func (obj *FileRes) GetUUIDs() []ResUUID { func (obj *FileRes) GetUUIDs() []ResUUID {
x := &FileUUID{ x := &FileUUID{
BaseUUID: BaseUUID{name: obj.GetName(), kind: obj.Kind()}, BaseUUID: BaseUUID{name: obj.GetName(), kind: obj.Kind()},
@@ -467,6 +484,7 @@ func (obj *FileRes) GetUUIDs() []ResUUID {
return []ResUUID{x} return []ResUUID{x}
} }
// GroupCmp returns whether two resources can be grouped together or not.
func (obj *FileRes) GroupCmp(r Res) bool { func (obj *FileRes) GroupCmp(r Res) bool {
_, ok := r.(*FileRes) _, ok := r.(*FileRes)
if !ok { if !ok {
@@ -477,6 +495,7 @@ func (obj *FileRes) GroupCmp(r Res) bool {
return false // not possible atm return false // not possible atm
} }
// Compare two resources and return if they are equivalent.
func (obj *FileRes) Compare(res Res) bool { func (obj *FileRes) Compare(res Res) bool {
switch res.(type) { switch res.(type) {
case *FileRes: case *FileRes:
@@ -503,6 +522,7 @@ func (obj *FileRes) Compare(res Res) bool {
return true return true
} }
// CollectPattern applies the pattern for collection resources.
func (obj *FileRes) CollectPattern(pattern string) { func (obj *FileRes) CollectPattern(pattern string) {
// XXX: currently the pattern for files can only override the Dirname variable :P // XXX: currently the pattern for files can only override the Dirname variable :P
obj.Dirname = pattern // XXX: simplistic for now obj.Dirname = pattern // XXX: simplistic for now

View File

@@ -32,6 +32,7 @@ type NoopRes struct {
Comment string `yaml:"comment"` // extra field for example purposes Comment string `yaml:"comment"` // extra field for example purposes
} }
// NewNoopRes is a constructor for this resource. It also calls Init() for you.
func NewNoopRes(name string) *NoopRes { func NewNoopRes(name string) *NoopRes {
obj := &NoopRes{ obj := &NoopRes{
BaseRes: BaseRes{ BaseRes: BaseRes{
@@ -43,6 +44,7 @@ func NewNoopRes(name string) *NoopRes {
return obj return obj
} }
// Init runs some startup code for this resource.
func (obj *NoopRes) Init() { func (obj *NoopRes) Init() {
obj.BaseRes.kind = "Noop" obj.BaseRes.kind = "Noop"
obj.BaseRes.Init() // call base init, b/c we're overriding obj.BaseRes.Init() // call base init, b/c we're overriding
@@ -54,6 +56,7 @@ func (obj *NoopRes) Validate() bool {
return true return true
} }
// Watch is the primary listener for this resource and it outputs events.
func (obj *NoopRes) Watch(processChan chan Event) { func (obj *NoopRes) Watch(processChan chan Event) {
if obj.IsWatching() { if obj.IsWatching() {
return return
@@ -109,8 +112,8 @@ func (obj *NoopRes) AutoEdges() AutoEdge {
return nil return nil
} }
// include all params to make a unique identification of this object // GetUUIDs includes all params to make a unique identification of this object.
// most resources only return one, although some resources return multiple // Most resources only return one, although some resources can return multiple.
func (obj *NoopRes) GetUUIDs() []ResUUID { func (obj *NoopRes) GetUUIDs() []ResUUID {
x := &NoopUUID{ x := &NoopUUID{
BaseUUID: BaseUUID{name: obj.GetName(), kind: obj.Kind()}, BaseUUID: BaseUUID{name: obj.GetName(), kind: obj.Kind()},
@@ -119,6 +122,7 @@ func (obj *NoopRes) GetUUIDs() []ResUUID {
return []ResUUID{x} return []ResUUID{x}
} }
// GroupCmp returns whether two resources can be grouped together or not.
func (obj *NoopRes) GroupCmp(r Res) bool { func (obj *NoopRes) GroupCmp(r Res) bool {
_, ok := r.(*NoopRes) _, ok := r.(*NoopRes)
if !ok { if !ok {
@@ -131,6 +135,7 @@ func (obj *NoopRes) GroupCmp(r Res) bool {
return true // noop resources can always be grouped together! return true // noop resources can always be grouped together!
} }
// Compare two resources and return if they are equivalent.
func (obj *NoopRes) Compare(res Res) bool { func (obj *NoopRes) Compare(res Res) bool {
switch res.(type) { switch res.(type) {
// we can only compare NoopRes to others of the same resource // we can only compare NoopRes to others of the same resource

18
pkg.go
View File

@@ -42,7 +42,7 @@ type PkgRes struct {
fileList []string // FIXME: update if pkg changes fileList []string // FIXME: update if pkg changes
} }
// NewPkgRes is a helper function for creating new resources that call Init(). // NewPkgRes is a constructor for this resource. It also calls Init() for you.
func NewPkgRes(name, state string, allowuntrusted, allownonfree, allowunsupported bool) *PkgRes { func NewPkgRes(name, state string, allowuntrusted, allownonfree, allowunsupported bool) *PkgRes {
obj := &PkgRes{ obj := &PkgRes{
BaseRes: BaseRes{ BaseRes: BaseRes{
@@ -57,6 +57,7 @@ func NewPkgRes(name, state string, allowuntrusted, allownonfree, allowunsupporte
return obj return obj
} }
// Init runs some startup code for this resource.
func (obj *PkgRes) Init() { func (obj *PkgRes) Init() {
obj.BaseRes.kind = "Pkg" obj.BaseRes.kind = "Pkg"
obj.BaseRes.Init() // call base init, b/c we're overriding obj.BaseRes.Init() // call base init, b/c we're overriding
@@ -94,8 +95,8 @@ func (obj *PkgRes) Init() {
} }
} }
// Validate checks if the resource data structure was populated correctly.
func (obj *PkgRes) Validate() bool { func (obj *PkgRes) Validate() bool {
if obj.State == "" { if obj.State == "" {
return false return false
} }
@@ -103,7 +104,8 @@ func (obj *PkgRes) Validate() bool {
return true return true
} }
// use UpdatesChanged signal to watch for changes // Watch is the primary listener for this resource and it outputs events.
// It uses the PackageKit UpdatesChanged signal to watch for changes.
// TODO: https://github.com/hughsie/PackageKit/issues/109 // TODO: https://github.com/hughsie/PackageKit/issues/109
// TODO: https://github.com/hughsie/PackageKit/issues/110 // TODO: https://github.com/hughsie/PackageKit/issues/110
func (obj *PkgRes) Watch(processChan chan Event) { func (obj *PkgRes) Watch(processChan chan Event) {
@@ -243,6 +245,8 @@ func (obj *PkgRes) pkgMappingHelper(bus *Conn) (map[string]*PkPackageIDActionDat
return result, nil return result, nil
} }
// CheckApply checks the resource state and applies the resource if the bool
// input is true. It returns error info and if the state check passed or not.
func (obj *PkgRes) CheckApply(apply bool) (checkok bool, err error) { func (obj *PkgRes) CheckApply(apply bool) (checkok bool, err error) {
log.Printf("%v: CheckApply(%t)", obj.fmtNames(obj.getNames()), apply) log.Printf("%v: CheckApply(%t)", obj.fmtNames(obj.getNames()), apply)
@@ -359,6 +363,7 @@ func (obj *PkgUUID) IFF(uuid ResUUID) bool {
return obj.name == res.name return obj.name == res.name
} }
// PkgResAutoEdges holds the state of the auto edge generator.
type PkgResAutoEdges struct { type PkgResAutoEdges struct {
fileList []string fileList []string
svcUUIDs []ResUUID svcUUIDs []ResUUID
@@ -367,6 +372,7 @@ type PkgResAutoEdges struct {
kind string kind string
} }
// Next returns the next automatic edge.
func (obj *PkgResAutoEdges) Next() []ResUUID { func (obj *PkgResAutoEdges) Next() []ResUUID {
if obj.testIsNext { if obj.testIsNext {
log.Fatal("Expecting a call to Test()") log.Fatal("Expecting a call to Test()")
@@ -394,6 +400,7 @@ func (obj *PkgResAutoEdges) Next() []ResUUID {
return result return result
} }
// Test gets results of the earlier Next() call, & returns if we should continue!
func (obj *PkgResAutoEdges) Test(input []bool) bool { func (obj *PkgResAutoEdges) Test(input []bool) bool {
if !obj.testIsNext { if !obj.testIsNext {
log.Fatal("Expecting a call to Next()") log.Fatal("Expecting a call to Next()")
@@ -474,7 +481,8 @@ func (obj *PkgRes) AutoEdges() AutoEdge {
} }
} }
// include all params to make a unique identification of this object // GetUUIDs includes all params to make a unique identification of this object.
// Most resources only return one, although some resources can return multiple.
func (obj *PkgRes) GetUUIDs() []ResUUID { func (obj *PkgRes) GetUUIDs() []ResUUID {
x := &PkgUUID{ x := &PkgUUID{
BaseUUID: BaseUUID{name: obj.GetName(), kind: obj.Kind()}, BaseUUID: BaseUUID{name: obj.GetName(), kind: obj.Kind()},
@@ -485,6 +493,7 @@ func (obj *PkgRes) GetUUIDs() []ResUUID {
return result return result
} }
// GroupCmp returns whether two resources can be grouped together or not.
// can these two resources be merged ? // can these two resources be merged ?
// (aka does this resource support doing so?) // (aka does this resource support doing so?)
// will resource allow itself to be grouped _into_ this obj? // will resource allow itself to be grouped _into_ this obj?
@@ -506,6 +515,7 @@ func (obj *PkgRes) GroupCmp(r Res) bool {
return true return true
} }
// Compare two resources and return if they are equivalent.
func (obj *PkgRes) Compare(res Res) bool { func (obj *PkgRes) Compare(res Res) bool {
switch res.(type) { switch res.(type) {
case *PkgRes: case *PkgRes:

16
svc.go
View File

@@ -40,6 +40,7 @@ type SvcRes struct {
Startup string `yaml:"startup"` // enabled, disabled, undefined Startup string `yaml:"startup"` // enabled, disabled, undefined
} }
// NewSvcRes is a constructor for this resource. It also calls Init() for you.
func NewSvcRes(name, state, startup string) *SvcRes { func NewSvcRes(name, state, startup string) *SvcRes {
obj := &SvcRes{ obj := &SvcRes{
BaseRes: BaseRes{ BaseRes: BaseRes{
@@ -52,11 +53,13 @@ func NewSvcRes(name, state, startup string) *SvcRes {
return obj return obj
} }
// Init runs some startup code for this resource.
func (obj *SvcRes) Init() { func (obj *SvcRes) Init() {
obj.BaseRes.kind = "Svc" obj.BaseRes.kind = "Svc"
obj.BaseRes.Init() // call base init, b/c we're overriding obj.BaseRes.Init() // call base init, b/c we're overriding
} }
// Validate checks if the resource data structure was populated correctly.
func (obj *SvcRes) Validate() bool { func (obj *SvcRes) Validate() bool {
if obj.State != "running" && obj.State != "stopped" && obj.State != "" { if obj.State != "running" && obj.State != "stopped" && obj.State != "" {
return false return false
@@ -67,7 +70,7 @@ func (obj *SvcRes) Validate() bool {
return true return true
} }
// Service watcher // Watch is the primary listener for this resource and it outputs events.
func (obj *SvcRes) Watch(processChan chan Event) { func (obj *SvcRes) Watch(processChan chan Event) {
if obj.IsWatching() { if obj.IsWatching() {
return return
@@ -228,6 +231,8 @@ func (obj *SvcRes) Watch(processChan chan Event) {
} }
} }
// CheckApply checks the resource state and applies the resource if the bool
// input is true. It returns error info and if the state check passed or not.
func (obj *SvcRes) CheckApply(apply bool) (checkok bool, err error) { func (obj *SvcRes) CheckApply(apply bool) (checkok bool, err error) {
log.Printf("%v[%v]: CheckApply(%t)", obj.Kind(), obj.GetName(), apply) log.Printf("%v[%v]: CheckApply(%t)", obj.Kind(), obj.GetName(), apply)
@@ -341,12 +346,14 @@ func (obj *SvcUUID) IFF(uuid ResUUID) bool {
return obj.name == res.name return obj.name == res.name
} }
// SvcResAutoEdges holds the state of the auto edge generator.
type SvcResAutoEdges struct { type SvcResAutoEdges struct {
data []ResUUID data []ResUUID
pointer int pointer int
found bool found bool
} }
// Next returns the next automatic edge.
func (obj *SvcResAutoEdges) Next() []ResUUID { func (obj *SvcResAutoEdges) Next() []ResUUID {
if obj.found { if obj.found {
log.Fatal("Shouldn't be called anymore!") log.Fatal("Shouldn't be called anymore!")
@@ -359,7 +366,7 @@ func (obj *SvcResAutoEdges) Next() []ResUUID {
return []ResUUID{value} // we return one, even though api supports N return []ResUUID{value} // we return one, even though api supports N
} }
// get results of the earlier Next() call, return if we should continue! // Test gets results of the earlier Next() call, & returns if we should continue!
func (obj *SvcResAutoEdges) Test(input []bool) bool { func (obj *SvcResAutoEdges) Test(input []bool) bool {
// if there aren't any more remaining // if there aren't any more remaining
if len(obj.data) <= obj.pointer { if len(obj.data) <= obj.pointer {
@@ -403,7 +410,8 @@ func (obj *SvcRes) AutoEdges() AutoEdge {
} }
} }
// include all params to make a unique identification of this object // GetUUIDs includes all params to make a unique identification of this object.
// Most resources only return one, although some resources can return multiple.
func (obj *SvcRes) GetUUIDs() []ResUUID { func (obj *SvcRes) GetUUIDs() []ResUUID {
x := &SvcUUID{ x := &SvcUUID{
BaseUUID: BaseUUID{name: obj.GetName(), kind: obj.Kind()}, BaseUUID: BaseUUID{name: obj.GetName(), kind: obj.Kind()},
@@ -412,6 +420,7 @@ func (obj *SvcRes) GetUUIDs() []ResUUID {
return []ResUUID{x} return []ResUUID{x}
} }
// GroupCmp returns whether two resources can be grouped together or not.
func (obj *SvcRes) GroupCmp(r Res) bool { func (obj *SvcRes) GroupCmp(r Res) bool {
_, ok := r.(*SvcRes) _, ok := r.(*SvcRes)
if !ok { if !ok {
@@ -423,6 +432,7 @@ func (obj *SvcRes) GroupCmp(r Res) bool {
return false // not possible atm return false // not possible atm
} }
// Compare two resources and return if they are equivalent.
func (obj *SvcRes) Compare(res Res) bool { func (obj *SvcRes) Compare(res Res) bool {
switch res.(type) { switch res.(type) {
case *SvcRes: case *SvcRes:

View File

@@ -39,7 +39,7 @@ type TimerUUID struct {
name string name string
} }
// NewTimerRes creates a new TimerRes. // NewTimerRes is a constructor for this resource. It also calls Init() for you.
func NewTimerRes(name string, interval int) *TimerRes { func NewTimerRes(name string, interval int) *TimerRes {
obj := &TimerRes{ obj := &TimerRes{
BaseRes: BaseRes{ BaseRes: BaseRes{
@@ -51,6 +51,7 @@ func NewTimerRes(name string, interval int) *TimerRes {
return obj return obj
} }
// Init runs some startup code for this resource.
func (obj *TimerRes) Init() { func (obj *TimerRes) Init() {
obj.BaseRes.kind = "Timer" obj.BaseRes.kind = "Timer"
obj.BaseRes.Init() // call base init, b/c we're overrriding obj.BaseRes.Init() // call base init, b/c we're overrriding
@@ -63,6 +64,7 @@ func (obj *TimerRes) Validate() bool {
return true return true
} }
// Watch is the primary listener for this resource and it outputs events.
func (obj *TimerRes) Watch(processChan chan Event) { func (obj *TimerRes) Watch(processChan chan Event) {
if obj.IsWatching() { if obj.IsWatching() {
return return
@@ -104,6 +106,8 @@ func (obj *TimerRes) Watch(processChan chan Event) {
} }
} }
// GetUUIDs includes all params to make a unique identification of this object.
// Most resources only return one, although some resources can return multiple.
func (obj *TimerRes) GetUUIDs() []ResUUID { func (obj *TimerRes) GetUUIDs() []ResUUID {
x := &TimerUUID{ x := &TimerUUID{
BaseUUID: BaseUUID{ BaseUUID: BaseUUID{
@@ -120,6 +124,7 @@ func (obj *TimerRes) AutoEdges() AutoEdge {
return nil return nil
} }
// Compare two resources and return if they are equivalent.
func (obj *TimerRes) Compare(res Res) bool { func (obj *TimerRes) Compare(res Res) bool {
switch res.(type) { switch res.(type) {
case *TimerRes: case *TimerRes:
@@ -144,7 +149,3 @@ func (obj *TimerRes) CheckApply(apply bool) (bool, error) {
log.Printf("%v[%v]: CheckApply(%t)", obj.Kind(), obj.GetName(), apply) log.Printf("%v[%v]: CheckApply(%t)", obj.Kind(), obj.GetName(), apply)
return true, nil // state is always okay return true, nil // state is always okay
} }
func (obj *TimerRes) CollectPatten(pattern string) {
return
}