Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
nogweii
my-certificate-alert
Commits
c0358261
Commit
c0358261
authored
Aug 17, 2021
by
Nogweii
Browse files
send a pushover notification
parent
2168f3cc
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/main.go
View file @
c0358261
...
...
@@ -36,9 +36,7 @@ func main() {
}
if
anyGlobMatch
{
log
.
WithFields
(
log
.
Fields
{
"domains"
:
allDomains
,
})
.
Info
(
"New certificate we're interested in found!"
)
notify
(
allDomains
)
}
case
err
:=
<-
errStream
:
...
...
src/notify.go
0 → 100644
View file @
c0358261
package
main
import
(
"fmt"
"github.com/gregdel/pushover"
log
"github.com/sirupsen/logrus"
)
func
notify
(
allDomains
[]
string
)
{
log
.
WithFields
(
log
.
Fields
{
"domains"
:
allDomains
,
})
.
Info
(
"Sending a pushover notification"
)
// Create a new pushover app & user
app
:=
pushover
.
New
(
configuration
.
PushoverAppToken
)
recipient
:=
pushover
.
NewRecipient
(
configuration
.
PushoverUserKey
)
// Create the message to send
messageContents
:=
fmt
.
Sprintf
(
"New certificate issued for %v"
,
allDomains
)
message
:=
pushover
.
NewMessage
(
messageContents
)
// Send the message to the recipient
_
,
err
:=
app
.
SendMessage
(
message
,
recipient
)
if
err
!=
nil
{
log
.
WithFields
(
log
.
Fields
{
"error"
:
err
})
.
Fatal
(
"Could not send pushover message"
)
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment