Documentation
¶
Overview ¶
Package app is the application: it builds the GitHub, Okta, and Slack clients from the configuration, serves the webhook, admin, and scheduled endpoints, and runs the Okta sync, PR compliance, and security alert features.
Index ¶
- Constants
- type App
- type Background
- type Dispatcher
- type Job
- type Option
- func WithBackground(b Background) Option
- func WithClock(now func() time.Time) Option
- func WithDispatcher(dispatch Dispatcher) Option
- func WithGitHubClient(c domain.GitHubClient) Option
- func WithHTTPClient(c *http.Client) Option
- func WithNotifier(n domain.Notifier) Option
- func WithOktaClient(c domain.OktaClient) Option
- func WithStateStore(s domain.StateStore) Option
- type Status
- type WebhookResult
Constants ¶
const ( ActionOktaSync = "okta-sync" ActionSecurityAlerts = "security-alerts" ActionSlackTest = "slack-test" )
Scheduled actions.
const JobTimeout = 10 * time.Minute
JobTimeout bounds a sync or report, and a queued follow-up sync.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type App ¶
type App struct {
// contains filtered or unexported fields
}
App is the configured application. It is safe for concurrent use.
func New ¶
New builds the application. It makes no network calls, so it fails only on invalid configuration.
func (*App) RunJob ¶ added in v1.1.0
RunJob runs a job started from Slack, posts its report whether or not it changed, and replies to who asked. The reply leaves out error details, which are returned and logged instead.
func (*App) RunScheduled ¶ added in v1.0.0
RunScheduled runs a scheduled action. Callers authenticate the request first: the HTTP endpoint requires the admin token, and EventBridge invocations are authorized by AWS.
type Background ¶ added in v1.0.0
Background runs work after the response to a request is sent, with a context of its own.
type Dispatcher ¶ added in v1.1.0
Dispatcher starts a job outside the request that asked for it, such as in another Lambda invocation.
type Job ¶ added in v1.1.0
type Job struct {
Action string `json:"action"`
// SlackUser is the Slack user ID of who asked.
SlackUser string `json:"slack_user,omitempty"`
// ResponseURL is where the result goes, as a reply only that user sees.
ResponseURL string `json:"response_url,omitempty"`
}
Job is an action someone asked for in Slack. It runs after Slack gets its response, since Slack waits only three seconds for one.
type Option ¶ added in v1.0.0
type Option func(*deps)
Option replaces a dependency that New would otherwise build.
func WithBackground ¶ added in v1.0.0
func WithBackground(b Background) Option
WithBackground runs webhook-triggered syncs in the background, so the webhook is answered at once. Without it they run before responding, as Lambda requires.
func WithDispatcher ¶ added in v1.1.0
func WithDispatcher(dispatch Dispatcher) Option
WithDispatcher runs jobs started from Slack with d, such as in another Lambda invocation. Without it they run in the Background, or, without that, before the response.
func WithGitHubClient ¶ added in v1.0.0
func WithGitHubClient(c domain.GitHubClient) Option
WithGitHubClient replaces the GitHub client.
func WithHTTPClient ¶ added in v1.0.0
WithHTTPClient sets the HTTP client every API client sends requests with.
func WithNotifier ¶ added in v1.0.0
WithNotifier replaces the Slack notifier.
func WithOktaClient ¶ added in v1.0.0
func WithOktaClient(c domain.OktaClient) Option
WithOktaClient replaces the Okta client.
func WithStateStore ¶ added in v1.1.0
func WithStateStore(s domain.StateStore) Option
WithStateStore replaces the store that remembers what each report last posted.
type Status ¶ added in v1.0.0
type Status struct {
Status string `json:"status"`
GitHubOrg string `json:"github_org"`
OktaSyncEnabled bool `json:"okta_sync_enabled"`
PRComplianceEnabled bool `json:"pr_compliance_enabled"`
SecurityAlertsEnabled bool `json:"security_alerts_enabled"`
SlackEnabled bool `json:"slack_enabled"`
SlackCommandsEnabled bool `json:"slack_commands_enabled"`
ReportRepeat string `json:"report_repeat"`
}
Status describes the application and its enabled features.
type WebhookResult ¶ added in v1.0.0
type WebhookResult string
WebhookResult says what was done with a webhook.
const ( WebhookProcessed WebhookResult = "processed" WebhookQueued WebhookResult = "queued" WebhookIgnored WebhookResult = "ignored" WebhookPong WebhookResult = "pong" )
Webhook results.