app

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 30, 2026 License: MIT Imports: 27 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
const (
	ActionOktaSync       = "okta-sync"
	ActionSecurityAlerts = "security-alerts"
	ActionSlackTest      = "slack-test"
)

Scheduled actions.

View Source
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

func New(cfg *config.Config, logger *slog.Logger, opts ...Option) (*App, error)

New builds the application. It makes no network calls, so it fails only on invalid configuration.

func (*App) Config

func (a *App) Config() *config.Config

Config returns the application's configuration.

func (*App) Handler added in v0.21.0

func (a *App) Handler() http.Handler

Handler returns the application's HTTP handler.

func (*App) RunJob added in v1.1.0

func (a *App) RunJob(ctx context.Context, job Job) error

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

func (a *App) RunScheduled(ctx context.Context, action string) error

RunScheduled runs a scheduled action. Callers authenticate the request first: the HTTP endpoint requires the admin token, and EventBridge invocations are authorized by AWS.

func (*App) Status added in v1.0.0

func (a *App) Status() Status

Status returns the application's status.

type Background added in v1.0.0

type Background interface {
	Go(f func(ctx context.Context))
}

Background runs work after the response to a request is sent, with a context of its own.

type Dispatcher added in v1.1.0

type Dispatcher func(ctx context.Context, job Job) error

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 WithClock added in v1.1.0

func WithClock(now func() time.Time) Option

WithClock replaces the clock, for tests.

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

func WithHTTPClient(c *http.Client) Option

WithHTTPClient sets the HTTP client every API client sends requests with.

func WithNotifier added in v1.0.0

func WithNotifier(n domain.Notifier) Option

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL