From 8eb2c3725199b17ae713dd0756a0e491e4829c12 Mon Sep 17 00:00:00 2001 From: Matthew Holt Date: Mon, 30 Sep 2019 09:16:01 -0600 Subject: Clean up provisioned modules on error; refactor Run(); add Validate() Modules that return an error during provisioning should still be cleaned up so that they don't leak any resources they may have allocated before the error occurred. Cleanup should be able to run even if Provision does not complete fully. --- modules.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'modules.go') diff --git a/modules.go b/modules.go index 3ca5384..2d01eb3 100644 --- a/modules.go +++ b/modules.go @@ -253,9 +253,10 @@ type Validator interface { // CleanerUpper is implemented by modules which may have side-effects // such as opened files, spawned goroutines, or allocated some sort -// of non-local state when they were provisioned. This method should +// of non-stack state when they were provisioned. This method should // deallocate/cleanup those resources to prevent memory leaks. Cleanup -// should be fast and efficient. +// should be fast and efficient. Cleanup should work even if Provision +// returns an error, to allow cleaning up from partial provisionings. type CleanerUpper interface { Cleanup() error } -- cgit v1.2.3