Documentation
¶
Index ¶
- Constants
- func Handler(next http.Handler, src Source) http.Handler
- func LongPath(shortPath string) string
- func MatchURL(baseURL, testURL string) (bool, error)
- func RequestURL(req *http.Request) string
- func ShortPath(longPath string) string
- func ShortURLMiddleware(next http.Handler) http.Handler
- type Config
- func (cfg Config) ApplicationName() string
- func (cfg Config) CallbackURL(path string, mergeParams ...url.Values) string
- func (cfg Config) Context(ctx context.Context) context.Context
- func (cfg Config) Hints() Hints
- func (cfg Config) PublicURL() string
- func (cfg Config) ShouldUsePublicURL() bool
- func (cfg Config) TwilioSMSFromNumber(carrier string) string
- func (cfg Config) ValidReferer(reqURL, ref string) bool
- func (cfg Config) ValidWebhookURL(testURL string) bool
- func (cfg Config) Validate() error
- type Hints
- type Source
- type Static
- type Store
- func (s *Store) Config() Config
- func (s *Store) ConfigData(ctx context.Context, tx *sql.Tx) (id, schemaVersion int, data []byte, err error)
- func (s *Store) Reload(ctx context.Context) error
- func (s *Store) ServeConfig(w http.ResponseWriter, req *http.Request)
- func (s *Store) SetConfig(ctx context.Context, cfg Config) error
- func (s *Store) SetConfigData(ctx context.Context, tx *sql.Tx, data []byte) (int, error)
- func (s *Store) Shutdown(ctx context.Context) error
- func (s *Store) UpdateConfig(ctx context.Context, fn func(Config) (Config, error)) error
Constants ¶
const SchemaVersion = 1
SchemaVersion indicates the current config struct version.
Variables ¶
This section is empty.
Functions ¶
func LongPath ¶ added in v0.24.0
LongPath will attempt to convert a shortened GoAlert URL into the original. If unable, it will return an empty string.
func MatchURL ¶ added in v0.28.0
MatchURL will compare two url strings and will return true if they match.
func RequestURL ¶ added in v0.30.0
RequestURL returns the full URL for the given request based on the current public url.
Types ¶
type Config ¶
type Config struct {
General struct {
ApplicationName string `public:"true" info:"The name used in messaging and page titles. Defaults to \"GoAlert\"."`
PublicURL string `` /* 138-byte string literal not displayed */
GoogleAnalyticsID string `public:"true" info:"No longer used." deprecated:"No longer used."`
NotificationDisclaimer string `public:"true" info:"Disclaimer text for receiving pre-recorded notifications (appears on profile page)."`
DisableMessageBundles bool `public:"true" info:"Disable bundling status updates and alert notifications."`
ShortURL string `` /* 179-byte string literal not displayed */
DisableSMSLinks bool `public:"true" info:"If set, SMS messages will not contain a URL pointing to GoAlert."`
DisableLabelCreation bool `public:"true" info:"Disables the ability to create new labels for services."`
DisableCalendarSubscriptions bool `` /* 132-byte string literal not displayed */
}
Maintenance struct {
AlertCleanupDays int `public:"true" info:"Closed alerts will be deleted after this many days (0 means disable cleanup)."`
APIKeyExpireDays int `public:"true" info:"Unused calendar API keys will be disabled after this many days (0 means disable cleanup)."`
ScheduleCleanupDays int `public:"true" info:"Schedule on-call history will be deleted after this many days (0 means disable cleanup)."`
}
Auth struct {
RefererURLs []string `info:"Allowed referer URLs for auth and redirects." deprecated:"Use --public-url flag instead, which takes precedence."`
DisableBasic bool `public:"true" info:"Disallow username/password login."`
}
GitHub struct {
Enable bool `public:"true" info:"Enable GitHub authentication."`
NewUsers bool `info:"Allow new user creation via GitHub authentication."`
ClientID string
ClientSecret string `password:"true"`
AllowedUsers []string `info:"Allow any of the listed GitHub usernames to authenticate. Use '*' to allow any user."`
AllowedOrgs []string `info:"Allow any member of any listed GitHub org (or team, using the format 'org/team') to authenticate."`
EnterpriseURL string `info:"GitHub URL (without /api) when used with GitHub Enterprise."`
}
OIDC struct {
Enable bool `public:"true" info:"Enable OpenID Connect authentication."`
NewUsers bool `info:"Allow new user creation via OIDC authentication."`
OverrideName string `info:"Set the name/label on the login page to something other than OIDC."`
IssuerURL string
ClientID string
ClientSecret string `password:"true"`
Scopes string `info:"Requested scopes for authentication. If left blank, openid, profile, and email will be used."`
UserInfoEmailPath string `` /* 140-byte string literal not displayed */
UserInfoEmailVerifiedPath string `` /* 169-byte string literal not displayed */
UserInfoNamePath string `` /* 175-byte string literal not displayed */
}
Mailgun struct {
Enable bool `public:"true"`
APIKey string `password:"true"`
EmailDomain string `info:"The TO address for all incoming alerts."`
}
Slack struct {
Enable bool `public:"true"`
ClientID string
ClientSecret string `password:"true"`
// The `xoxb-` prefix is documented by Slack.
// https://api.slack.com/docs/token-types#bot
AccessToken string `password:"true" info:"Slack app bot user OAuth access token (should start with xoxb-)."`
SigningSecret string `password:"true" info:"Signing secret to verify requests from slack."`
InteractiveMessages bool `info:"Enable interactive messages (e.g. buttons)."`
}
Twilio struct {
Enable bool `public:"true" info:"Enables sending and processing of Voice and SMS messages through the Twilio notification provider."`
AccountSID string
AuthToken string `` /* 151-byte string literal not displayed */
AlternateAuthToken string `` /* 194-byte string literal not displayed */
FromNumber string `public:"true" info:"The Twilio number to use for outgoing notifications."`
MessagingServiceSID string `public:"true" info:"If set, replaces the use of From Number for SMS notifications."`
DisableTwoWaySMS bool `info:"Disables SMS reply codes for alert messages."`
SMSCarrierLookup bool `info:"Perform carrier lookup of SMS contact methods (required for SMSFromNumberOverride). Extra charges may apply."`
SMSFromNumberOverride []string `` /* 143-byte string literal not displayed */
}
SMTP struct {
Enable bool `public:"true" info:"Enables email as a contact method."`
From string `public:"true" info:"The email address messages should be sent from."`
Address string `info:"The server address to use for sending email. Port is optional."`
DisableTLS bool `info:"Disables TLS on the connection (STARTTLS will still be used if supported)."`
SkipVerify bool `info:"Disables certificate validation for TLS/STARTTLS (insecure)."`
Username string `info:"Username for authentication."`
Password string `password:"true" info:"Password for authentication."`
}
Webhook struct {
Enable bool `public:"true" info:"Enables webhook as a contact method."`
AllowedURLs []string `public:"true" info:"If set, allows webhooks for these domains only."`
}
Feedback struct {
Enable bool `public:"true" info:"Enables Feedback link in nav bar."`
OverrideURL string `public:"true" info:"Use a custom URL for Feedback link in nav bar."`
}
// contains filtered or unexported fields
}
Config contains GoAlert application settings.
func FromContext ¶
FromContext will return the Config carried in the provided Context.
It panics if config is not available on the current context.
func (Config) ApplicationName ¶ added in v0.28.0
ApplicationName will return the General.ApplicationName
func (Config) CallbackURL ¶
CallbackURL will return a public-routable URL to the given path. It will use PublicURL() to fill in missing pieces.
It will panic if provided an invalid URL.
func (Config) PublicURL ¶
PublicURL will return the General.PublicURL or a fallback address (i.e. the app listening port).
func (Config) ShouldUsePublicURL ¶ added in v0.30.0
ShouldUsePublicURL returns true if redirects, validation, etc.. should use the configured PublicURL instead of host/referer.
func (Config) TwilioSMSFromNumber ¶ added in v0.25.0
TwilioSMSFromNumber will determine the appropriate FROM number to use for SMS messages to the given number
func (Config) ValidReferer ¶
ValidReferer returns true if the URL is an allowed referer source.
func (Config) ValidWebhookURL ¶ added in v0.28.0
ValidWebhookURL returns true if the URL is an allowed webhook source.
type Hints ¶ added in v0.25.0
type Hints struct {
GitHub struct {
AuthCallbackURL string
}
OIDC struct {
RedirectURL string
}
Mailgun struct {
ForwardURL string
}
Twilio struct {
MessageWebhookURL string
VoiceWebhookURL string
}
Slack struct {
InteractivityResponseURL string
}
}
Hints contains information helpful for configuring GoAlert and various integrations.
type Source ¶
type Source interface {
Config() Config
}
A Source will provide a snapshot of a Config struct.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store handles saving and loading configuration from a postgres database.
func NewStore ¶
func NewStore(ctx context.Context, db *sql.DB, keys keyring.Keys, explicitURL, fallbackURL string) (*Store, error)
NewStore will create a new Store with the given parameters. It will automatically detect new configuration changes.
func (*Store) ConfigData ¶
func (s *Store) ConfigData(ctx context.Context, tx *sql.Tx) (id, schemaVersion int, data []byte, err error)
ConfigData will return the current raw config data from the DB.
func (*Store) ServeConfig ¶
func (s *Store) ServeConfig(w http.ResponseWriter, req *http.Request)
ServeConfig handles requests to read and write the config json.
func (*Store) SetConfig ¶
SetConfig will replace the configuration in the DB and perform an immediate reload.
func (*Store) SetConfigData ¶
SetConfigData will replace the current DB config with data.