/
deprovision.go
41 lines (32 loc) · 1.13 KB
/
deprovision.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
39
40
41
package ansibleapp
import (
"fmt"
"github.com/op/go-logging"
)
func Deprovision(instance *ServiceInstance, log *logging.Logger) error {
specJSON, _ := DumpJSON(instance)
log.Notice("============================================================")
log.Notice(" DEPROVISIONING ")
log.Notice("============================================================")
log.Notice(fmt.Sprintf("ServiceInstance.Id: %s", instance.Id))
log.Notice(fmt.Sprintf("ServiceInstance.Spec: %v", specJSON))
log.Notice(fmt.Sprintf("ServiceInstance.Parameters: %v", instance.Parameters))
log.Notice("============================================================")
var client *Client
var err error
if client, err = NewClient(log); err != nil {
return err
}
if err = client.PullImage(instance.Spec.Name); err != nil {
return err
}
// Might need to change up this interface to feed in instance ids
output, err := client.RunImage(
"deprovision", HardcodedClusterConfig, instance.Spec, instance.Parameters)
if err != nil {
log.Error("Problem running image")
return err
}
log.Info(string(output))
return nil
}