-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
51 lines (40 loc) · 1.29 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
package main
import (
"net/http"
"os"
"code.cloudfoundry.org/lager"
"github.com/pivotal-cf/brokerapi"
"github.com/starkandwayne/scs-broker/broker"
"github.com/starkandwayne/scs-broker/config"
"github.com/starkandwayne/scs-broker/httpartifacttransport"
)
var brokerLogger lager.Logger
var httpTransport httpartifacttransport.HttpArtifactTransport
func main() {
brokerLogger = lager.NewLogger("scs-broker")
brokerLogger.RegisterSink(lager.NewWriterSink(os.Stdout, lager.DEBUG))
brokerLogger.RegisterSink(lager.NewWriterSink(os.Stderr, lager.ERROR))
brokerConf, err := config.ParseConfig()
if err != nil {
brokerLogger.Fatal("Reading config from env", err, lager.Data{
"broker-config-environment-variable": config.ConfigEnvVarName,
})
}
brokerLogger.Info("starting")
serviceBroker := &broker.SCSBroker{
Config: brokerConf,
Logger: brokerLogger,
}
brokerCredentials := brokerapi.BrokerCredentials{
Username: brokerConf.Auth.Username,
Password: brokerConf.Auth.Password,
}
brokerAPI := brokerapi.New(serviceBroker, brokerLogger, brokerCredentials)
http.Handle("/", brokerAPI)
port := os.Getenv("PORT")
if port == "" {
port = "8080"
}
brokerLogger.Info("listening", lager.Data{"port": port})
brokerLogger.Fatal("http-listen", http.ListenAndServe("0.0.0.0:"+port, nil))
}