Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(slackdiff): Use slack-ruby-client instead of slack-api #2576

Merged
1 commit merged into from
Jul 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
- OpenBSD: Include bgpd, ospfd and ospf6d files (@woopstar)
- scrub often changing values in junos license output (@matejv)
- comware: support for enable(super) login password added (@delvta)
- use slack-ruby-client instead of slack-api for slackdiff hook (@0xmc)

### Fixed

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ RUN apt-get -yq update \
&& rm -rf /var/lib/apt/lists/*

# dependencies for hooks
RUN gem install aws-sdk slack-api xmpp4r cisco_spark --no-document
RUN gem install aws-sdk slack-ruby-client xmpp4r cisco_spark --no-document

# dependencies for sources
RUN gem install gpgme sequel sqlite3 mysql2 pg --no-document
Expand Down
8 changes: 4 additions & 4 deletions docs/Hooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,12 @@ Your AWS credentials should be stored in `~/.aws/credentials`.

## Hook type: slackdiff

The `slackdiff` hook posts colorized config diffs to a [Slack](http://www.slack.com) channel of your choice. It only triggers for `post_store` events.
The `slackdiff` hook posts colorized config diffs to a [Slack](https://www.slack.com) channel of your choice. It only triggers for `post_store` events.

You will need to manually install the `slack-api` gem on your system:
You will need to manually install the `slack-ruby-client` gem on your system:

```shell
gem install slack-api
gem install slack-ruby-client
```

### slackdiff hook configuration example
Expand All @@ -198,7 +198,7 @@ hooks:
channel: "#network-changes"
```

The token parameter is a "legacy token" and is generated [Here](https://api.slack.com/custom-integrations/legacy-tokens).
The token parameter is a Slack API token that can be generated following [this tutorial](https://api.slack.com/tutorials/tracks/getting-a-token). Until Slack stops supporting them, legacy tokens can also be used.

Optionally you can disable snippets and post a formatted message, for instance linking to a commit in a git repo. Named parameters `%{node}`, `%{group}`, `%{model}` and `%{commitref}` are available.

Expand Down
2 changes: 1 addition & 1 deletion lib/oxidized/hook/slackdiff.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def run_hook(ctx)
config.token = cfg.token
config.proxy = cfg.proxy if cfg.has_key?('proxy')
end
client = Slack::Client.new
client = Slack::Web::Client.new
client.auth_test
log "Connected"
if cfg.has_key?("diff") ? cfg.diff : true
Expand Down