Documentation
¶
Overview ¶
Package api implements the REST handlers for environment-scoped resources (ADR-0006): /api/v1/environments and /api/v1/environments/{env}/...
Index ¶
- Constants
- func EnvFrom(ctx context.Context) *environment.Environment
- func Namespace(r *http.Request) (string, error)
- func ReadOnlyReason(st runtime.NerdctlStatus) string
- type BulkActionRequest
- type BulkActionResult
- type CreateContainerRequest
- type Environment
- type EnvironmentStatus
- type EventHistory
- type ExecExit
- type Features
- type Handler
- type HistoryEvent
- type JobFrame
- type RemoveImagesResult
Constants ¶
const ( StatusConnected = "connected" )
Environment statuses.
Variables ¶
This section is empty.
Functions ¶
func EnvFrom ¶
func EnvFrom(ctx context.Context) *environment.Environment
EnvFrom returns the environment resolved from the {env} path parameter.
func Namespace ¶
Namespace returns the containerd namespace for the request: the "namespace" query parameter, or the environment's default. Invalid names are rejected (ADR-0006).
func ReadOnlyReason ¶
func ReadOnlyReason(st runtime.NerdctlStatus) string
ReadOnlyReason explains why an environment is read-only.
Types ¶
type BulkActionRequest ¶
type BulkActionRequest struct {
Action runtime.Action `json:"action"`
IDs []string `json:"ids"`
Force bool `json:"force,omitempty"`
Volumes bool `json:"volumes,omitempty"`
}
BulkActionRequest is the body of POST /containers/actions. Keep in sync with api/openapi.yaml.
type BulkActionResult ¶
type BulkActionResult struct {
ID string `json:"id"`
OK bool `json:"ok"`
Error *httpjson.ErrorDetail `json:"error,omitempty"`
}
BulkActionResult is the outcome for one container.
type CreateContainerRequest ¶
type CreateContainerRequest struct {
runtime.CreateSpec
// Start runs the container after creating it (like `nerdctl run -d`).
Start bool `json:"start"`
}
CreateContainerRequest is the body of POST /containers. Keep in sync with api/openapi.yaml.
type Environment ¶
type Environment struct {
ID string `json:"id"`
Name string `json:"name"`
Kind string `json:"kind"`
DefaultNamespace string `json:"defaultNamespace"`
}
Environment is the API representation. Keep in sync with api/openapi.yaml.
type EnvironmentStatus ¶
type EnvironmentStatus struct {
Environment
Status string `json:"status"` // connected | unavailable
Error string `json:"error,omitempty"`
Runtime *runtime.Versions `json:"runtime,omitempty"`
// Features reports server settings the UI adapts to.
Features Features `json:"features"`
}
EnvironmentStatus adds live connectivity information.
type EventHistory ¶
type EventHistory interface {
ListEvents(ctx context.Context, arg db.ListEventsParams) ([]db.Event, error)
}
EventHistory reads recorded events (#65, ADR-0021); *db.Queries implements it.
type ExecExit ¶
type ExecExit struct {
ExitCode int `json:"exitCode"`
}
ExecExit is the last data message of a terminal session.
type Features ¶
type Features struct {
// Exec is false when the web terminal is disabled (--disable-exec).
Exec bool `json:"exec"`
}
Features of the server for an environment.
type Handler ¶
type Handler struct {
Envs *environment.Registry
Jobs *jobs.Manager
// EventHistory serves the event feed (#65); nil when recording is disabled.
EventHistory EventHistory
// ExecDisabled turns off the web terminal (--disable-exec, #15).
ExecDisabled bool
Logger *slog.Logger
}
Handler serves environment endpoints.
type HistoryEvent ¶
type HistoryEvent struct {
ID int64 `json:"id"`
Timestamp time.Time `json:"ts"`
Namespace string `json:"namespace,omitempty"`
Topic string `json:"topic"`
Kind string `json:"kind"`
Action string `json:"action"`
ObjectID string `json:"objectId,omitempty"`
ObjectName string `json:"objectName,omitempty"`
Attributes map[string]string `json:"attributes,omitempty"`
}
HistoryEvent is a recorded event. Keep in sync with api/openapi.yaml.
type JobFrame ¶
type JobFrame struct {
Job *jobs.Job `json:"job,omitempty"`
Output string `json:"output,omitempty"`
Reset bool `json:"reset,omitempty"`
}
JobFrame is a data message of a job stream: the job state and/or terminal output. The first frame carries the job and the stored output with reset set.
type RemoveImagesResult ¶
type RemoveImagesResult struct {
Reference string `json:"reference"`
OK bool `json:"ok"`
Error *httpjson.ErrorDetail `json:"error,omitempty"`
}
RemoveImagesResult reports the removal of one reference. Keep in sync with api/openapi.yaml.