api

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2026 License: Apache-2.0 Imports: 78 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 api is the controller's public HTTP API (§5.1). The dashboard, synctl and CI all use these same endpoints; there are no UI-only routes.

Index

Constants

View Source
const (
	CredSession   = "session"
	CredToken     = "token"
	CredAccessKey = "access_key"
	// CredRole is an assumed role (sts); CredTemporary a device-login or
	// Cloud Shell credential acting as the user.
	CredRole      = "role_session"
	CredTemporary = "temporary"
)

Credential types a request can authenticate with (§7.1).

View Source
const (
	CodeBadRequest    = "bad_request"
	CodeUnauthorized  = "unauthorized"
	CodeForbidden     = "forbidden"
	CodeNotFound      = "not_found"
	CodeConflict      = "conflict"
	CodeRateLimited   = "rate_limited"
	CodeInternal      = "internal"
	CodeInvalidOrigin = "invalid_origin"
	CodeMFARequired   = "mfa_required"
	CodeQuotaExceeded = "quota_exceeded"
	// CodeLocked: the environment's deploys are locked (Phase 15d).
	CodeLocked = "locked"
)

Error codes returned in {"error": {"code": …}}. Clients switch on these, not on messages.

View Source
const HeaderSessionToken = "X-Syncloud-Session-Token"

HeaderSessionToken carries the session token of temporary credentials.

View Source
const SettingRequireMFA = "iam.require_mfa"

SettingRequireMFA makes MFA mandatory for every person (not service accounts).

Variables

View Source
var CLICommands func() map[string]string

CLICommands maps API operations to synctl commands (set by the controller, which links the CLI; the api package cannot import it).

View Source
var OpenAPISpec []byte

OpenAPISpec is the API contract, served at /api/v1/openapi.json. A test keeps it in sync with Routes.

Functions

func ActionFor

func ActionFor(method, path string) string

ActionFor returns the IAM action of a route ("" when it has none).

Types

type ACMEInfo

type ACMEInfo struct {
	Enabled      bool   `json:"enabled"`
	DirectoryURL string `json:"directoryUrl"`
	Email        string `json:"email"`
}

ACMEInfo describes the certificate issuer for the dashboard.

type Options

type Options struct {
	Store   *store.Store
	Secrets *secrets.Box
	CA      *pki.CA
	Nodes   *nodes.Registry
	// GatewayAddr is the agent gateway address returned to joining nodes.
	GatewayAddr string
	// System reports platform components (system tasks); may be nil in tests.
	System *system.Manager
	// Registry issues Docker registry tokens; nil disables the token endpoint.
	Registry *registry.Issuer
	// Internal handlers are mounted as-is outside the public API (e.g. the
	// Traefik config endpoint) and carry their own authentication.
	Internal map[string]http.Handler
	// Domains, Detector and Certs back the domain settings (§5.0.2); may be nil.
	Domains  *domain.Service
	Detector *domain.Detector
	Certs    *certs.Manager
	ACME     ACMEInfo
	// OnSetup runs after the root account is created.
	OnSetup func()
	// Backups manages S3 backups (§13); may be nil.
	Backups *backup.Manager
	// Mesh reports the private network (§8); may be nil.
	Mesh *mesh.Manager
	// DownloadsDir holds agent/CLI binaries served at /downloads/ ("" disables).
	DownloadsDir string
	// Workloads runs services (§5.2); may be nil.
	Workloads *workload.Manager
	// Databases runs managed Valkey (Phase 12); may be nil.
	Databases *dbs.Manager
	// Logs serves container logs (§9.2); may be nil.
	Logs *logs.Store
	// Exec relays interactive commands to tasks; may be nil.
	Exec *execrelay.Relay
	// Jobs runs one-off, scheduled and hook jobs (§5.11); may be nil.
	Jobs *jobs.Manager
	// Health is the central health monitor (§5.6); may be nil.
	Health *health.Monitor
	// RegistryBrowser reads repositories and images (§5.10); may be nil.
	RegistryBrowser *registry.Browser
	// Builds builds Git commits into images (§5.8); may be nil.
	Builds *builds.Manager
	// Metrics reads task resource usage (§9.1); may be nil.
	Metrics *metrics.Store
	// RegistryMaint applies lifecycle policies and runs GC (§5.10); may be nil.
	RegistryMaint *regmaint.Manager
	// Upstreams stores third-party registry credentials (§5.9); may be nil.
	Upstreams *upstream.Manager
	// RegistryHosts are the names images use for the private registry.
	RegistryHosts func() []string
	// Autoscaler runs target tracking policies (§5.5).
	Autoscaler *autoscale.Manager
	// Alerts evaluates alert rules and notifies channels (§9).
	Alerts *alerts.Manager
	// SecurityGroups is on when containers are isolated (§8.3);
	// OnSecurityChange republishes the compiled policy.
	SecurityGroups   bool
	OnSecurityChange func()
	FirewallStats    *fwstats.Stats
	Quotas           *quota.Manager
	Shell            *shell.Manager
	Pools            *nodepool.Manager
	Edges            *edge.Manager
	Upgrades         *upgrade.Service
	S3               *s3.Manager
	AgentRollout     *rollout.Manager
	Discovery        *discovery.Manager
	Traefik          *traefik.Provider
	TraefikExtras    *traefik.Extras
	GitConnections   *gitconn.Manager
	GitServer        *gitserver.Manager
	// OnTraefikSettings re-renders the Traefik replicas after the static
	// settings changed.
	OnTraefikSettings func()
	// ControllerSchedulable lets ctl-0 run services from the moment it joins (D3).
	ControllerSchedulable bool
	Bus                   *events.Bus
	Log                   *slog.Logger
	Web                   fs.FS
	// Now is overridable for tests.
	Now func() time.Time
}

type Principal

type Principal struct {
	User       store.User
	CredType   string
	CredID     string // access key ID or token ID; empty for sessions
	RoleID     string // set for role sessions: the role's policies apply
	MFA        bool   // the credential was obtained with a TOTP code
	MFAEnabled bool   // the user has MFA set up
	Kind       string // user | service
}

Principal is who is making a request and with which credential.

type Route

type Route struct {
	Method string
	Path   string
	Public bool // no authentication required
	// contains filtered or unexported fields
}

Route is one API endpoint. Path uses OpenAPI-style {param} placeholders, which net/http's ServeMux also understands.

type Server

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

func New

func New(o Options) *Server

func (*Server) Handler

func (s *Server) Handler() http.Handler

func (*Server) Routes

func (s *Server) Routes() []Route

Routes returns every API endpoint.

Jump to

Keyboard shortcuts

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