daemon

package
v0.47.8 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2026 License: MIT Imports: 37 Imported by: 0

Documentation

Overview

Package daemon provides a long-running daemon for GitOps operations.

Package daemon provides a long-running daemon for GitOps operations.

Package daemon provides a long-running daemon for GitOps operations. It handles webhook reception, polling-based reconciliation, and health checks.

Package daemon provides a long-running daemon for GitOps operations.

Package daemon provides a long-running daemon for GitOps operations.

Index

Constants

View Source
const (
	StatusHealthy     = "healthy"
	StatusDegraded    = "degraded"
	StatusUnhealthy   = "unhealthy"
	StatusUnavailable = "unavailable"
	StatusClosed      = "closed"
	StatusOpen        = "open"
)

Status constants for subsystem health.

View Source
const (
	// DefaultDeliveryCacheSize bounds how many recent delivery IDs one server
	// remembers (#747). Each entry is a 32-byte digest plus list overhead.
	DefaultDeliveryCacheSize = 1024

	// DefaultDeliveryCacheTTL is how long a delivery ID is remembered. Provider
	// retries arrive within minutes; a replay after this window is processed.
	DefaultDeliveryCacheTTL = time.Hour
)
View Source
const DefaultDriftInterval = 5 * time.Minute

DefaultDriftInterval is the daemon's restart-count sampling cadence.

View Source
const DefaultMaxSelfHealAttempts = 3

DefaultMaxSelfHealAttempts bounds unattended remediation of one stable drift signature.

View Source
const DefaultReconcileMaxTimeout = 30 * time.Minute

DefaultConfig returns a Config with sensible defaults. DefaultReconcileMaxTimeout is the default hard cap on one reconcile cycle. It is three times the default cycle budget: 10m for the steps outside compose up plus about 20m of compose up, enough for a full run in which a few files pull large images (a 17-file full run exceeded a shared 10m budget in #727). Cleanup may run DefaultReconcileRollbackGrace past it, so a wedged cycle ends within 35 minutes.

View Source
const DefaultReconcileRollbackGrace = 5 * time.Minute

DefaultReconcileRollbackGrace is how far past the cycle cap's deadline backup extraction and rollbacks may run. Rollbacks re-apply known-good files whose images are already present, so they usually take seconds; 5m leaves room for several while still ending a wedged cycle within 35 minutes.

View Source
const DefaultSocketPath = "/var/run/bosun.sock"

DefaultSocketPath is the default path for the bosun daemon Unix socket.

Variables

This section is empty.

Functions

func InjectPeerCred

func InjectPeerCred(ctx context.Context, c net.Conn) context.Context

InjectPeerCred is a ConnContext function for http.Server that injects peer credentials.

func IsWebhookBodyKey added in v0.47.3

func IsWebhookBodyKey(key string) bool

IsWebhookBodyKey reports whether a key returned by WebhookReplayKeys is the body digest rather than the delivery ID.

func PushDeletesBranch added in v0.47.3

func PushDeletesBranch(body []byte) bool

PushDeletesBranch reports whether a push payload deletes its ref (#747): GitHub sets "deleted": true, and GitHub, GitLab, and Gitea send an "after" made only of zeros. A body that is not a JSON object, or whose fields have other types, is not a deletion.

func SanitizeWebhookPusherName added in v0.39.11

func SanitizeWebhookPusherName(name string) string

SanitizeWebhookPusherName strips characters that can create or visually rewrite log lines, then caps the remaining attribution in Unicode code points. Spaces and printable Unicode names remain unchanged. It is exported so the standalone webhook receiver applies the same boundary before forwarding attribution to the daemon.

func ShouldProcessGenericWebhook added in v0.46.2

func ShouldProcessGenericWebhook(githubEvent string, body []byte, trackingBranch string) (process bool, ref string, reason string)

ShouldProcessGenericWebhook decides whether an authorized generic webhook starts a reconcile. A GitHub event header other than push is ignored. A top-level "ref" in a JSON object body must name the tracked branch, using the same comparison as the GitHub endpoint; tags, other branches, and non-string values are ignored. A body without a ref (empty, not JSON, not an object, or no "ref" key) still triggers, so the endpoint stays usable as a plain signed trigger, unless the GitHub event header is set: a GitHub push always has a ref, so one without a readable ref is ignored. An empty trackingBranch means the caller does not know the branch (the standalone receiver without configuration): only the event filter applies. The returned ref is the raw value for logging; callers must sanitize it, and reason may embed it unsanitized. Shared by the daemon's /webhook and the standalone receiver's.

func ShouldProcessPushRef added in v0.46.3

func ShouldProcessPushRef(ref string, trackingBranch string) (process bool, reason string)

ShouldProcessPushRef decides whether an authorized provider push event (GitHub, GitLab, or Gitea, whose payloads carry a full `ref`) targets the tracked branch. It uses the GitHub endpoint's comparison: only refs/heads/<trackingBranch> passes, so other branches, tags, and bare branch names are ignored. A push event without a ref is ignored too, because its branch is unknown. An empty trackingBranch means the caller does not know the branch (the standalone receiver without configuration): every push passes. reason may embed ref unsanitized; callers must sanitize it before logging.

func ValidateConfig

func ValidateConfig(cfg *Config) error

ValidateConfig validates the daemon configuration.

func WebhookBodyKey added in v0.47.3

func WebhookBodyKey(body []byte) string

WebhookBodyKey returns the replay key for an authorized request body: its SHA-256 in a namespace separate from delivery IDs. The delivery headers are not signed, so a captured body re-sent with a fresh delivery ID still matches this key. An empty body returns "": it carries no event, so the plain signed trigger (an empty body sent repeatedly) keeps working.

func WebhookDeliveryID added in v0.47.3

func WebhookDeliveryID(h http.Header) string

WebhookDeliveryID returns the request's delivery ID for replay detection, prefixed with the header it came from, or "" when no delivery header is set. The value is attacker-controlled; callers must sanitize it before logging.

func WebhookReplayKeys added in v0.47.3

func WebhookReplayKeys(h http.Header, body []byte) []string

WebhookReplayKeys returns the request's replay keys: its delivery ID and its body digest. Either may be "".

func WrapServerForPeerCred

func WrapServerForPeerCred(srv *http.Server, listener net.Listener) net.Listener

WrapServerForPeerCred configures the HTTP server to use peer credentials.

func WriteBranchDeleteIgnored added in v0.47.3

func WriteBranchDeleteIgnored(w http.ResponseWriter, r *http.Request, provider, ref string)

WriteBranchDeleteIgnored answers an authorized push that deletes its branch (#747): 200 so the provider does not retry, a warn log because deleting the deploy branch is unusual, and no reconcile. Shared with the standalone receiver.

func WriteDuplicateDeliveryIgnored added in v0.47.3

func WriteDuplicateDeliveryIgnored(w http.ResponseWriter, r *http.Request, matched string)

WriteDuplicateDeliveryIgnored answers an authorized request whose delivery ID or body was already handled (#747): 200 so the provider does not retry, a warn log because an unexpected repeat may be a replay, and no reconcile. matched is the replay key that hit (from DeliveryCache.ClaimMatch); the log names it as match=delivery (with the ID) or match=body. Shared with the standalone receiver.

Types

type APIContainerResponse added in v0.2.10

type APIContainerResponse struct {
	ID      string   `json:"id"`
	Name    string   `json:"name"`
	Image   string   `json:"image"`
	State   string   `json:"state"`
	Status  string   `json:"status"`
	Health  string   `json:"health,omitempty"`
	Created string   `json:"created"`
	Ports   []string `json:"ports,omitempty"`
}

APIContainerResponse represents a container in the API response.

type APIContainersResponse added in v0.2.10

type APIContainersResponse struct {
	Containers []APIContainerResponse `json:"containers"`
	Summary    ContainerSummary       `json:"summary"`
}

APIContainersResponse is the response for the containers list endpoint.

type APIDriftItem added in v0.3.0

type APIDriftItem struct {
	Service  string `json:"service"`
	Type     string `json:"type"`
	Declared string `json:"declared,omitempty"`
	Actual   string `json:"actual,omitempty"`
}

APIDriftItem represents a single drift item in the API response.

type APIDriftResponse added in v0.3.0

type APIDriftResponse struct {
	Status         string         `json:"status"`
	CheckedAt      *time.Time     `json:"checked_at,omitempty"`
	DeclaredCount  int            `json:"declared_count"`
	DriftItemCount int            `json:"drift_item_count"`
	Items          []APIDriftItem `json:"items"`
}

APIDriftResponse is the response for the drift status endpoint.

type APILogsResponse added in v0.2.10

type APILogsResponse struct {
	Container string `json:"container"`
	Lines     int    `json:"lines"`
	Logs      string `json:"logs"`
}

APILogsResponse is the response for the container logs endpoint.

type APIRestartResponse added in v0.2.10

type APIRestartResponse struct {
	Status    string `json:"status"`
	Container string `json:"container"`
	Message   string `json:"message"`
}

APIRestartResponse is the response for the container restart endpoint.

type APIStatusResponse added in v0.2.10

type APIStatusResponse struct {
	Health        string               `json:"health"`
	State         string               `json:"state"`
	Uptime        string               `json:"uptime"`
	UptimeSeconds int64                `json:"uptime_seconds"`
	LastReconcile *time.Time           `json:"last_reconcile,omitempty"`
	LastError     string               `json:"last_error,omitempty"`
	NextPoll      *time.Time           `json:"next_poll,omitempty"`
	PollInterval  int                  `json:"poll_interval,omitempty"`
	Targets       []TargetHealthStatus `json:"targets,omitempty"`
}

APIStatusResponse is the extended status response for the WebUI API.

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client communicates with the bosun daemon over Unix socket or TCP.

func NewClient

func NewClient(socketPath string) *Client

NewClient creates a new daemon client using Unix socket.

func NewTCPClient

func NewTCPClient(addr, bearerToken string) *Client

NewTCPClient creates a new daemon client using TCP with bearer token auth.

func (*Client) Config

func (c *Client) Config(ctx context.Context) (*ConfigResponse, error)

Config fetches configuration from the daemon. This is used for daemon-injected secrets - the webhook container fetches secrets from the daemon rather than storing them on disk. Note: This endpoint is only available over Unix socket, not TCP (for security).

func (*Client) Health

func (c *Client) Health(ctx context.Context) (*HealthResponse, error)

Health checks the daemon's bounded public liveness response.

func (*Client) Ping

func (c *Client) Ping(ctx context.Context) error

Ping checks if the daemon is reachable.

func (*Client) Status

func (c *Client) Status(ctx context.Context) (*StatusResponse, error)

Status gets the current status from the daemon.

func (*Client) Trigger

func (c *Client) Trigger(ctx context.Context, source string, force bool) (*TriggerResponse, error)

Trigger sends a trigger request to the daemon.

type Config

type Config struct {
	// Socket API settings (primary)
	SocketPath        string      // Path to Unix socket (default: /var/run/bosun.sock)
	SocketMode        os.FileMode // Socket file permissions (default: 0660)
	SocketAllowedUIDs []uint32    // Additional UIDs allowed to mutate through the socket

	// AllowUnauthenticatedSocket opts out of fail-closed peer-credential auth.
	// This is intentionally separate from SocketMode: the mode grants access to
	// connect, while peer credentials authorize mutating requests.
	AllowUnauthenticatedSocket bool

	// TCP API settings (optional, for remote access)
	EnableTCP   bool   // Enable TCP listener (default: false)
	TCPAddr     string // TCP address to listen on (default: 127.0.0.1:9090)
	BearerToken string // Bearer token for TCP authentication (required if EnableTCP)

	// HTTP server settings (for webhooks, kept for backwards compatibility)
	Port          int    // HTTP port for webhooks and health (default: 8080)
	EnableHTTP    bool   // Enable HTTP server (default: true for backwards compat)
	WebhookPath   string // Path for webhook endpoint (default: /webhook)
	HealthPath    string // Path for health endpoint (default: /health)
	ReadyPath     string // Path for readiness endpoint (default: /ready)
	WebhookSecret string // Secret for validating webhook signatures

	// ListenAddr is the host/IP the HTTP server binds to (BOSUN_LISTEN_ADDR).
	// Empty binds all interfaces — the default MUST stay all-interfaces
	// because container-side callers (Traefik, Prometheus, Homepage) reach
	// bosun over the docker bridge, not loopback.
	ListenAddr string

	// TrustedProxies is the parsed allowlist of proxies whose X-Forwarded-For
	// header the request log will record, in a field kept separate from the
	// observed peer address. Nil or empty trusts nothing, which is the default
	// and the direction this control must fail: ListenAddr binds all
	// interfaces, so any reachable host can send a well-formed header.
	TrustedProxies *trustedProxies

	// AllowUnauthenticatedWebhook opts out of fail-closed webhook auth (#345).
	// When WebhookSecret is empty, trigger endpoints reject every request
	// unless this is true (BOSUN_ALLOW_UNAUTHENTICATED_WEBHOOK=true, strict match).
	AllowUnauthenticatedWebhook bool

	// MetricsToken is a read-scope credential for /metrics and /api/widget
	// (BOSUN_METRICS_TOKEN). It is SEPARATE from BearerToken: the TCP bearer
	// also authorizes /trigger and /api/restart (control operations), so a
	// metrics scraper must never need it. The control bearer, being strictly
	// more privileged, is also accepted on these read endpoints.
	MetricsToken string

	// AllowUnauthenticatedMetrics opts out of fail-closed metrics auth (#296).
	// When both MetricsToken and BearerToken are empty, /metrics and /api/widget
	// reject every request unless this is true (BOSUN_ALLOW_UNAUTHENTICATED_METRICS=true,
	// strict match). A loud opt-out: logged at startup and per accepted request.
	AllowUnauthenticatedMetrics bool

	// Polling settings
	PollInterval time.Duration // Interval between polls (0 disables polling)
	InitialDelay time.Duration // Delay before first poll (default: 10s)

	// Reconcile settings
	ReconcileConfig *reconcile.Config
	// ProjectNameFromFile is the local bosun.yaml root-level project_name,
	// retained for startup posture reporting. It never changes the effective
	// per-target deployment or restart-breaker namespace.
	ProjectNameFromFile string

	// Timeout settings
	ReconcileTimeout time.Duration // Cycle budget for a reconcile operation; paused during isolated compose up (default: 10m)
	// ReconcileMaxTimeout is the hard cap on one reconcile cycle's wall-clock
	// time, compose up included (default: 30m). Values below ReconcileTimeout
	// are raised to it.
	ReconcileMaxTimeout time.Duration
	// ReconcileRollbackGrace extends the cap for cleanup only (default: 5m):
	// every backup extraction and rollback in a cycle, started before or after
	// the cap fires, ends by the cap's deadline plus this grace. A cycle's worst
	// case is ReconcileMaxTimeout + ReconcileRollbackGrace.
	ReconcileRollbackGrace time.Duration
	ShutdownTimeout        time.Duration // Max time for graceful shutdown (default: 30s)
	APITimeout             time.Duration // Timeout for API handler requests (default: 30s)

	// Drift check settings
	DriftInterval         time.Duration                        // Interval for periodic drift checks (0 disables, default: 5m)
	DriftAlertCooldown    time.Duration                        // Cooldown between repeated drift alerts per item (default: 1h)
	DriftAlertDebounce    reconcile.ConfigField[time.Duration] // Debounce window before first drift alert fires (0 = disabled, default: 0)
	DriftResolveAlerts    bool                                 // Send "drift resolved" alerts (default: true)
	DriftSelfHeal         reconcile.ConfigField[bool]          // Trigger reconciliation when drift detected (default: false)
	DriftSelfHealCooldown reconcile.ConfigField[time.Duration] // Minimum interval between self-heal reconciliations (default: 15m)
	MaxSelfHealAttempts   int                                  // Maximum attempts for one stable drift signature (default: 3)

	// Content-hash sync settings
	ContentHashSync bool // Compare file hashes before writing (default: true)

	// Orphan container cleanup settings
	RemoveOrphans bool // Pass --remove-orphans to docker compose up (default: true)

	// Alerting
	AlertManager *alert.Manager

	// Version is the bosun version string (set by caller from build-time ldflags).
	Version string
	// contains filtered or unexported fields
}

Config holds daemon configuration.

func ConfigFromEnv

func ConfigFromEnv() *Config

ConfigFromEnv loads daemon configuration from environment variables.

func DefaultConfig

func DefaultConfig() *Config

type ConfigResponse

type ConfigResponse struct {
	WebhookSecret string `json:"webhook_secret,omitempty"`
	PollInterval  int    `json:"poll_interval,omitempty"`
	RepoURL       string `json:"repo_url,omitempty"`
	RepoBranch    string `json:"repo_branch,omitempty"`
}

ConfigResponse is the response body for /config. This allows the webhook container to fetch secrets from the daemon without storing them on disk. WebhookSecret is a credential: /config is peer-authorized like /trigger, and buildConfigResponse only fills the field when its caller asks for it.

type ContainerSummary added in v0.2.10

type ContainerSummary struct {
	Total     int `json:"total"`
	Running   int `json:"running"`
	Stopped   int `json:"stopped"`
	Unhealthy int `json:"unhealthy"`
}

ContainerSummary provides aggregate container stats.

type Daemon

type Daemon struct {
	// contains filtered or unexported fields
}

Daemon is the main GitOps daemon that handles webhooks and polling.

func New

func New(cfg *Config) (*Daemon, error)

New creates a new Daemon with the given configuration.

func (*Daemon) DockerClient added in v0.3.0

func (d *Daemon) DockerClient() (*docker.Client, error)

DockerClient returns the shared Docker client, creating it on first use.

func (*Daemon) HealthStatus

func (d *Daemon) HealthStatus() HealthStatus

HealthStatus returns the daemon health status with subsystem breakdown.

func (*Daemon) IsReady

func (d *Daemon) IsReady() bool

IsReady returns whether the daemon is ready to serve requests.

func (*Daemon) LastReconcile

func (d *Daemon) LastReconcile() (time.Time, error)

LastReconcile returns the time of the last reconciliation and any error.

func (*Daemon) RegisterAPIRoutes added in v0.2.10

func (d *Daemon) RegisterAPIRoutes(mux *http.ServeMux)

RegisterAPIRoutes registers the WebUI API routes on an http.ServeMux.

func (*Daemon) Run

func (d *Daemon) Run(ctx context.Context) (err error)

Run starts the daemon and blocks until shutdown. It handles SIGTERM and SIGINT for graceful shutdown.

func (*Daemon) TriggerReconcile

func (d *Daemon) TriggerReconcile(ctx context.Context, source string, force bool) error

TriggerReconcile triggers a reconciliation run. If a reconcile is already in progress, it queues source/force metadata and returns immediately. All triggers in the batch contribute to the next run; force remains sticky if any queued trigger requests it.

func (*Daemon) WidgetData added in v0.5.0

func (d *Daemon) WidgetData() map[string]any

WidgetData returns lightweight stats for Homepage's customapi widget. Response is flat JSON with max 4 fields per Homepage block display limits.

type DeliveryCache added in v0.47.3

type DeliveryCache struct {
	// contains filtered or unexported fields
}

DeliveryCache remembers recent webhook replay keys (delivery IDs and body digests) so a repeated delivery is not acted on twice (#747). It is bounded: at most capacity entries, each forgotten after ttl, oldest dropped first when full. Keys are SHA-256 digests, so memory does not depend on header length. The zero value is ready to use with DefaultDeliveryCacheSize and DefaultDeliveryCacheTTL. Safe for concurrent use.

func NewDeliveryCache added in v0.47.3

func NewDeliveryCache(capacity int, ttl time.Duration) *DeliveryCache

NewDeliveryCache returns a cache with the given bounds. A non-positive capacity or ttl falls back to the default.

func (*DeliveryCache) Claim added in v0.47.3

func (c *DeliveryCache) Claim(ids ...string) bool

Claim records every non-empty key and returns true when none was seen within the TTL. It returns false for a repeat of any key, which the caller should ignore, and then records nothing. Empty keys (no delivery header, an empty body) are skipped; with no keys left it always returns true.

func (*DeliveryCache) ClaimMatch added in v0.47.3

func (c *DeliveryCache) ClaimMatch(ids ...string) (matched string, ok bool)

ClaimMatch is Claim that also returns, on a repeat, the first given id that was already recorded, so the caller can log which key matched.

func (*DeliveryCache) Release added in v0.47.3

func (c *DeliveryCache) Release(ids ...string)

Release forgets every given key, so a provider retry after a failed forward is processed.

func (*DeliveryCache) Seen added in v0.47.3

func (c *DeliveryCache) Seen(id string) bool

Seen reports whether id was recorded within the TTL, without recording it or changing the cache. An empty id is never seen.

type GitHubPushPayload

type GitHubPushPayload struct {
	Ref    string `json:"ref"`
	Before string `json:"before"`
	After  string `json:"after"`
	Pusher struct {
		Name  string `json:"name"`
		Email string `json:"email"`
	} `json:"pusher"`
	HeadCommit struct {
		ID      string `json:"id"`
		Message string `json:"message"`
		Author  struct {
			Name  string `json:"name"`
			Email string `json:"email"`
		} `json:"author"`
	} `json:"head_commit"`
	Repository struct {
		FullName string `json:"full_name"`
		CloneURL string `json:"clone_url"`
		SSHURL   string `json:"ssh_url"`
	} `json:"repository"`
}

GitHubPushPayload represents a GitHub push webhook payload.

type HealthResponse added in v0.40.6

type HealthResponse struct {
	Status string        `json:"status"`
	Ready  bool          `json:"ready"`
	Uptime time.Duration `json:"uptime"`
}

HealthResponse is the bounded public liveness response returned by /health. Detailed reconcile and subsystem diagnostics belong on /status and in logs.

type HealthStatus

type HealthStatus struct {
	Status        string                     `json:"status"`
	Ready         bool                       `json:"ready"`
	LastReconcile time.Time                  `json:"last_reconcile,omitempty"`
	LastError     string                     `json:"last_error,omitempty"`
	Uptime        time.Duration              `json:"uptime"`
	Subsystems    map[string]SubsystemStatus `json:"subsystems"`
	Targets       []TargetHealthStatus       `json:"targets,omitempty"`
}

HealthStatus represents the daemon health with subsystem breakdown.

type Metrics added in v0.21.0

type Metrics struct {
	// Reconciliation counters
	ReconcileTotal   *prometheus.CounterVec
	ReconcileSeconds *prometheus.HistogramVec

	// Webhook trigger counter
	WebhookTriggersTotal *prometheus.CounterVec

	// Drift check counter
	DriftChecksTotal *prometheus.CounterVec

	// Gauges for current state
	Ready               prometheus.Gauge
	UptimeSeconds       prometheus.Gauge
	LastReconcileTime   prometheus.Gauge
	LastReconcileErrors prometheus.Gauge
}

Metrics holds all Prometheus metrics for the bosun daemon.

func (*Metrics) RecordDriftCheck added in v0.21.0

func (m *Metrics) RecordDriftCheck(hasDrift bool)

RecordDriftCheck records a drift check result.

func (*Metrics) RecordReconcileFailure added in v0.21.0

func (m *Metrics) RecordReconcileFailure(durationSeconds float64)

RecordReconcileFailure records a failed reconciliation with its duration.

func (*Metrics) RecordReconcileSuccess added in v0.21.0

func (m *Metrics) RecordReconcileSuccess(durationSeconds float64)

RecordReconcileSuccess records a successful reconciliation with its duration.

func (*Metrics) RecordWebhookTrigger added in v0.21.0

func (m *Metrics) RecordWebhookTrigger(source string)

RecordWebhookTrigger records a webhook trigger by source.

func (*Metrics) SetLastReconcileTime added in v0.21.0

func (m *Metrics) SetLastReconcileTime(unixTimestamp float64)

SetLastReconcileTime updates the last reconcile timestamp gauge.

func (*Metrics) SetReady added in v0.21.0

func (m *Metrics) SetReady(ready bool)

SetReady updates the ready gauge.

func (*Metrics) SetUptime added in v0.21.0

func (m *Metrics) SetUptime(seconds float64)

SetUptime updates the uptime gauge.

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server handles HTTP requests for webhooks and health checks.

func NewServer

func NewServer(d *Daemon) *Server

NewServer creates a new HTTP server for the daemon.

func (*Server) Shutdown

func (s *Server) Shutdown(ctx context.Context) error

Shutdown gracefully shuts down the HTTP server. Waits for in-flight reconciliation goroutines to complete.

func (*Server) Start

func (s *Server) Start(port int) error

Start starts the HTTP server on the given port, bound to the configured listen address (all interfaces when unset).

type SocketConfig

type SocketConfig struct {
	SocketPath                   string      // Path to Unix socket (e.g., /var/run/bosun.sock)
	SocketMode                   os.FileMode // Socket file permissions (default: 0660)
	AllowedUIDs                  []uint32    // Additional UIDs allowed to mutate through the socket
	AllowUnauthenticatedMutation bool        // Explicitly disable peer-credential auth
}

SocketConfig holds socket server configuration.

func DefaultSocketConfig

func DefaultSocketConfig() *SocketConfig

DefaultSocketConfig returns default socket configuration.

type SocketServer

type SocketServer struct {
	// contains filtered or unexported fields
}

SocketServer handles Unix socket connections for the trigger API.

func NewSocketServer

func NewSocketServer(d *Daemon, cfg *SocketConfig) (*SocketServer, error)

NewSocketServer creates a new Unix socket server.

func (*SocketServer) Shutdown

func (s *SocketServer) Shutdown(ctx context.Context) error

Shutdown gracefully shuts down the socket server.

func (*SocketServer) Start

func (s *SocketServer) Start() (err error)

Start starts the Unix socket server.

type StatusResponse

type StatusResponse struct {
	State         string               `json:"state"` // idle, reconciling
	LastReconcile *time.Time           `json:"last_reconcile,omitempty"`
	LastCommit    string               `json:"last_commit,omitempty"`
	LastError     string               `json:"last_error,omitempty"`
	Uptime        string               `json:"uptime"`
	Targets       []TargetHealthStatus `json:"targets,omitempty"`
}

StatusResponse is the response body for /status.

type SubsystemStatus added in v0.24.0

type SubsystemStatus struct {
	Status   string `json:"status"`
	Message  string `json:"message,omitempty"`
	LastRun  string `json:"last_run,omitempty"`
	Failures int    `json:"failures,omitempty"`
}

SubsystemStatus represents the health of an individual subsystem.

type TCPServer

type TCPServer struct {
	// contains filtered or unexported fields
}

TCPServer handles TCP connections with bearer token authentication. This allows remote access to the daemon API for trusted clients.

func NewTCPServer

func NewTCPServer(d *Daemon, addr, bearerToken string) (*TCPServer, error)

NewTCPServer creates a new TCP server with bearer token auth.

func (*TCPServer) Shutdown

func (s *TCPServer) Shutdown(ctx context.Context) error

Shutdown gracefully shuts down the TCP server.

func (*TCPServer) Start

func (s *TCPServer) Start() error

Start starts the TCP server.

type TargetDriftStatus added in v0.44.3

type TargetDriftStatus struct {
	Status    string    `json:"status"`
	CheckedAt time.Time `json:"checked_at,omitempty"`
	Items     int       `json:"items,omitempty"`
	Message   string    `json:"message,omitempty"`
}

TargetDriftStatus is the bounded drift summary exposed by detailed operator status views. It contains no paths, repository URLs, or raw Docker errors.

type TargetHealthStatus added in v0.44.3

type TargetHealthStatus struct {
	Name               string            `json:"name"`
	Status             string            `json:"status"`
	LastDeployedCommit string            `json:"last_deployed_commit,omitempty"`
	DeployedAt         time.Time         `json:"deployed_at,omitempty"`
	Drift              TargetDriftStatus `json:"drift"`
	CircuitBreaker     SubsystemStatus   `json:"circuit_breaker"`
	Message            string            `json:"message,omitempty"`
}

TargetHealthStatus is the per-target portion of detailed daemon status. Targets are emitted in startup configuration order.

type TriggerRequest

type TriggerRequest struct {
	Source string `json:"source,omitempty"` // Source of trigger (e.g., "github", "manual")
	Force  bool   `json:"force,omitempty"`  // Force full pipeline execution regardless of state
}

TriggerRequest is the request body for /trigger.

type TriggerResponse

type TriggerResponse struct {
	Status  string `json:"status"`
	Message string `json:"message"`
}

TriggerResponse is the response body for /trigger.

Jump to

Keyboard shortcuts

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