Documentation
¶
Overview ¶
Package console serves the admin console HTTP API over live proxy state: telemetry from internal/telemetry, the runtime policy, registry config and cache stats. Authentication is enforced by the session middleware (auth.Sessions.Middleware) that cmd/jo-ei mounts in front of it at /api/.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewHandler ¶
NewHandler returns the console API handler; mount it at "/api/".
Types ¶
type CachePurger ¶ added in v0.2.0
type CachePurger interface {
PurgeStale(ctx context.Context) (removed int64, freedBytes int64, err error)
}
CachePurger deletes stale cache entries on demand; *cache.LocalCache satisfies it.
type CacheStatsProvider ¶
type CacheStatsProvider interface {
Stats() (cache.CacheStats, error)
}
CacheStatsProvider exposes cache statistics; cache.Cache satisfies it.
type Config ¶
type Config struct {
Store *telemetry.Store
Broadcaster *telemetry.Broadcaster
Policy *policy.Runtime
Cache CacheStatsProvider // optional; nil reports zero stats
CacheMaxBytes int64
// Purger enables POST /api/cache/cleanup; nil returns 404 there.
Purger CachePurger
// CacheStaleAfterDays is the effective idle threshold, echoed to the UI
// for the "unused Nd+" legend.
CacheStaleAfterDays int
Registries []RegistryInfo
// RegistryStore persists registry edits (PUT /api/registries). Nil keeps the
// screen read-only using the static Registries field.
RegistryStore RegistryStore
// RunningRegistries is the registry set the live proxy mux actually serves
// (captured at boot). GET/PUT report pending_restart when the stored set
// differs from this.
RunningRegistries []RegistryInfo
// ImageScanEnabled reports whether Trivy image-scanning is configured; when
// false, enabling the docker registry produces a warning (the docker handler
// is gated on image-scan at boot).
ImageScanEnabled bool
Health ScannerHealthProvider // optional; nil reports no scanners
// Users backs the /api/users routes; nil answers 503 users_unavailable.
Users UserAdmin
Logger zerolog.Logger
// SSEHeartbeat is the idle keep-alive interval for /api/events. With no
// traffic the stream is otherwise silent for hours and intermediaries
// (Docker port-forwards, AV web filters) drop the idle connection.
// Zero means the 25s default.
SSEHeartbeat time.Duration
}
Config wires the API to runtime state.
type RegistryInfo ¶
type RegistryInfo struct {
Ecosystem string `json:"eco"`
Enabled bool `json:"enabled"`
Upstreams []string `json:"upstreams"`
}
RegistryInfo describes one configured registry for GET /api/registries.
type RegistryStore ¶
type RegistryStore interface {
LoadRegistries() ([]RegistryInfo, bool, error)
SaveRegistries([]RegistryInfo) error
}
RegistryStore persists the editable registry set. Implemented in cmd/jo-ei by an adapter over *settings.Store. When nil, registries are read-only.
type ScannerHealthProvider ¶
type ScannerHealthProvider interface {
Snapshot() []health.ScannerHealth
}
ScannerHealthProvider supplies live scan-engine health for the overview. *health.Monitor satisfies it.
type UserAdmin ¶ added in v0.6.0
type UserAdmin interface {
List() ([]users.User, error)
Get(username string) (users.User, error)
Create(u users.User) error
SetRole(username string, r users.Role) error
SetDisabled(username string, disabled bool) error
SetPassword(username, hash string, mustChange bool) error
Delete(username string) error
}
UserAdmin is the user store surface the management API needs. *users.Store satisfies it.