app

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package app provides the core application logic for the GitHub bot. coordinates webhook processing, Okta sync, and PR compliance checks.

Package app provides unified request/response handling for all runtimes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type App

type App struct {
	Config       *config.Config
	Logger       *slog.Logger
	GitHubClient *github.Client
	OktaClient   *okta.Client
	Notifier     *notifiers.SlackNotifier
}

App is the main application instance containing all clients and configuration.

func New

func New(ctx context.Context, cfg *config.Config) (*App, error)

New creates a new App instance with configured clients. initializes GitHub, Okta, and Slack clients based on config.

func (*App) GetStatus

func (a *App) GetStatus() StatusResponse

GetStatus returns current application status and enabled features.

func (*App) HandleRequest added in v0.5.0

func (a *App) HandleRequest(ctx context.Context, req Request) Response

HandleRequest routes incoming requests to the appropriate handler. This is the single entry point for all request processing.

func (*App) ProcessScheduledEvent

func (a *App) ProcessScheduledEvent(ctx context.Context, evt ScheduledEvent) error

ProcessScheduledEvent handles scheduled events (e.g., cron jobs). routes to appropriate handlers based on event action.

func (*App) ProcessWebhook

func (a *App) ProcessWebhook(ctx context.Context, payload []byte, eventType string) error

ProcessWebhook handles incoming GitHub webhook events. supports pull_request, team, and membership events.

type Request added in v0.5.0

type Request struct {
	Type    RequestType       `json:"type"`
	Method  string            `json:"method,omitempty"`
	Path    string            `json:"path,omitempty"`
	Headers map[string]string `json:"headers,omitempty"`
	Body    []byte            `json:"body,omitempty"`

	// ScheduledAction is used for scheduled events (e.g., "okta-sync").
	ScheduledAction string `json:"scheduled_action,omitempty"`
	// ScheduledData contains optional payload for scheduled events.
	ScheduledData json.RawMessage `json:"scheduled_data,omitempty"`
}

Request is a unified request type that abstracts HTTP and scheduled events. Runtimes (server, lambda) convert their native formats to this type.

type RequestType added in v0.5.0

type RequestType string

RequestType identifies the category of incoming request.

const (
	// RequestTypeHTTP represents HTTP requests (webhooks, status, config).
	RequestTypeHTTP RequestType = "http"
	// RequestTypeScheduled represents scheduled/cron events.
	RequestTypeScheduled RequestType = "scheduled"
)

type Response added in v0.5.0

type Response struct {
	StatusCode  int               `json:"status_code"`
	Headers     map[string]string `json:"headers,omitempty"`
	Body        []byte            `json:"body,omitempty"`
	ContentType string            `json:"content_type,omitempty"`
}

Response is a unified response type returned by HandleRequest. Runtimes convert this to their native response format.

type ScheduledEvent

type ScheduledEvent struct {
	Action string          `json:"action"`
	Data   json.RawMessage `json:"data,omitempty"`
}

ScheduledEvent represents a generic scheduled event.

type StatusResponse

type StatusResponse struct {
	Status            string `json:"status"`
	GitHubConfigured  bool   `json:"github_configured"`
	OktaSyncEnabled   bool   `json:"okta_sync_enabled"`
	PRComplianceCheck bool   `json:"pr_compliance_check"`
	SlackEnabled      bool   `json:"slack_enabled"`
}

StatusResponse contains application status and feature flags.

Jump to

Keyboard shortcuts

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