Peer Acks v2
A port of the original Cockroach Labs peer-acks to Go, now powered by Google Cloud Functions.
About
Peer Acks V2 is an internal Slack integration used at Cockroach Labs for employees to show appreciation to each other in the form of "peer acks".
Architecture
The application consists of two serverless functions:
SlackEvents: Handles Slack events and challenges
SlackSlashCommand: Processes Slack slash commands
Prerequisites
- Google Cloud SDK
- Go 1.21 or later
- CockroachDB database
- Slack app configuration
Environment Variables
The following environment variables are required:
DATASOURCE=postgresql://user@crdb-host:26257/peer_acks?sslmode=verify-full&sslcert=client.crt&sslkey=client.key&sslrootcert=ca.crt
SLACK_ACKS_CHANNELID=your_slack_channel_id
SLACK_SIGNING_SECRET=your_slack_signing_secret
Development
Local Setup
-
Set up a database:
# Start up local CRDB cluster and create database
cockroach start-single-node --insecure
cockroach sql --insecure -e "CREATE DATABASE peer_acks;"
-
Set required environment variables:
export DATASOURCE="postgresql://root@localhost:26257/peer_acks?sslmode=disable"
export SLACK_SIGNING_SECRET="your-slack-secret"
export SLACK_ACKS_CHANNELID="your-channel-id"
-
Run a function locally:
FUNCTION_TARGET=SlackEvents go run main.go
-
(Optional) To expose local server to Slack:
ngrok http 8080
Then update your Slack app's event subscription URL to the ngrok URL.
Deployment
Deploy to Google Cloud Functions
-
Ensure you have the Google Cloud SDK installed and configured:
gcloud auth login
gcloud config set project YOUR_PROJECT_ID
-
Deploy using Cloud Build:
gcloud builds submit --config cloudbuild-functions.yaml \
--substitutions=_DATASOURCE="your-db-connection-string",\
_SLACK_SIGNING_SECRET="your-slack-secret",\
_SLACK_ACKS_CHANNELID="your-channel-id"
-
After deployment, update your Slack app configuration with the new function URLs from the Google Cloud Console.
Security
- Slack endpoints are authenticated using Slack's signing secret
- Database credentials are managed through environment variables
- Functions are deployed with HTTPS endpoints