-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.go
67 lines (57 loc) · 1.51 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
58
59
60
61
62
63
64
65
66
67
package main
import (
"fmt"
"net/http"
cfenv "github.com/cloudfoundry-community/go-cfenv"
"github.com/go-martini/martini"
"github.com/martini-contrib/gorelic"
"github.com/pivotalservices/pezauth/integrations"
pez "github.com/pivotalservices/pezauth/service"
"github.com/xchapter7x/cloudcontroller-client"
)
func main() {
appEnv, _ := cfenv.Current()
m := martini.Classic()
newRelic := new(integrations.MyNewRelic).New(appEnv)
gorelic.InitNewrelicAgent(newRelic.Key, newRelic.App, false)
m.Use(gorelic.Handler)
oauth2Client := new(integrations.MyOAuth2).New(appEnv)
pez.ClientID = oauth2Client.ID
pez.ClientSecret = oauth2Client.Secret
rds := new(integrations.MyRedis).New(appEnv)
defer rds.Conn.Close()
pez.InitSession(m, &redisCreds{
pass: rds.Pass,
uri: rds.URI,
})
h := new(integrations.MyHeritage).New(appEnv)
heritageClient := &heritage{
Client: ccclient.New(h.LoginTarget, h.LoginUser, h.LoginPass, new(http.Client)),
ccTarget: h.CCTarget,
}
mngo := new(integrations.MyMongo).New(appEnv)
defer mngo.Session.Close()
if _, err := heritageClient.Login(); err == nil {
pez.InitRoutes(m, rds.Conn, mngo, heritageClient)
m.Run()
} else {
panic(fmt.Sprintf("heritage client login error: %s", err.Error()))
}
}
type redisCreds struct {
pass string
uri string
}
func (s *redisCreds) Pass() string {
return s.pass
}
func (s *redisCreds) Uri() string {
return s.uri
}
type heritage struct {
*ccclient.Client
ccTarget string
}
func (s *heritage) CCTarget() string {
return s.ccTarget
}