wongnai / kube-slack

Kubernetes Slack Monitoring
MIT License
323 stars 59 forks source link

Avoid error when slack_username is not defined #64

Open albertollamaso opened 4 years ago

albertollamaso commented 4 years ago
When the envrionent variable slack_username is not defined it throws this error:

(node:1) UnhandledPromiseRejectionWarning: Error: Configuration property "slack_username" is not defined
    at Config.get (/app/node_modules/config/lib/config.js:182:11)
    at SlackNotifier.notify (/app/notify/slack.js:26:48)
    at PodLongNotReady.callback (/app/index.js:27:26)
    at PodLongNotReady.emit (events.js:198:13)
    at PodLongNotReady.check (/app/monitors/longnotready.js:65:18)
    at process._tickCallback (internal/process/next_tick.js:68:7)
(node:1) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)

With this commit we avoid this error if this environment variable is not defined