Claimer is a slack bot for managing locks in a concourse resource pool
-
An API token for the slack bot (see here for instruction on creating a new bot user)
-
The ID of the slack channel that the bot will listen in (you must invite the bot to this channel). You can find this by opening the channel in slack and looking at the last portion of the URL. For example:
https://<org>.slack.com/messages/<channelId>/
-
A git repo and deploy key for your pool (see here for repo structure)
NOTE: Claimer can only claim and release pools that contain a single lock
-
Golang 1.7+
-
git
andssh
mkdir -p $GOPATH/src/github.com/mdelillo
cd $GOPATH/src/github.com/mdelillo
git clone https://github.com/mdelillo/claimer
cd claimer
go build .
./claimer \
-apiToken <api-token> \
-channelId <channel-id> \
-repoUrl <repo-url> \
-deployKey <deploy-key>
The provided manifest.yml
and Procfile
can be used to push Claimer to Cloud Foundry.
- Fill in
manifest.yml
with required environment variables - Log in to your CF environment
- Run
cf push
You can customize the things that claimer says.
- Create a translations file. Examples can be found here
- Use the
translationFile
field in themanifest.yml
to point to your translations file.
Be sure all tests pass (ginkgo -r .
) and code is formatted (bin/fmt
) before submitting pull requests.
The integration tests run by posting in a real slack channel and ensuring that a real git repo is modified. In order to run them, you'll need to set up or get access to a slack organization and git repo.
- Create a bot user for claimer (e.g.
@claimer
) - Create another bot user for testing (e.g.
@claimer-integration
) - Create a channel (e.g.
#test-claimer
) and add both bots to it - Create another channel (e.g.
#other-channel
) and add both bots to it
- Create a github repo
- Add a deploy key (make sure it has write access)
- Create the following directory structure in your repo:
. ├── pool-1 │ ├── claimed │ └── unclaimed │ └── lock-a └── pool-2 ├── claimed └── unclaimed ├── lock-a └── lock-b
- Commit all the files and tag the commit with
initial-state
-
Export the following environment variables:
CLAIMER_TEST_API_TOKEN
: API Token for@claimer
CLAIMER_TEST_BOT_ID
: Bot ID for@claimer
. You can get this by visitinghttps://slack.com/api/auth.test?token=<api-token>
CLAIMER_TEST_USER_API_TOKEN
: API Token for@claimer-integration
CLAIMER_TEST_USERNAME
: Username of your test user (e.g.claimer-integration
)CLAIMER_TEST_USER_ID
: User ID of your test user. You can get to this by going to your profile in Slack, clicking the More Actions button, and clickingCopy member ID
CLAIMER_TEST_CHANNEL_ID
: Channel ID for your#test-claimer
channelCLAIMER_TEST_OTHER_CHANNEL_ID
: Channel ID for your#other-channel
channelCLAIMER_TEST_REPO_URL
: URL of your git repositoryCLAIMER_TEST_DEPLOY_KEY
: Deploy token for your git repository
-
Install ginkgo:
go install github.com/mdelillo/claimer/vendor/github.com/onsi/ginkgo/ginkgo
-
Run ginkgo:
$GOPATH/bin/ginkgo -r .
Counterfeiter fakes are used heavily in the unit tests.
The bin/generate-fakes
script can be used to regenerate them.
- Only pools with a single lock can be claimed and released
- Claimer does not respond in slack when some errors occur (e.g. when
claim
is called without a pool) - Claimer can only listen to messages in one channel at a time
Claimer is licensed under the MIT license.