-
Notifications
You must be signed in to change notification settings - Fork 4
/
main.go
57 lines (45 loc) · 1.38 KB
/
main.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package main
import (
"fmt"
"os"
"github.com/SUSE/cf-usb-sidecar/csm-extensions/services/dev-rabbitmq"
"github.com/SUSE/cf-usb-sidecar/csm-extensions/services/dev-rabbitmq/config"
"github.com/SUSE/cf-usb-sidecar/csm-extensions/services/dev-rabbitmq/provisioner"
"github.com/SUSE/go-csm-lib/csm"
"github.com/pivotal-golang/lager"
"gopkg.in/caarlos0/env.v2"
)
func main() {
var logger = lager.NewLogger("rabbitmq-extension")
logger.RegisterSink(lager.NewWriterSink(os.Stdout, lager.DEBUG))
conf := config.RabbitmqConfig{}
err := env.Parse(&conf)
if err != nil {
logger.Fatal("main", err)
}
if conf.DockerEndpoint == "" {
if conf.DockerHost == "" {
logger.Fatal("DOCKER_ENDPOINT or DOCKER_HOST environment variables not set", nil)
}
conf.DockerEndpoint = fmt.Sprintf("http://%s:%s", conf.DockerHost, conf.DockerPort)
}
request, err := csm.GetCSMRequest(os.Args)
if err != nil {
logger.Fatal("main", err)
}
csmConnection := csm.NewCSMFileConnection(request.OutputPath, logger)
prov := provisioner.NewRabbitHoleProvisioner(logger, conf)
extension := rabbitmq.NewRabbitmqExtension(prov, conf, logger)
response, err := extension.DeleteWorkspace(request.WorkspaceID)
if err != nil {
err := csmConnection.WriteError(err)
if err != nil {
logger.Fatal("main", err)
}
os.Exit(0)
}
err = csmConnection.Write(*response)
if err != nil {
logger.Fatal("main", err)
}
}