Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mdelillo/claimer
Slack bot for managing locks in a concourse resource pool
https://github.com/mdelillo/claimer
concourse concourse-ci golang resource-pool slack slack-bot
Last synced: 3 days ago
JSON representation
Slack bot for managing locks in a concourse resource pool
- Host: GitHub
- URL: https://github.com/mdelillo/claimer
- Owner: mdelillo
- License: mit
- Created: 2017-02-28T03:35:49.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2021-02-17T15:50:14.000Z (almost 4 years ago)
- Last Synced: 2024-11-14T21:40:03.687Z (2 months ago)
- Topics: concourse, concourse-ci, golang, resource-pool, slack, slack-bot
- Language: Go
- Homepage:
- Size: 2.69 MB
- Stars: 3
- Watchers: 6
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Claimer
Claimer is a slack bot for managing locks in a [concourse resource pool](https://github.com/concourse/pool-resource)
## Installation
### Prerequisites
* An API token for the slack bot
(see [here](https://api.slack.com/bot-users#how_do_i_create_custom_bot_users_for_my_team) 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://.slack.com/messages//`
* A git repo and deploy key for your pool
(see [here](https://github.com/concourse/pool-resource#git-repository-structure) for repo structure)**NOTE:** Claimer can only claim and release pools that contain a single lock
* Golang 1.7+
* `git` and `ssh`### Compile and run
```bash
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 \
-channelId \
-repoUrl \
-deployKey
```### Deploying to Cloud Foundry
The provided `manifest.yml` and `Procfile` can be used to push Claimer to [Cloud Foundry](https://www.cloudfoundry.org/).
1. Fill in `manifest.yml` with required environment variables
1. Log in to your CF environment
1. Run `cf push`## Translations
You can customize the things that claimer says.
1. Create a translations file. Examples can be found [here](https://github.com/mdelillo/claimer/tree/master/translations)
1. Use the `translationFile` field in the `manifest.yml` to point to your translations file.## Contributing
Be sure all tests pass (`ginkgo -r .`) and code is formatted (`bin/fmt`) before submitting pull requests.
### Prerequisites
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.#### Slack
1. Create a bot user for claimer (e.g. `@claimer`)
1. Create another bot user for testing (e.g. `@claimer-integration`)
1. Create a channel (e.g. `#test-claimer`) and add both bots to it
1. Create another channel (e.g. `#other-channel`) and add both bots to it#### Git
1. Create a github repo
1. [Add a deploy key](https://developer.github.com/guides/managing-deploy-keys/#setup-2)
(make sure it has write access)
1. Create the following directory structure in your repo:
```
.
├── pool-1
│ ├── claimed
│ └── unclaimed
│ └── lock-a
└── pool-2
├── claimed
└── unclaimed
├── lock-a
└── lock-b
```
1. Commit all the files and tag the commit with `initial-state`### Running the tests
1. 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 visiting `https://slack.com/api/auth.test?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 clicking `Copy member ID`
* `CLAIMER_TEST_CHANNEL_ID`: Channel ID for your `#test-claimer` channel
* `CLAIMER_TEST_OTHER_CHANNEL_ID`: Channel ID for your `#other-channel` channel
* `CLAIMER_TEST_REPO_URL`: URL of your git repository
* `CLAIMER_TEST_DEPLOY_KEY`: Deploy token for your git repository1. Install ginkgo:
```bash
go install github.com/mdelillo/claimer/vendor/github.com/onsi/ginkgo/ginkgo
```1. Run ginkgo:
```bash
$GOPATH/bin/ginkgo -r .
```### Generating fakes
[Counterfeiter](https://github.com/maxbrunsfeld/counterfeiter) fakes are used heavily in the unit tests.
The `bin/generate-fakes` script can be used to regenerate them.## Known Issues and Limitations
* 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## License
Claimer is licensed under the MIT license.