Skip to content

Commit

Permalink
Fix where no oncall returned if missing configuration variable
Browse files Browse the repository at this point in the history
Introduced in #117. Also fixes case where an ignored schedule would still appear in the logs if no username was assigned to it.

Fixes #118
  • Loading branch information
stephenyeargin committed Nov 27, 2018
1 parent aab7414 commit b2d83cc
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/scripts/pagerduty.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -614,11 +614,18 @@ module.exports = (robot) ->

renderSchedule = (s, cb) ->
withCurrentOncall msg, s, (username, schedule) ->
# If there is an allowed schedules array, skip returned schedule not in it
if allowed_schedules.length and schedule.id not in allowed_schedules
robot.logger.debug "Schedule #{schedule.id} (#{schedule.name}) not in HUBOT_PAGERDUTY_SCHEDULES"
return cb null

# Ignore schedule if no user assigned to it
if (username)
if !allowed_schedules or schedule.id in allowed_schedules
messages.push("* #{username} is on call for #{schedule.name} - #{schedule.html_url}")
messages.push("* #{username} is on call for #{schedule.name} - #{schedule.html_url}")
else
robot.logger.debug "No user for schedule #{schedule.name}"

# Return callback
cb null

if scheduleName?
Expand Down

0 comments on commit b2d83cc

Please sign in to comment.