-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
boardwalkd (feat): add Slack commands for catching/releasing workspac…
…es (#75) Adds Slack integration to `boardwalkd` through means of a Slack App, such that it is now possible to quickly view the status of workspaces--along with the logged events--as well as catch or release workspaces from within Slack. This is intended to augment--not replace--the web dashboard. Using the Slack [app manifest](https://api.slack.com/reference/manifests) located within `slack_app_manifest.yaml`, an individual implementing Boardwalk can quickly conmfigure the required settings for the app. Additional configuration, if desired, may be done after--or before by directly editing the manifest--the app is [created within Slack's system](https://api.slack.com/apps?new_app=1). Using this feature is done by providing a Slack app and bot token, in the `BOARDWALKD_SLACK_APP_TOKEN` and `BOARDWALKD_SLACK_BOT_TOKEN` environment variables. Features provided by this integration include: 1. A Slack app home page, which displays at a glance statuses for configured workspaces 2. The ability to catch or release one, multiple, or all workspaces. 3. Viewing the details of a specified workspace. 4. Adds the following Slack slash-commands: - `/brdwlk-version` - Returns the currently running version of Boardwalk. - `/brdwlk-catch-release` - Allows one or more workspaces to be caught or released from a single modal. - `/brdwlk-list` - Lists workspaces with an active worker
- Loading branch information
1 parent
68e52ab
commit 0f75412
Showing
13 changed files
with
1,239 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
- Boardwalk icon (`src/boardwalkd/static/boardwalk_icon.jpg`) - Cropped from a | ||
public domain image from | ||
[Ingolfson](https://commons.wikimedia.org/wiki/User:Ingolfson) on [Wikimedia | ||
Commons](https://commons.wikimedia.org/wiki/File:Swampy_But_Pretty_Bog_In_Fiordland_NZ.jpg) | ||
- GitHub Corner code in `src/boardwalkd/templates/base.html` - MIT licensed, | ||
from [tholman/github-corners](https://github.com/tholman/github-corners) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
display_information: | ||
name: Boardwalk | ||
description: Boardwalk is a linear Ansible workflow engine. | ||
background_color: "#11359e" | ||
long_description: "Boardwalk is a linear Ansible workflow engine. It's purpose-built to help systems engineers automate low-and-slow background jobs against large numbers of production hosts. It's ideal for rolling-maintenance jobs like kernel and operating system upgrades.\r | ||
\r | ||
This Slack application is intended to serve as a quick interface to one of the more common reasons one might visit the dashboard: that being to catch or release workspaces.\r | ||
\r | ||
License: MIT\r | ||
Source code: https://github.com/Backblaze/boardwalk/" | ||
features: | ||
app_home: | ||
home_tab_enabled: true | ||
messages_tab_enabled: true | ||
messages_tab_read_only_enabled: false | ||
bot_user: | ||
display_name: Boardwalk | ||
always_online: true | ||
slash_commands: | ||
- command: /brdwlk-version | ||
description: Get the current version of Boardwalk | ||
should_escape: false | ||
- command: /brdwlk-catch-release | ||
description: Catch or release workspace(s) | ||
should_escape: false | ||
- command: /brdwlk-list | ||
description: List workspaces with an active worker | ||
should_escape: false | ||
oauth_config: | ||
scopes: | ||
bot: | ||
- chat:write | ||
- commands | ||
- im:write | ||
- incoming-webhook | ||
- users:read | ||
- users:read.email | ||
settings: | ||
event_subscriptions: | ||
bot_events: | ||
- app_home_opened | ||
interactivity: | ||
is_enabled: true | ||
org_deploy_enabled: false | ||
socket_mode_enabled: true | ||
token_rotation_enabled: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,7 +34,7 @@ def cli(): | |
@cli.command(context_settings=CONTEXT_SETTINGS) | ||
@click.option( | ||
"--auth-expire-days", | ||
help=("The number of days login tokens and user API keys are valid before" " they expire"), | ||
help=("The number of days login tokens and user API keys are valid before they expire"), | ||
type=float, | ||
default=14, | ||
show_default=True, | ||
|
@@ -94,7 +94,7 @@ def cli(): | |
) | ||
@click.option( | ||
"--port", | ||
help=("The non-TLS port number the server binds to. --port and/or" " --tls-port must be configured"), | ||
help=("The non-TLS port number the server binds to. --port and/or --tls-port must be configured"), | ||
type=int, | ||
default=None, | ||
) | ||
|
@@ -115,6 +115,33 @@ def cli(): | |
default=None, | ||
show_envvar=True, | ||
) | ||
@click.option( | ||
"--slack-app-token", | ||
help=( | ||
"A Slack App Token for the Slack App this Boardwalkd instance is to connect to." | ||
" If specified, --slack-bot-token must also be provided." | ||
), | ||
type=str, | ||
default=None, | ||
show_envvar=True, | ||
) | ||
@click.option( | ||
"--slack-bot-token", | ||
help=("A Slack OAuth Bot Token for the Slack App this Boardwalkd instance is to connect to."), | ||
type=str, | ||
default=None, | ||
show_envvar=True, | ||
) | ||
@click.option( | ||
"--slack-slash-command-prefix", | ||
help=( | ||
"The prefix to use in front of Boardwalk slash commands in Slack (e.g., /PREFIX-version). Needs to match the prefix supplied in the Slack App configuration." | ||
), | ||
type=str, | ||
default="brdwlk", | ||
show_default=True, | ||
show_envvar=True, | ||
) | ||
@click.option( | ||
"--tls-crt", | ||
help=("Path to TLS certificate chain file for use along with --tls-port"), | ||
|
@@ -155,6 +182,9 @@ def serve( | |
port: int | None, | ||
slack_error_webhook_url: str, | ||
slack_webhook_url: str, | ||
slack_app_token: str | None, | ||
slack_bot_token: str | None, | ||
slack_slash_command_prefix: str, | ||
tls_crt: str | None, | ||
tls_key: str | None, | ||
tls_port: int | None, | ||
|
@@ -173,17 +203,15 @@ def serve( | |
|
||
# If there is no TLS port then reject setting a TLS key and cert | ||
if (not tls_port) and (tls_crt or tls_key): | ||
raise BoardwalkException("--tls-crt and --tls-key should not be configured" " unless --tls-port is also set") | ||
raise BoardwalkException("--tls-crt and --tls-key should not be configured unless --tls-port is also set") | ||
|
||
# Validate TLS configuration (key and cert paths are already validated by click) | ||
if tls_port is not None: | ||
try: | ||
assert tls_crt | ||
assert tls_key | ||
except AssertionError: | ||
raise BoardwalkException( | ||
"--tls-crt and --tls-key paths must be supplied when a" " --tls-port is configured" | ||
) | ||
raise BoardwalkException("--tls-crt and --tls-key paths must be supplied when a --tls-port is configured") | ||
|
||
# Validate --owner | ||
if owner: | ||
|
@@ -196,6 +224,10 @@ def serve( | |
else: | ||
owner = "[email protected]" | ||
|
||
# Validate Slack app/bot token | ||
if (not slack_bot_token) and slack_app_token: | ||
raise BoardwalkException("If --slack-app-token is supplied, --slack-bot-token must also be supplied") | ||
|
||
asyncio.run( | ||
run( | ||
auth_expire_days=auth_expire_days, | ||
|
@@ -204,8 +236,11 @@ def serve( | |
host_header_pattern=host_header_regex, | ||
owner=owner, | ||
port_number=port, | ||
slack_app_token=slack_app_token, | ||
slack_bot_token=slack_bot_token, | ||
slack_error_webhook_url=slack_error_webhook_url, | ||
slack_webhook_url=slack_webhook_url, | ||
slack_slash_command_prefix=slack_slash_command_prefix, | ||
tls_crt_path=tls_crt, | ||
tls_key_path=tls_key, | ||
tls_port_number=tls_port, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.