{"modulePath":"github.com/cruxstack/github-ops-app","version":"v1.1.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package app\n\nPackage 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.\n\n## Constants\n\n```go\nconst (\n\tActionOktaSync       = \"okta-sync\"\n\tActionSecurityAlerts = \"security-alerts\"\n\tActionSlackTest      = \"slack-test\"\n)\n```\nScheduled actions.\n\n```go\nconst JobTimeout = 10 * time.Minute\n```\nJobTimeout bounds a sync or report, and a queued follow-up sync.\n\n## Types\n\n```go\ntype App struct {\n\t// contains filtered or unexported fields\n}\n```\nApp is the configured application. It is safe for concurrent use.\n\n```go\nfunc New(cfg *config.Config, logger *slog.Logger, opts ...Option) (*App, error)\n```\nNew builds the application. It makes no network calls, so it fails only on invalid configuration.\n\n```go\nfunc (a *App) Config() *config.Config\n```\nConfig returns the application's configuration.\n\n```go\nfunc (a *App) Handler() http.Handler\n```\nHandler returns the application's HTTP handler.\n\n```go\nfunc (a *App) RunJob(ctx context.Context, job Job) error\n```\nRunJob 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.\n\n```go\nfunc (a *App) RunScheduled(ctx context.Context, action string) error\n```\nRunScheduled runs a scheduled action. Callers authenticate the request first: the HTTP endpoint requires the admin token, and EventBridge invocations are authorized by AWS.\n\n```go\nfunc (a *App) Status() Status\n```\nStatus returns the application's status.\n\n```go\ntype Background interface {\n\tGo(f func(ctx context.Context))\n}\n```\nBackground runs work after the response to a request is sent, with a context of its own.\n\n```go\ntype Dispatcher func(ctx context.Context, job Job) error\n```\nDispatcher starts a job outside the request that asked for it, such as in another Lambda invocation.\n\n```go\ntype Job struct {\n\tAction string `json:\"action\"`\n\t// SlackUser is the Slack user ID of who asked.\n\tSlackUser string `json:\"slack_user,omitempty\"`\n\t// ResponseURL is where the result goes, as a reply only that user sees.\n\tResponseURL string `json:\"response_url,omitempty\"`\n}\n```\nJob is an action someone asked for in Slack. It runs after Slack gets its response, since Slack waits only three seconds for one.\n\n```go\ntype Option func(*deps)\n```\nOption replaces a dependency that New would otherwise build.\n\n```go\nfunc WithBackground(b Background) Option\n```\nWithBackground runs webhook-triggered syncs in the background, so the webhook is answered at once. Without it they run before responding, as Lambda requires.\n\n```go\nfunc WithClock(now func() time.Time) Option\n```\nWithClock replaces the clock, for tests.\n\n```go\nfunc WithDispatcher(dispatch Dispatcher) Option\n```\nWithDispatcher 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.\n\n```go\nfunc WithGitHubClient(c domain.GitHubClient) Option\n```\nWithGitHubClient replaces the GitHub client.\n\n```go\nfunc WithHTTPClient(c *http.Client) Option\n```\nWithHTTPClient sets the HTTP client every API client sends requests with.\n\n```go\nfunc WithNotifier(n domain.Notifier) Option\n```\nWithNotifier replaces the Slack notifier.\n\n```go\nfunc WithOktaClient(c domain.OktaClient) Option\n```\nWithOktaClient replaces the Okta client.\n\n```go\nfunc WithStateStore(s domain.StateStore) Option\n```\nWithStateStore replaces the store that remembers what each report last posted.\n\n```go\ntype Status struct {\n\tStatus                string `json:\"status\"`\n\tGitHubOrg             string `json:\"github_org\"`\n\tOktaSyncEnabled       bool   `json:\"okta_sync_enabled\"`\n\tPRComplianceEnabled   bool   `json:\"pr_compliance_enabled\"`\n\tSecurityAlertsEnabled bool   `json:\"security_alerts_enabled\"`\n\tSlackEnabled          bool   `json:\"slack_enabled\"`\n\tSlackCommandsEnabled  bool   `json:\"slack_commands_enabled\"`\n\tReportRepeat          string `json:\"report_repeat\"`\n}\n```\nStatus describes the application and its enabled features.\n\n```go\ntype WebhookResult string\n```\nWebhookResult says what was done with a webhook.\n\n```go\nconst (\n\tWebhookProcessed WebhookResult = \"processed\"\n\tWebhookQueued    WebhookResult = \"queued\"\n\tWebhookIgnored   WebhookResult = \"ignored\"\n\tWebhookPong      WebhookResult = \"pong\"\n)\n```\nWebhook results.\n\n","path":"github.com/cruxstack/github-ops-app/internal/app","name":"app","synopsis":"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.","isRedistributable":true}
