diff --git a/docs/resource-guide.md b/docs/resource-guide.md index 1da00e2a..23b184e4 100644 --- a/docs/resource-guide.md +++ b/docs/resource-guide.md @@ -177,10 +177,10 @@ this. In other words, you should expect `Validate` to have run first, but you shouldn't allow `Init` to dangerously `rm -rf /$the_world` if your code only checks `$the_world` in `Validate`. Remember to always program safely! -### Close +### Cleanup ```golang -Close() error +Cleanup() error ``` This is called to cleanup after the resource. It is usually not necessary, but @@ -192,8 +192,8 @@ loop. #### Example ```golang -// Close runs some cleanup code for this resource. -func (obj *FooRes) Close() error { +// Cleanup is run by the engine to clean up after the resource is done. +func (obj *FooRes) Cleanup() error { err := obj.conn.Close() // close some internal connection obj.someMap = nil // free up some large data structure from memory return err @@ -579,15 +579,15 @@ It is only called from within `CheckApply`. World provides a connection to the outside world. This is most often used for communicating with the distributed database. It can be used in `Init`, `CheckApply` and `Watch`. Use with discretion and understanding of the internals -if needed in `Close`. +if needed in `Cleanup`. ### VarDir VarDir is a facility for local storage. It is used to return a path to a directory which may be used for temporary storage. It should be cleaned up on -resource `Close` if the resource would like to delete the contents. The resource -should not assume that the initial directory is empty, and it should be cleaned -on `Init` if that is a requirement. +resource `Cleanup` if the resource would like to delete the contents. The +resource should not assume that the initial directory is empty, and it should be +cleaned on `Init` if that is a requirement. ### Debug @@ -724,7 +724,7 @@ two calls, this is much more difficult. A common example is that a resource might want to open a connection to `dbus` or `http` to do resource state testing and applying. If the methods are combined, there's no need to open and close them twice. A counter argument might be that you could open the connection in -`Init`, and close it in `Close`, however you might not want that open for the +`Init`, and close it in `Cleanup`, however you might not want that open for the full lifetime of the resource if you only change state occasionally. 2. Suppose you came up with a really good reason why you wanted the two methods to be separate. It turns out that the current `CheckApply` can wrap this easily. diff --git a/engine/graph/autogroup/autogroup_test.go b/engine/graph/autogroup/autogroup_test.go index 96d1514f..4b2a15d7 100644 --- a/engine/graph/autogroup/autogroup_test.go +++ b/engine/graph/autogroup/autogroup_test.go @@ -63,7 +63,7 @@ func (obj *NoopResTest) Init(init *engine.Init) error { return nil } -func (obj *NoopResTest) Close() error { +func (obj *NoopResTest) Cleanup() error { return nil } diff --git a/engine/graph/engine.go b/engine/graph/engine.go index 6f288de9..3bea69d1 100644 --- a/engine/graph/engine.go +++ b/engine/graph/engine.go @@ -257,7 +257,7 @@ func (obj *Engine) Commit() error { // close the state and resource // FIXME: will this mess up the sync and block the engine? - if err := obj.state[vertex].Close(); err != nil { + if err := obj.state[vertex].Cleanup(); err != nil { return errwrap.Wrapf(err, "the Res did not Close") } diff --git a/engine/graph/reverse.go b/engine/graph/reverse.go index 911ced6e..6f98b060 100644 --- a/engine/graph/reverse.go +++ b/engine/graph/reverse.go @@ -231,9 +231,9 @@ func (obj *State) ReversalInit() error { return obj.ReversalWrite(str, res.ReversibleMeta().Overwrite) // Store! } -// ReversalClose performs the reversal shutdown steps if necessary for this +// ReversalCleanup performs the reversal shutdown steps if necessary for this // resource. -func (obj *State) ReversalClose() error { +func (obj *State) ReversalCleanup() error { res, ok := obj.Vertex.(engine.ReversibleRes) if !ok { return nil // nothing to do diff --git a/engine/graph/state.go b/engine/graph/state.go index b4f0f1cd..b3eef5a6 100644 --- a/engine/graph/state.go +++ b/engine/graph/state.go @@ -263,9 +263,9 @@ func (obj *State) Init() error { return nil } -// Close shuts down and performs any cleanup. This is most akin to a "post" or +// Cleanup shuts down and performs any cleanup. This is most akin to a "post" or // cleanup command as the initiator for closing a vertex happens in graph sync. -func (obj *State) Close() error { +func (obj *State) Cleanup() error { res, isRes := obj.Vertex.(engine.Res) if !isRes { return fmt.Errorf("vertex is not a Res") @@ -288,13 +288,13 @@ func (obj *State) Close() error { var reverr error // clear the reverse request from the disk... - if err := obj.ReversalClose(); err != nil { + if err := obj.ReversalCleanup(); err != nil { // TODO: test this code path... // TODO: should this be an error or a warning? reverr = err } - reterr := res.Close() + reterr := res.Cleanup() if obj.Debug { obj.Logf("Close(%s): Return(%+v)", res, reterr) } diff --git a/engine/resources.go b/engine/resources.go index 5026103f..0d56b7c5 100644 --- a/engine/resources.go +++ b/engine/resources.go @@ -190,8 +190,8 @@ type Res interface { // and data from the engine. Init(*Init) error - // Close is run by the engine to clean up after the resource is done. - Close() error + // Cleanup is run by the engine to clean up after the resource is done. + Cleanup() error // Watch is run by the engine to monitor for state changes. If it // detects any, it notifies the engine which will usually run CheckApply diff --git a/engine/resources/augeas.go b/engine/resources/augeas.go index 10156378..e434daec 100644 --- a/engine/resources/augeas.go +++ b/engine/resources/augeas.go @@ -118,8 +118,8 @@ func (obj *AugeasRes) Init(init *engine.Init) error { return nil } -// Close is run by the engine to clean up after the resource is done. -func (obj *AugeasRes) Close() error { +// Cleanup is run by the engine to clean up after the resource is done. +func (obj *AugeasRes) Cleanup() error { return nil } diff --git a/engine/resources/aws_ec2.go b/engine/resources/aws_ec2.go index 1bccde86..523da5ff 100644 --- a/engine/resources/aws_ec2.go +++ b/engine/resources/aws_ec2.go @@ -388,10 +388,11 @@ func (obj *AwsEc2Res) Init(init *engine.Init) error { return nil } -// Close cleans up when we're done. This is needed to delete some of the AWS +// Cleanup cleans up when we're done. This is needed to delete some of the AWS // objects created for the SNS endpoint. -func (obj *AwsEc2Res) Close() error { +func (obj *AwsEc2Res) Cleanup() error { var errList error + // XXX: do these in a defer of Watch instead. // clean up sns objects created by Init/snsWatch if obj.snsClient != nil { // delete the topic and associated subscriptions diff --git a/engine/resources/config_etcd.go b/engine/resources/config_etcd.go index e00bcbcb..2b6d89a1 100644 --- a/engine/resources/config_etcd.go +++ b/engine/resources/config_etcd.go @@ -86,8 +86,8 @@ func (obj *ConfigEtcdRes) Init(init *engine.Init) error { return nil } -// Close is run by the engine to clean up after the resource is done. -func (obj *ConfigEtcdRes) Close() error { +// Cleanup is run by the engine to clean up after the resource is done. +func (obj *ConfigEtcdRes) Cleanup() error { return nil } diff --git a/engine/resources/consul_kv.go b/engine/resources/consul_kv.go index ed6011db..b3ddb1bc 100644 --- a/engine/resources/consul_kv.go +++ b/engine/resources/consul_kv.go @@ -108,8 +108,8 @@ func (obj *ConsulKVRes) Init(init *engine.Init) error { return errwrap.Wrapf(err, "could not create Consul client") } -// Close is run by the engine to clean up after the resource is done. -func (obj *ConsulKVRes) Close() error { +// Cleanup is run by the engine to clean up after the resource is done. +func (obj *ConsulKVRes) Cleanup() error { if obj.config != nil && obj.config.Transport != nil { obj.config.Transport.CloseIdleConnections() } diff --git a/engine/resources/cron.go b/engine/resources/cron.go index 6bc49798..b925b338 100644 --- a/engine/resources/cron.go +++ b/engine/resources/cron.go @@ -212,10 +212,10 @@ func (obj *CronRes) Init(init *engine.Init) error { return obj.file.Init(init) } -// Close is run by the engine to clean up after the resource is done. -func (obj *CronRes) Close() error { +// Cleanup is run by the engine to clean up after the resource is done. +func (obj *CronRes) Cleanup() error { if obj.file != nil { - return obj.file.Close() + return obj.file.Cleanup() } return nil } diff --git a/engine/resources/dhcp.go b/engine/resources/dhcp.go index e0971bcd..2cf39fb8 100644 --- a/engine/resources/dhcp.go +++ b/engine/resources/dhcp.go @@ -377,8 +377,8 @@ func (obj *DHCPServerRes) Init(init *engine.Init) error { return nil } -// Close is run by the engine to clean up after the resource is done. -func (obj *DHCPServerRes) Close() error { +// Cleanup is run by the engine to clean up after the resource is done. +func (obj *DHCPServerRes) Cleanup() error { // NOTE: if this ever panics, it might mean the engine is running Close // before Watch finishes exiting, which is an engine bug in that code... //obj.mutex.RUnlock() @@ -1045,8 +1045,8 @@ func (obj *DHCPHostRes) Init(init *engine.Init) error { return nil } -// Close is run by the engine to clean up after the resource is done. -func (obj *DHCPHostRes) Close() error { +// Cleanup is run by the engine to clean up after the resource is done. +func (obj *DHCPHostRes) Cleanup() error { return nil } diff --git a/engine/resources/docker_container.go b/engine/resources/docker_container.go index 3d20ccd1..41cc8d1f 100644 --- a/engine/resources/docker_container.go +++ b/engine/resources/docker_container.go @@ -164,8 +164,8 @@ func (obj *DockerContainerRes) Init(init *engine.Init) error { return nil } -// Close is run by the engine to clean up after the resource is done. -func (obj *DockerContainerRes) Close() error { +// Cleanup is run by the engine to clean up after the resource is done. +func (obj *DockerContainerRes) Cleanup() error { return obj.client.Close() // close the docker client } diff --git a/engine/resources/docker_image.go b/engine/resources/docker_image.go index 3e001163..6cfb82aa 100644 --- a/engine/resources/docker_image.go +++ b/engine/resources/docker_image.go @@ -125,8 +125,8 @@ func (obj *DockerImageRes) Init(init *engine.Init) error { return nil } -// Close is run by the engine to clean up after the resource is done. -func (obj *DockerImageRes) Close() error { +// Cleanup is run by the engine to clean up after the resource is done. +func (obj *DockerImageRes) Cleanup() error { return obj.client.Close() // close the docker client } diff --git a/engine/resources/exec.go b/engine/resources/exec.go index 152ff3ae..935d39ba 100644 --- a/engine/resources/exec.go +++ b/engine/resources/exec.go @@ -161,8 +161,8 @@ func (obj *ExecRes) Init(init *engine.Init) error { return nil } -// Close is run by the engine to clean up after the resource is done. -func (obj *ExecRes) Close() error { +// Cleanup is run by the engine to clean up after the resource is done. +func (obj *ExecRes) Cleanup() error { return nil } diff --git a/engine/resources/exec_test.go b/engine/resources/exec_test.go index f1ddbe7c..6e41df74 100644 --- a/engine/resources/exec_test.go +++ b/engine/resources/exec_test.go @@ -62,8 +62,8 @@ func TestExecSendRecv1(t *testing.T) { t.Errorf("validate failed with: %v", err) } defer func() { - if err := r1.Close(); err != nil { - t.Errorf("close failed with: %v", err) + if err := r1.Cleanup(); err != nil { + t.Errorf("cleanup failed with: %v", err) } }() init, execSends := fakeExecInit(t) @@ -107,8 +107,8 @@ func TestExecSendRecv2(t *testing.T) { t.Errorf("validate failed with: %v", err) } defer func() { - if err := r1.Close(); err != nil { - t.Errorf("close failed with: %v", err) + if err := r1.Cleanup(); err != nil { + t.Errorf("cleanup failed with: %v", err) } }() init, execSends := fakeExecInit(t) @@ -152,8 +152,8 @@ func TestExecSendRecv3(t *testing.T) { t.Errorf("validate failed with: %v", err) } defer func() { - if err := r1.Close(); err != nil { - t.Errorf("close failed with: %v", err) + if err := r1.Cleanup(); err != nil { + t.Errorf("cleanup failed with: %v", err) } }() init, execSends := fakeExecInit(t) diff --git a/engine/resources/file.go b/engine/resources/file.go index ef434a99..4ac10bb0 100644 --- a/engine/resources/file.go +++ b/engine/resources/file.go @@ -350,8 +350,8 @@ func (obj *FileRes) Init(init *engine.Init) error { return nil } -// Close is run by the engine to clean up after the resource is done. -func (obj *FileRes) Close() error { +// Cleanup is run by the engine to clean up after the resource is done. +func (obj *FileRes) Cleanup() error { return nil } diff --git a/engine/resources/group.go b/engine/resources/group.go index 0c5fae40..4817180d 100644 --- a/engine/resources/group.go +++ b/engine/resources/group.go @@ -71,8 +71,8 @@ func (obj *GroupRes) Init(init *engine.Init) error { return nil } -// Close is run by the engine to clean up after the resource is done. -func (obj *GroupRes) Close() error { +// Cleanup is run by the engine to clean up after the resource is done. +func (obj *GroupRes) Cleanup() error { return nil } diff --git a/engine/resources/hetzner_vm.go b/engine/resources/hetzner_vm.go index f121da45..53527267 100644 --- a/engine/resources/hetzner_vm.go +++ b/engine/resources/hetzner_vm.go @@ -361,8 +361,9 @@ func (obj *HetznerVMRes) Init(init *engine.Init) error { return nil } -// Close deletes the authentication info before closing the resource. -func (obj *HetznerVMRes) Close() error { +// Cleanup is run by the engine to clean up after the resource is done. It +// deletes the authentication info before closing the resource. +func (obj *HetznerVMRes) Cleanup() error { obj.APIToken = "" obj.client = nil return nil diff --git a/engine/resources/hostname.go b/engine/resources/hostname.go index 05d72750..d7f14f53 100644 --- a/engine/resources/hostname.go +++ b/engine/resources/hostname.go @@ -101,8 +101,8 @@ func (obj *HostnameRes) Init(init *engine.Init) error { return nil } -// Close is run by the engine to clean up after the resource is done. -func (obj *HostnameRes) Close() error { +// Cleanup is run by the engine to clean up after the resource is done. +func (obj *HostnameRes) Cleanup() error { return nil } diff --git a/engine/resources/http.go b/engine/resources/http.go index 07f845cc..f625239e 100644 --- a/engine/resources/http.go +++ b/engine/resources/http.go @@ -224,8 +224,8 @@ func (obj *HTTPServerRes) Init(init *engine.Init) error { return nil } -// Close is run by the engine to clean up after the resource is done. -func (obj *HTTPServerRes) Close() error { +// Cleanup is run by the engine to clean up after the resource is done. +func (obj *HTTPServerRes) Cleanup() error { return nil } @@ -713,8 +713,8 @@ func (obj *HTTPFileRes) Init(init *engine.Init) error { return nil } -// Close is run by the engine to clean up after the resource is done. -func (obj *HTTPFileRes) Close() error { +// Cleanup is run by the engine to clean up after the resource is done. +func (obj *HTTPFileRes) Cleanup() error { return nil } diff --git a/engine/resources/kv.go b/engine/resources/kv.go index 51696909..cb9900fb 100644 --- a/engine/resources/kv.go +++ b/engine/resources/kv.go @@ -123,8 +123,8 @@ func (obj *KVRes) Init(init *engine.Init) error { return nil } -// Close is run by the engine to clean up after the resource is done. -func (obj *KVRes) Close() error { +// Cleanup is run by the engine to clean up after the resource is done. +func (obj *KVRes) Cleanup() error { return nil } diff --git a/engine/resources/mount.go b/engine/resources/mount.go index 2625868a..68c652b2 100644 --- a/engine/resources/mount.go +++ b/engine/resources/mount.go @@ -185,8 +185,8 @@ func (obj *MountRes) Init(init *engine.Init) error { return nil } -// Close is run by the engine to clean up after the resource is done. -func (obj *MountRes) Close() error { +// Cleanup is run by the engine to clean up after the resource is done. +func (obj *MountRes) Cleanup() error { return nil } diff --git a/engine/resources/msg.go b/engine/resources/msg.go index 7488723b..192b87dd 100644 --- a/engine/resources/msg.go +++ b/engine/resources/msg.go @@ -88,8 +88,8 @@ func (obj *MsgRes) Init(init *engine.Init) error { return nil } -// Close is run by the engine to clean up after the resource is done. -func (obj *MsgRes) Close() error { +// Cleanup is run by the engine to clean up after the resource is done. +func (obj *MsgRes) Cleanup() error { return nil } diff --git a/engine/resources/net.go b/engine/resources/net.go index fd4dfecb..943d3d69 100644 --- a/engine/resources/net.go +++ b/engine/resources/net.go @@ -186,8 +186,8 @@ func (obj *NetRes) Init(init *engine.Init) error { return nil } -// Close cleans up when we're done. -func (obj *NetRes) Close() error { +// Cleanup is run by the engine to clean up after the resource is done. +func (obj *NetRes) Cleanup() error { if obj.socketFile == "/" { return fmt.Errorf("socket file should not be the root path") } diff --git a/engine/resources/noop.go b/engine/resources/noop.go index 3531b33d..b6b186a9 100644 --- a/engine/resources/noop.go +++ b/engine/resources/noop.go @@ -57,8 +57,8 @@ func (obj *NoopRes) Init(init *engine.Init) error { return nil } -// Close is run by the engine to clean up after the resource is done. -func (obj *NoopRes) Close() error { +// Cleanup is run by the engine to clean up after the resource is done. +func (obj *NoopRes) Cleanup() error { return nil } diff --git a/engine/resources/nspawn.go b/engine/resources/nspawn.go index 80e54846..a64fbe2b 100644 --- a/engine/resources/nspawn.go +++ b/engine/resources/nspawn.go @@ -132,10 +132,10 @@ func (obj *NspawnRes) Init(init *engine.Init) error { return obj.svc.Init(init) } -// Close is run by the engine to clean up after the resource is done. -func (obj *NspawnRes) Close() error { +// Cleanup is run by the engine to clean up after the resource is done. +func (obj *NspawnRes) Cleanup() error { if obj.svc != nil { - return obj.svc.Close() + return obj.svc.Cleanup() } return nil } diff --git a/engine/resources/password.go b/engine/resources/password.go index 94891e65..d850c650 100644 --- a/engine/resources/password.go +++ b/engine/resources/password.go @@ -89,8 +89,8 @@ func (obj *PasswordRes) Init(init *engine.Init) error { return nil } -// Close is run by the engine to clean up after the resource is done. -func (obj *PasswordRes) Close() error { +// Cleanup is run by the engine to clean up after the resource is done. +func (obj *PasswordRes) Cleanup() error { return nil } diff --git a/engine/resources/pippet.go b/engine/resources/pippet.go index 205b1870..88f297b3 100644 --- a/engine/resources/pippet.go +++ b/engine/resources/pippet.go @@ -87,8 +87,8 @@ func (obj *PippetRes) Init(init *engine.Init) error { return obj.runner.Register() } -// Close is run by the engine to clean up after the resource is done. -func (obj *PippetRes) Close() error { +// Cleanup is run by the engine to clean up after the resource is done. +func (obj *PippetRes) Cleanup() error { return obj.runner.Unregister() } diff --git a/engine/resources/pkg.go b/engine/resources/pkg.go index b43e81ad..d52340b2 100644 --- a/engine/resources/pkg.go +++ b/engine/resources/pkg.go @@ -96,8 +96,8 @@ func (obj *PkgRes) Init(init *engine.Init) error { return nil } -// Close is run by the engine to clean up after the resource is done. -func (obj *PkgRes) Close() error { +// Cleanup is run by the engine to clean up after the resource is done. +func (obj *PkgRes) Cleanup() error { return nil } diff --git a/engine/resources/print.go b/engine/resources/print.go index fb9260b6..92f578e9 100644 --- a/engine/resources/print.go +++ b/engine/resources/print.go @@ -64,8 +64,8 @@ func (obj *PrintRes) Init(init *engine.Init) error { return nil } -// Close is run by the engine to clean up after the resource is done. -func (obj *PrintRes) Close() error { +// Cleanup is run by the engine to clean up after the resource is done. +func (obj *PrintRes) Cleanup() error { return nil } diff --git a/engine/resources/resources_test.go b/engine/resources/resources_test.go index 5c112c36..70b5062a 100644 --- a/engine/resources/resources_test.go +++ b/engine/resources/resources_test.go @@ -543,9 +543,9 @@ func TestResources1(t *testing.T) { } }() closeFn := func() { - // run close (we don't ever expect an error on close!) - t.Logf("test #%d: running Close", index) - if err := res.Close(); err != nil { + // run cleanup (we don't ever expect an error on cleanup!) + t.Logf("test #%d: running Cleanup", index) + if err := res.Cleanup(); err != nil { t.Errorf("test #%d: FAIL", index) t.Errorf("test #%d: could not close Res: %+v", index, err) //return @@ -793,11 +793,11 @@ func TestResources2(t *testing.T) { } return resCheckApplyError(res, expCheckOK, errOK) } - // resClose runs Close on the res. - resClose := func(res engine.Res) func() error { - // run Close + // resCleanup runs CLeanup on the res. + resCleanup := func(res engine.Res) func() error { + // run CLeanup return func() error { - return res.Close() + return res.Cleanup() } } // resReversal runs Reverse on the resource and stores the result in the @@ -928,7 +928,7 @@ func TestResources2(t *testing.T) { resCheckApply(r1, false), // changed fileExpect(p, content), resCheckApply(r1, true), // it's already good - resClose(r1), + resCleanup(r1), fileExpect(p, content), // ensure it exists } @@ -960,7 +960,7 @@ func TestResources2(t *testing.T) { resCheckApply(r1, false), // changed fileExpect(p, content), resCheckApply(r1, true), // it's already good - resClose(r1), + resCleanup(r1), fileExpect(p, content), // ensure it exists } @@ -992,7 +992,7 @@ func TestResources2(t *testing.T) { resInit(r1), resCheckApplyError(r1, false, ErrIsNotExistOK), // should error resCheckApplyError(r1, false, ErrIsNotExistOK), // double check - resClose(r1), + resCleanup(r1), fileAbsent(p), // ensure it's absent } @@ -1021,7 +1021,7 @@ func TestResources2(t *testing.T) { resInit(r1), resCheckApply(r1, true), resCheckApply(r1, true), - resClose(r1), + resCleanup(r1), fileAbsent(p), // ensure it's absent } @@ -1050,7 +1050,7 @@ func TestResources2(t *testing.T) { resInit(r1), resCheckApply(r1, false), resCheckApply(r1, true), - resClose(r1), + resCleanup(r1), fileAbsent(p), // ensure it's absent } @@ -1094,7 +1094,7 @@ func TestResources2(t *testing.T) { resCheckApply(r1, false), // changed fileExpect(p, content), resCheckApply(r1, true), // it's already good - resClose(r1), + resCleanup(r1), //resValidate(r2), // no!!! func() error { // wrap it b/c it is currently nil @@ -1110,7 +1110,7 @@ func TestResources2(t *testing.T) { return resCheckApply(r2, true)() }, func() error { - return resClose(r2)() + return resCleanup(r2)() }, fileAbsent(p), // ensure it's absent } @@ -1156,7 +1156,7 @@ func TestResources2(t *testing.T) { resCheckApply(r1, false), // changed fileExpect(p, content), resCheckApply(r1, true), // it's already good - resClose(r1), + resCleanup(r1), //resValidate(r2), func() error { // wrap it b/c it is currently nil @@ -1172,7 +1172,7 @@ func TestResources2(t *testing.T) { return resCheckApply(r2, true)() }, func() error { - return resClose(r2)() + return resCleanup(r2)() }, fileExpect(p, original), // we restored the contents! fileRemove(p), // cleanup @@ -1220,7 +1220,7 @@ func TestResources2(t *testing.T) { resCheckApplyError(r1, false, ErrIsNotExistOK), // changed //fileExpect(p, content), //resCheckApply(r1, true), // it's already good - resClose(r1), + resCleanup(r1), //func() error { // // wrap it b/c it is currently nil // return r2.Validate() @@ -1232,7 +1232,7 @@ func TestResources2(t *testing.T) { // return resCheckApply(r2, true)() //}, //func() error { - // return resClose(r2)() + // return resCleanup(r2)() //}, //fileExpect(p, content), // we never changed it back... //fileRemove(p), // cleanup @@ -1275,7 +1275,7 @@ func TestResources2(t *testing.T) { resCheckApply(r1, false), // changed fileAbsent(p), // ensure it got removed resCheckApply(r1, true), // it's already good - resClose(r1), + resCleanup(r1), //resValidate(r2), // no!!! func() error { // wrap it b/c it is currently nil @@ -1291,7 +1291,7 @@ func TestResources2(t *testing.T) { return resCheckApply(r2, true)() }, func() error { - return resClose(r2)() + return resCleanup(r2)() }, fileExpect(p, original), // ensure it's back to original } @@ -1357,7 +1357,7 @@ func TestResources2(t *testing.T) { resCheckApply(r1, false), // changed fileExpect(p, content), resCheckApply(r1, true), // it's already good - resClose(r1), + resCleanup(r1), fileExpect(p, content), // ensure it exists } @@ -1394,7 +1394,7 @@ func TestResources2(t *testing.T) { resCheckApply(r1, true), // it's already good fileExpect(p, content), // should already be like this fileExpect(p2, content), // should not change either - resClose(r1), + resCleanup(r1), } testCases = append(testCases, test{ @@ -1423,7 +1423,7 @@ func TestResources2(t *testing.T) { fileExists(p, true), // ensure it's a dir resCheckApply(r1, true), // it's already good fileExists(p, true), // ensure it's a dir - resClose(r1), + resCleanup(r1), } testCases = append(testCases, test{ @@ -1494,7 +1494,7 @@ func TestResources2(t *testing.T) { fileExists(d2f2, false), fileExists(d2f3, false), resCheckApply(r1, true), // it's already good - resClose(r1), + resCleanup(r1), } testCases = append(testCases, test{ @@ -1560,7 +1560,7 @@ func TestResources2(t *testing.T) { fileAbsent(d2f2), fileAbsent(d2f3), resCheckApply(r1, true), // it's already good - resClose(r1), + resCleanup(r1), } testCases = append(testCases, test{ @@ -1646,17 +1646,17 @@ func TestResources2(t *testing.T) { resValidate(r2), resInit(r2), //resCheckApply(r2, false), // not really needed in test - resClose(r2), + resCleanup(r2), resValidate(r3), resInit(r3), //resCheckApply(r3, false), // not really needed in test - resClose(r3), + resCleanup(r3), resValidate(r4), resInit(r4), //resCheckApply(r4, false), // not really needed in test - resClose(r4), + resCleanup(r4), resValidate(r1), resInit(r1, addGraph(graph), addLogf(nil)), // show the full graph @@ -1675,7 +1675,7 @@ func TestResources2(t *testing.T) { fileExists(p3, true), // ensure it's a dir fileExists(p4, false), resCheckApply(r1, true), // it's already good - resClose(r1), + resCleanup(r1), } testCases = append(testCases, test{ diff --git a/engine/resources/svc.go b/engine/resources/svc.go index d925c1c1..cf4e7bda 100644 --- a/engine/resources/svc.go +++ b/engine/resources/svc.go @@ -76,8 +76,8 @@ func (obj *SvcRes) Init(init *engine.Init) error { return nil } -// Close is run by the engine to clean up after the resource is done. -func (obj *SvcRes) Close() error { +// Cleanup is run by the engine to clean up after the resource is done. +func (obj *SvcRes) Cleanup() error { return nil } diff --git a/engine/resources/test.go b/engine/resources/test.go index 493f4ef9..7a8ee121 100644 --- a/engine/resources/test.go +++ b/engine/resources/test.go @@ -119,8 +119,8 @@ func (obj *TestRes) Init(init *engine.Init) error { return nil } -// Close is run by the engine to clean up after the resource is done. -func (obj *TestRes) Close() error { +// Cleanup is run by the engine to clean up after the resource is done. +func (obj *TestRes) Cleanup() error { return nil } diff --git a/engine/resources/tftp.go b/engine/resources/tftp.go index 3a4721bd..289d95b4 100644 --- a/engine/resources/tftp.go +++ b/engine/resources/tftp.go @@ -134,8 +134,8 @@ func (obj *TFTPServerRes) Init(init *engine.Init) error { return nil } -// Close is run by the engine to clean up after the resource is done. -func (obj *TFTPServerRes) Close() error { +// Cleanup is run by the engine to clean up after the resource is done. +func (obj *TFTPServerRes) Cleanup() error { return nil } @@ -540,8 +540,8 @@ func (obj *TFTPFileRes) Init(init *engine.Init) error { return nil } -// Close is run by the engine to clean up after the resource is done. -func (obj *TFTPFileRes) Close() error { +// Cleanup is run by the engine to clean up after the resource is done. +func (obj *TFTPFileRes) Cleanup() error { return nil } diff --git a/engine/resources/timer.go b/engine/resources/timer.go index 69435806..537f51cd 100644 --- a/engine/resources/timer.go +++ b/engine/resources/timer.go @@ -60,8 +60,8 @@ func (obj *TimerRes) Init(init *engine.Init) error { return nil } -// Close is run by the engine to clean up after the resource is done. -func (obj *TimerRes) Close() error { +// Cleanup is run by the engine to clean up after the resource is done. +func (obj *TimerRes) Cleanup() error { return nil } diff --git a/engine/resources/user.go b/engine/resources/user.go index d99052cd..ce0cd5f4 100644 --- a/engine/resources/user.go +++ b/engine/resources/user.go @@ -105,8 +105,8 @@ func (obj *UserRes) Init(init *engine.Init) error { return nil } -// Close is run by the engine to clean up after the resource is done. -func (obj *UserRes) Close() error { +// Cleanup is run by the engine to clean up after the resource is done. +func (obj *UserRes) Cleanup() error { return nil } diff --git a/engine/resources/virt.go b/engine/resources/virt.go index 9f3a8274..1c3bdc7e 100644 --- a/engine/resources/virt.go +++ b/engine/resources/virt.go @@ -239,8 +239,8 @@ func (obj *VirtRes) Init(init *engine.Init) error { return nil } -// Close runs some cleanup code for this resource. -func (obj *VirtRes) Close() error { +// Cleanup is run by the engine to clean up after the resource is done. +func (obj *VirtRes) Cleanup() error { // By the time that this Close method is called, the engine promises // that the Watch loop has previously shutdown! (Assuming no bugs!) // TODO: As a result, this is an extra check which shouldn't be needed, diff --git a/engine/util/util_test.go b/engine/util/util_test.go index e39553e5..2b44bfa8 100644 --- a/engine/util/util_test.go +++ b/engine/util/util_test.go @@ -178,7 +178,7 @@ type testEngineRes struct { func (t *testEngineRes) CheckApply(bool) (bool, error) { return false, nil } -func (t *testEngineRes) Close() error { return nil } +func (t *testEngineRes) Cleanup() error { return nil } func (t *testEngineRes) Cmp(engine.Res) error { return nil }