Ejemplo n.º 1
0
//FetchEventsInfo - function to poll for events information in the CCDB via REST API
func FetchEventsInfo(cfapp *cfenv.App, log *log.Logger) {
	log.Println("running FetchEventsInfo cron")
	heritageClient := getHeritageClient(cfapp)
	cfclient := cf.NewCloudFoundryClient(heritageClient, log)
	eventSearch := new(events.EventSearch).Init(cfclient)
	eventSearch.CompileRecentEvents()
	localCache.EventsBlob = eventSearch.EventsBlob
}
Ejemplo n.º 2
0
//FetchAppsInfo - function to poll for app information in the CCDB via REST API
func FetchAppsInfo(cfapp *cfenv.App, log *log.Logger) {
	log.Println("running FetchAppsInfo cron")
	heritageClient := getHeritageClient(cfapp)
	cfclient := cf.NewCloudFoundryClient(heritageClient, log)
	appSearch := new(applications.AppSearch).Init(cfclient)
	appSearch.CompileAllApps()
	localCache.AppsBlob = appSearch.AppStats
}
Ejemplo n.º 3
0
//FetchUserInfo - function to poll for user information in the UAA via REST API
func FetchUserInfo(cfapp *cfenv.App, log *log.Logger) {
	log.Printf("running FetchUserInfo cron")
	heritageClient := getHeritageClient(cfapp)
	cfclient := cf.NewCloudFoundryClient(heritageClient, log)
	userSearch := new(users.UserSearch).Init(cfclient)
	userList, _ := userSearch.List("", "")
	localCache.UserBlob = new(users.UserAggregate)
	localCache.UserBlob.Compile(userList)
}
Ejemplo n.º 4
0
	"github.com/martini-contrib/oauth2"
	"github.com/pivotal-pez/pezdispenser/cloudfoundryclient"
	"github.com/pivotal-pez/pezdispenser/service"
	"github.com/xchapter7x/goutil"
	"gopkg.in/mgo.v2/bson"
)

//NewOrg - creates a new org manager
var NewOrg = func(username string, log *log.Logger, tokens oauth2.Tokens, store pezdispenser.Persistence, authClient AuthRequestCreator) OrgManager {
	s := &orgManager{
		username: username,
		log:      log,
		tokens:   tokens,
		store:    store,
		cfClient: cloudfoundryclient.NewCloudFoundryClient(authClient, log),
	}
	return s
}

//Show - show if the user exists and already has an org or not.
func (s *orgManager) Show() (result *PivotOrg, err error) {
	result = new(PivotOrg)
	userInfo := GetUserInfo(s.tokens)
	NewUserMatch().UserInfo(userInfo).UserName(s.username).OnSuccess(func() {
		s.log.Println("getting userInfo: ", userInfo)
		s.log.Println("result value: ", result)
		err = s.store.FindOne(bson.M{EmailFieldName: s.username}, result)
		s.log.Println("response: ", result, err)
	}).OnFailure(func() {
		s.log.Println(ErrCantCallAcrossUsers.Error())