Documentation
¶
Overview ¶
Package config reads and validates the configuration from environment variables. Invalid, incomplete, or contradictory settings are errors, all reported at once, so a misconfigured service fails at startup instead of silently running with a feature disabled or a default it was not given.
Any value may be an AWS SSM Parameter Store ARN, which is replaced by the parameter's decrypted value.
Index ¶
Constants ¶
const ( DefaultListenAddr = ":8080" DefaultGitHubWebURL = "https://github.com" DefaultOktaGitHubUserField = "githubUsername" DefaultOktaSyncSafetyThreshold = 0.5 DefaultSecurityAlertsMinAgeDays = 30 DefaultSecurityAlertsMinSeverity = domain.SeverityHigh // MinAdminTokenLength is the shortest admin token accepted. MinAdminTokenLength = 16 )
Defaults for unset variables.
Variables ¶
var ( DefaultPRMonitoredBranches = []string{"main", "master"} DefaultOktaScopes = []string{"okta.groups.read", "okta.users.read"} )
Default lists for unset variables.
Functions ¶
This section is empty.
Types ¶
type Bootstrap ¶ added in v1.0.0
Bootstrap is the configuration needed before the rest can be loaded: how to log, serve, and run the GitHub App installer. It doesn't need the GitHub App's credentials, so it loads before the app is set up. Like the rest, its APP_ values may be SSM ARNs; the installer's own variables are read as github-app-setup-go reads them, without SSM resolution.
func LoadBootstrap ¶ added in v1.0.0
LoadBootstrap reads the bootstrap configuration.
type Config ¶
type Config struct {
Bootstrap
// AdminToken guards the admin and scheduled endpoints. When empty,
// those endpoints are disabled.
AdminToken string
GitHub GitHub
PRCompliance PRCompliance
Okta Okta
SecurityAlerts SecurityAlerts
Slack Slack
}
Config is the application's configuration.
func (*Config) Redacted ¶
func (c *Config) Redacted() RedactedConfig
Redacted returns the configuration with secrets redacted.
func (*Config) ShouldMonitorBranch ¶
ShouldMonitorBranch returns true if merges into branch are checked for compliance.
type Env ¶ added in v1.0.0
type Env struct {
// Lookup has the signature of os.LookupEnv.
Lookup func(key string) (string, bool)
// ResolveSSM returns the value of the SSM parameter an ARN names. When
// nil, parameters are read from AWS with the default credentials.
ResolveSSM func(ctx context.Context, arn string) (string, error)
}
Env is where configuration is read from.
func ProcessEnv ¶ added in v1.0.0
func ProcessEnv() Env
ProcessEnv reads the process environment and resolves SSM ARNs in AWS.
type GitHub ¶ added in v1.0.0
type GitHub struct {
Org string
AppID int64
// InstallationID is the app's installation on Org. When zero it is
// looked up.
InstallationID int64
PrivateKey []byte
WebhookSecret string
// BaseURL is the API URL for GitHub Enterprise Server, or empty.
BaseURL string
// WebURL is the web URL that links point to.
WebURL string
}
GitHub configures the GitHub App.
type Installer ¶ added in v1.0.0
type Installer struct {
Enabled bool
// StorageMode is where the installer saves credentials: envfile or
// aws-ssm.
StorageMode string
// StorageDir is the env file path for the envfile mode.
StorageDir string
// GitHubOrg is the organization the app is created in.
GitHubOrg string
// GitHubURL is the GitHub web URL the app is created on.
GitHubURL string
}
Installer configures the GitHub App manifest installer.
type Okta ¶ added in v1.0.0
type Okta struct {
Enabled bool
Domain string
ClientID string
PrivateKey []byte
PrivateKeyID string
Scopes []string
BaseURL string
GitHubUserField string
SyncRules []domain.SyncRule
SyncSafetyThreshold float64
OrphanedUserNotifications bool
}
Okta configures Okta group sync.
type PRCompliance ¶ added in v1.0.0
type PRCompliance struct {
Enabled bool
// MonitoredBranches are branch names or glob patterns, such as
// "release/*".
MonitoredBranches []string
}
PRCompliance configures PR compliance monitoring.
type RedactedConfig ¶
type RedactedConfig struct {
LogLevel string `json:"log_level"`
BasePath string `json:"base_path"`
PublicURL string `json:"public_url"`
InstallerEnabled bool `json:"installer_enabled"`
AdminToken string `json:"admin_token"`
GitHubOrg string `json:"github_org"`
GitHubAppID int64 `json:"github_app_id"`
GitHubInstallationID int64 `json:"github_installation_id"`
GitHubAppPrivateKey string `json:"github_app_private_key"`
GitHubWebhookSecret string `json:"github_webhook_secret"`
GitHubBaseURL string `json:"github_base_url"`
PRComplianceEnabled bool `json:"pr_compliance_enabled"`
PRMonitoredBranches []string `json:"pr_monitored_branches"`
OktaEnabled bool `json:"okta_enabled"`
OktaDomain string `json:"okta_domain"`
OktaClientID string `json:"okta_client_id"`
OktaPrivateKey string `json:"okta_private_key"`
OktaPrivateKeyID string `json:"okta_private_key_id"`
OktaScopes []string `json:"okta_scopes"`
OktaGitHubUserField string `json:"okta_github_user_field"`
OktaSyncRules []domain.SyncRule `json:"okta_sync_rules"`
OktaSyncSafetyThreshold float64 `json:"okta_sync_safety_threshold"`
OktaOrphanedUserNotifications bool `json:"okta_orphaned_user_notifications"`
SecurityAlertsEnabled bool `json:"security_alerts_enabled"`
SecurityAlertsMinAgeDays int `json:"security_alerts_min_age_days"`
SecurityAlertsMinSeverity string `json:"security_alerts_min_severity"`
SlackEnabled bool `json:"slack_enabled"`
SlackToken string `json:"slack_token"`
SlackChannel string `json:"slack_channel"`
SlackChannelPRBypass string `json:"slack_channel_pr_bypass"`
SlackChannelOktaSync string `json:"slack_channel_okta_sync"`
SlackChannelOrphanedUsers string `json:"slack_channel_orphaned_users"`
SlackChannelSecurityAlerts string `json:"slack_channel_security_alerts"`
}
RedactedConfig is the configuration with secrets redacted, safe to log or return from the admin API.
type SecurityAlerts ¶ added in v1.0.0
SecurityAlerts configures stale security alert reports.
type Server ¶ added in v1.0.0
type Server struct {
// ListenAddr is the TCP address to listen on, such as ":8080".
ListenAddr string
// BasePath is the path every route is mounted under: empty, or a path
// with a leading slash and no trailing slash.
BasePath string
// PublicURL is the external URL of the service, including BasePath. It
// is used to build the installer's redirect and webhook URLs; when
// empty, they are derived from each request.
PublicURL string
}
Server configures the HTTP server.