Skip to content

Commit

Permalink
Fix service host
Browse files Browse the repository at this point in the history
Signed-off-by: Julien Pivotto <roidelapluie@o11y.eu>
  • Loading branch information
roidelapluie committed Mar 7, 2023
1 parent fcda769 commit 44ca740
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions webhook/hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,25 +101,28 @@ func Webhook(w http.ResponseWriter, r *http.Request, c config.Configuration) {

if name, ok := data.CommonLabels["instance"]; ok {
l.V(2).Infof("Creating host %v", name)
host, err = icinga.GetHost(serviceHost)
host, err = icinga.GetHost(name)
if err != nil {
err := icinga.CreateHost(icinga2.Host{
Name: name,
DisplayName: name,
Notes: "Created by signalio",
Address: name,
})
if err != nil {
l.Errorf("Could not create service host %v: %v\n", host, err)
asJSON(w, http.StatusInternalServerError, err.Error())
return
}
host, err = icinga.GetHost(serviceHost)
host, err = icinga.GetHost(name)
if err != nil {
l.Errorf("Did not find service host %v: %v\n", host, err)
asJSON(w, http.StatusInternalServerError, err.Error())
return
}
}
serviceHost = name
l.V(2).Infof("Using host %v=%v", name, host)
} else {
l.V(2).Infof("No instance label")
}
Expand Down

0 comments on commit 44ca740

Please sign in to comment.