Skip to content

Latest commit

 

History

History
123 lines (93 loc) · 4.47 KB

README.md

File metadata and controls

123 lines (93 loc) · 4.47 KB

Claimer

Claimer is a slack bot for managing locks in a concourse resource pool

Claimer demo

Installation

Prerequisites

  • 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 and ssh

Compile and run

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>

Deploying to Cloud Foundry

The provided manifest.yml and Procfile can be used to push Claimer to Cloud Foundry.

  1. Fill in manifest.yml with required environment variables
  2. Log in to your CF environment
  3. Run cf push

Translations

You can customize the things that claimer says.

  1. Create a translations file. Examples can be found here
  2. 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)
  2. Create another bot user for testing (e.g. @claimer-integration)
  3. Create a channel (e.g. #test-claimer) and add both bots to it
  4. Create another channel (e.g. #other-channel) and add both bots to it

Git

  1. Create a github repo
  2. Add a deploy key (make sure it has write access)
  3. Create the following directory structure in your repo:
    .
    ├── pool-1
    │   ├── claimed
    │   └── unclaimed
    │       └── lock-a
    └── pool-2
        ├── claimed
        └── unclaimed
            ├── lock-a
            └── lock-b
    
  4. 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=<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 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 repository
  2. Install ginkgo:

    go install github.com/mdelillo/claimer/vendor/github.com/onsi/ginkgo/ginkgo
  3. Run ginkgo:

    $GOPATH/bin/ginkgo -r .

Generating fakes

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.