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

Schedules Blacklist #110

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ Then add **hubot-pager-me** to your `external-scripts.json`:
* HUBOT_PAGERDUTY_API_KEY - Get one from https://<your subdomain>.pagerduty.com/api_keys
* HUBOT_PAGERDUTY_SERVICE_API_KEY - Service API Key from a 'General API Service'. This should be assigned to a dummy escalation policy that doesn't actually notify, as hubot will trigger on this before reassigning it
* HUBOT_PAGERDUTY_SERVICES - (optional) Provide a comma separated list of service identifiers (e.g. `PFGPBFY`) to restrict queries to only those services.
* HUBOT_PAGERDUTY_SCHEDULES_BLACKLIST - (optional) Provide a comman seperated blacklist of schedule names to filter out when querying for 'whos on call'
(e.g. `Backup,Secondary` will remove all schedules with either the words 'Backup' or 'Secondary' in the schedule name)

### Webhook

Expand Down
4 changes: 4 additions & 0 deletions src/scripts/pagerduty.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,10 @@ module.exports = (robot) ->
robot.emit 'error', err, msg
return
if schedules.length > 0
if process.env.HUBOT_PAGERDUTY_SCHEDULES_BLACKLIST
schedules_blacklist_regex = new RegExp("(" + process.env.HUBOT_PAGERDUTY_SCHEDULES_BLACKLIST.replace(/,/g, '|') + ")")
schedules = schedules.filter (schedule) -> !schedule.name.match(schedules_blacklist_regex)

async.map schedules, renderSchedule, (err) ->
if err?
robot.emit 'error', err, msg
Expand Down