forked from cloudfoundry/bosh-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
uninstaller.go
38 lines (29 loc) · 818 Bytes
/
uninstaller.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package installation
import (
boshlog "github.com/cloudfoundry/bosh-utils/logger"
boshsys "github.com/cloudfoundry/bosh-utils/system"
)
type Uninstaller interface {
Uninstall(Target) error
}
type uninstaller struct {
fs boshsys.FileSystem
logTag string
logger boshlog.Logger
}
func NewUninstaller(fs boshsys.FileSystem, logger boshlog.Logger) Uninstaller {
return &uninstaller{
fs: fs,
logTag: "uninstaller",
logger: logger,
}
}
func (u *uninstaller) Uninstall(installationTarget Target) error {
err := u.fs.RemoveAll(installationTarget.Path())
if err != nil {
u.logger.Error(u.logTag, "Failed to uninstall CPI from '%s': %s", installationTarget.Path(), err.Error())
return err
}
u.logger.Info(u.logTag, "Successfully uninstalled CPI from '%s'", installationTarget.Path())
return nil
}