mirror of
https://github.com/cloudflare/redoctober.git
synced 2026-01-03 03:35:43 +00:00
Send hipchat message on startup (if configured). (#179)
+ If a valid hipchat configuration is provided, send a message when Red October has restarted. + If persistence is inactive, alert the channel that this is the case.
This commit is contained in:
@@ -39,10 +39,12 @@ type UI struct {
|
|||||||
Static string `json:"static"`
|
Static string `json:"static"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// HipChat contains the settings for Hipchat integration.
|
// HipChat contains the settings for Hipchat integration. The ID is
|
||||||
|
// the name that should be used in the startup message.
|
||||||
type HipChat struct {
|
type HipChat struct {
|
||||||
Host string `json:"host"`
|
Host string `json:"host"`
|
||||||
Room string `json:"room"`
|
Room string `json:"room"`
|
||||||
|
ID string `json:"id"`
|
||||||
APIKey string `json:"api_key"`
|
APIKey string `json:"api_key"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
27
core/core.go
27
core/core.go
@@ -18,6 +18,7 @@ import (
|
|||||||
"github.com/cloudflare/redoctober/keycache"
|
"github.com/cloudflare/redoctober/keycache"
|
||||||
"github.com/cloudflare/redoctober/order"
|
"github.com/cloudflare/redoctober/order"
|
||||||
"github.com/cloudflare/redoctober/passvault"
|
"github.com/cloudflare/redoctober/passvault"
|
||||||
|
"github.com/cloudflare/redoctober/persist"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -244,6 +245,11 @@ func Init(path string, config *config.Config) error {
|
|||||||
err = fmt.Errorf("failed to load password vault %s: %s", path, err)
|
err = fmt.Errorf("failed to load password vault %s: %s", path, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
crypt, err = cryptor.New(&records, nil, config)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
var hipchatClient hipchat.HipchatClient
|
var hipchatClient hipchat.HipchatClient
|
||||||
hc := config.HipChat
|
hc := config.HipChat
|
||||||
if hc.Valid() {
|
if hc.Valid() {
|
||||||
@@ -258,11 +264,28 @@ func Init(path string, config *config.Config) error {
|
|||||||
HcHost: hc.Host,
|
HcHost: hc.Host,
|
||||||
RoHost: config.UI.Root,
|
RoHost: config.UI.Root,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
name := hc.ID
|
||||||
|
if name == "" {
|
||||||
|
name = "Red October"
|
||||||
|
}
|
||||||
|
message := name + " has restarted."
|
||||||
|
color := hipchat.GreenBackground
|
||||||
|
|
||||||
|
status := crypt.Status()
|
||||||
|
if status.State == persist.Inactive {
|
||||||
|
message += " @here: persistence is currently " + status.State + "; the restore admins need to restore the saved delegations."
|
||||||
|
color = hipchat.RedBackground
|
||||||
|
}
|
||||||
|
|
||||||
|
err = hipchatClient.Notify(message, color)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
orders = order.NewOrderer(hipchatClient)
|
orders = order.NewOrderer(hipchatClient)
|
||||||
crypt, err = cryptor.New(&records, nil, config)
|
return nil
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create processes a create request.
|
// Create processes a create request.
|
||||||
|
|||||||
Reference in New Issue
Block a user