Beispiel #1
0
func main() {
	setupEnvVars()

	// setup dynamodb connection
	c, err := integrations.NewClient(dynamoTable, dynamoEndpoint, dynamoRegion, awsKey, awsSecret)
	if err != nil {
		log.Fatal(kv.FormatLog("who-is-who", kv.Error, "dynamo connection", m{
			"message": err.Error(),
		}))
	}
	d := api.DynamoConn{
		Dynamo: c,
	}

	// setup HTTP server
	log.Println(kv.FormatLog("who-is-who", kv.Info, "server startup", m{
		"message": fmt.Sprintf("Listening on %s", port),
	}))
	err = http.ListenAndServe(port, d.HookUpRouter())
	if err != nil {
		log.Fatal(kv.FormatLog("who-is-who", kv.Error, "server startup failure", m{
			"msg": err.Error(),
		}))
	}
}
Beispiel #2
0
func main() {
	// get DB conn
	client, err := integrations.NewClient(dynamoTable, dynamoEndpoint, dynamoRegion, awsKey, awsSecret)
	if err != nil {
		log.Fatalf("Failed to connect => {%s}", err)
	}

	// get Slack info
	slackData := slack.NewUserMap(domain, slackToken)

	// seed a map of User's with emails
	emails, err := slackData.EmailList()
	if err != nil {
		log.Fatal(kayvee.FormatLog("who-is-who", kayvee.Error, "bad slack conn", m{
			"msg": err.Error(),
		}))
	}

	userMap := make(integrations.UserMap)
	for _, e := range emails {
		userMap[strings.ToLower(e)] = integrations.User{}
	}

	// declare all data sources to be used
	dataSources := []struct {
		Service integrations.InfoSource
		Name    string
	}{
		{slackData, "slack"},
		{aws.AwsService{}, "aws"},
		// Turning github integration off until bugs are fixed: INFRA-1124
		// {github.UserList{
		// 	Token:  githubToken,
		// 	Org:    githubOrg,
		// 	Domain: domain,
		// }, "github"},
	}

	// add data from every data source to every User object
	for _, src := range dataSources {
		var err error
		userMap, err = src.Service.Fill(userMap)
		if err != nil {
			log.Printf("Failed to get data from source, %s => {%s}", src.Name, err)
		}
	}

	// try to save everything
	err = client.SaveUsers(userMap)
	if err != nil {
		log.Fatalf("Failed to save users in Dynamo, %s", err)
	}

	log.Printf("Saved %d users", len(userMap))
}
Beispiel #3
0
func TestMain(m *testing.M) {
	c, err := integrations.NewClient(testTable, testDynamoEndpoint, "", "", "")
	if err != nil {
		log.Fatal(kayvee.FormatLog("who-is-who-testing", kayvee.Critical, "dynamo conn error", nil))
	}
	router = (api.DynamoConn{
		Dynamo: c,
	}).HookUpRouter()

	setup(c)

	outcome := m.Run()
	defer os.Exit(outcome)

	teardown(c)
}
Beispiel #4
0
func main() {
	// get DB conn
	client, err := integrations.NewClient(dynamoTable, dynamoEndpoint, dynamoRegion, awsKey, awsSecret)
	if err != nil {
		log.Fatalf("Failed to connect => {%s}", err)
	}

	_, err = client.Dynamo.
		UpdateItem(dynamoTable, dynago.HashKey("email", *email)).
		UpdateExpression("SET github=:github").
		Param(":github", *github).
		Execute()
	if err != nil {
		log.Fatalf("Failed to update 'github' field. Tried to set value to '%s' for user with email '%s'", *email, *github)
	}
}