api

package module
v0.0.0-...-41ae5f8 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2026 License: Apache-2.0 Imports: 2 Imported by: 7

Documentation

Index

Constants

View Source
const (
	// MaxLabels is the maximum number of labels allowed per resource
	MaxLabels = 64
	// MaxAnnotations is the maximum number of annotations allowed per resource
	MaxAnnotations = 32
	// MaxLabelKeyLength is the maximum length for label keys
	MaxLabelKeyLength = 63
	// MaxLabelValueLength is the maximum length for label values
	MaxLabelValueLength = 255
	// MaxAnnotationKeyLength is the maximum length for annotation keys
	MaxAnnotationKeyLength = 253
	// MaxAnnotationValueLength is the maximum length for annotation values (64KB)
	MaxAnnotationValueLength = 65536
	// ReservedMetadataPrefix is the reserved prefix for system metadata
	ReservedMetadataPrefix = "ravel."
)

Metadata validation constants

View Source
const DefaultStopSignal = "SIGTERM"
View Source
const DefaultStopTimeout = 5 // in seconds
View Source
const MaxStopTimeout = 30 // in seconds

Variables

This section is empty.

Functions

This section is empty.

Types

type AgentBuildRequest

type AgentBuildRequest struct {
	Id         string            `json:"id"`
	Namespace  string            `json:"namespace"`
	ImageName  string            `json:"image_name"`
	Tag        string            `json:"tag"`
	Registry   string            `json:"registry"`
	Dockerfile string            `json:"dockerfile"`
	BuildArgs  map[string]string `json:"build_args"`
	Target     string            `json:"target"`
	NoCache    bool              `json:"no_cache"`
}

AgentBuildRequest is sent to the agent to start a build

type AgentBuildResponse

type AgentBuildResponse struct {
	Id     string      `json:"id"`
	Status BuildStatus `json:"status"`
}

AgentBuildResponse is returned by the agent after starting a build

type AgentBuildStatusResponse

type AgentBuildStatusResponse struct {
	Id          string      `json:"id"`
	Status      BuildStatus `json:"status"`
	Digest      string      `json:"digest,omitempty"`
	Error       string      `json:"error,omitempty"`
	DurationMs  int64       `json:"duration_ms,omitempty"`
	CompletedAt *time.Time  `json:"completed_at,omitempty"`
}

AgentBuildStatusResponse is returned by the agent for build status queries

type Build

type Build struct {
	Id          string      `json:"id"`
	Namespace   string      `json:"namespace"`
	NodeId      string      `json:"node_id,omitempty"`
	ImageName   string      `json:"image_name"`
	Tag         string      `json:"tag"`
	Registry    string      `json:"registry"`
	FullImage   string      `json:"full_image"`
	Status      BuildStatus `json:"status"`
	Digest      string      `json:"digest,omitempty"`
	Error       string      `json:"error,omitempty"`
	DurationMs  int64       `json:"duration_ms,omitempty"`
	CreatedAt   time.Time   `json:"created_at"`
	CompletedAt *time.Time  `json:"completed_at,omitempty"`
}

Build represents a container image build

type BuildLog

type BuildLog struct {
	Timestamp time.Time `json:"timestamp"`
	Stream    string    `json:"stream"`
	Message   string    `json:"message"`
}

BuildLog represents a single log entry from a build

type BuildStatus

type BuildStatus string

BuildStatus represents the current state of a build

const (
	BuildStatusPending   BuildStatus = "pending"
	BuildStatusBuilding  BuildStatus = "building"
	BuildStatusPushing   BuildStatus = "pushing"
	BuildStatusCompleted BuildStatus = "completed"
	BuildStatusFailed    BuildStatus = "failed"
)

type CreateBuildPayload

type CreateBuildPayload struct {
	ImageName  string            `json:"image_name"`
	Tag        string            `json:"tag,omitempty"`
	Registry   string            `json:"registry"`
	Dockerfile string            `json:"dockerfile,omitempty"`
	BuildArgs  map[string]string `json:"build_args,omitempty"`
	Target     string            `json:"target,omitempty"`
	NoCache    bool              `json:"no_cache,omitempty"`
}

CreateBuildPayload is the request payload for creating a new build

type CreateFleetPayload

type CreateFleetPayload struct {
	Name     string    `json:"name"`
	Metadata *Metadata `json:"metadata,omitempty"`
}

type CreateGatewayPayload

type CreateGatewayPayload struct {
	Name       string `json:"name,omitempty"`
	TargetPort int    `json:"target_port"`
}

type CreateMachinePayload

type CreateMachinePayload struct {
	Region               string        `json:"region"`
	Config               MachineConfig `json:"config"`
	SkipStart            bool          `json:"skip_start,omitempty"`
	EnableMachineGateway bool          `json:"enable_machine_gateway,omitempty"`
	Metadata             *Metadata     `json:"metadata,omitempty"`
}

type CreateSecretPayload

type CreateSecretPayload struct {
	Name  string `json:"name" minLength:"1" maxLength:"63" pattern:"^[a-z0-9]([-a-z0-9]*[a-z0-9])?$" doc:"Secret name (DNS label format)"`
	Value string `json:"value" minLength:"1" doc:"Secret value"`
}

type ExecOptions

type ExecOptions struct {
	Cmd       []string `json:"cmd"`
	TimeoutMs int      `json:"timeout_ms"`
}

func (*ExecOptions) GetTimeout

func (e *ExecOptions) GetTimeout() time.Duration

type ExecResult

type ExecResult struct {
	Stderr   string `json:"stderr"`
	Stdout   string `json:"stdout"`
	ExitCode int    `json:"exit_code"`
}

type Fleet

type Fleet struct {
	Id        string      `json:"id"`
	Namespace string      `json:"namespace"`
	Name      string      `json:"name"`
	CreatedAt time.Time   `json:"created_at"`
	Status    FleetStatus `json:"status"`
	Metadata  *Metadata   `json:"metadata,omitempty"`
}

type FleetStatus

type FleetStatus string
const (
	FleetStatusActive    FleetStatus = "active"
	FleetStatusDestroyed FleetStatus = "destroyed"
)

type Gateway

type Gateway struct {
	Id         string `json:"id"`
	Name       string `json:"name"`
	Namespace  string `json:"namespace"`
	FleetId    string `json:"fleet_id"`
	Protocol   string `json:"protocol"`
	TargetPort int    `json:"target_port"`
}

type GuestConfig

type GuestConfig struct {
	CpuKind  string `json:"cpu_kind"`
	MemoryMB int    `json:"memory_mb" minimum:"1"`
	Cpus     int    `json:"cpus" minimum:"1"`
}

type HealthCheck

type HealthCheck struct {
	Exec     []string `json:"exec,omitempty" doc:"Command to run for health check"`
	Interval int      `json:"interval,omitempty" doc:"Interval in seconds between health checks (default: 30)"`
	Timeout  int      `json:"timeout,omitempty" doc:"Timeout in seconds for health check (default: 5)"`
	Retries  int      `json:"retries,omitempty" doc:"Number of consecutive failures before unhealthy (default: 3)"`
}

type HealthStatus

type HealthStatus string
const (
	HealthStatusUnknown   HealthStatus = "unknown"
	HealthStatusHealthy   HealthStatus = "healthy"
	HealthStatusUnhealthy HealthStatus = "unhealthy"
	HealthStatusStarting  HealthStatus = "starting"
)

type InitConfig

type InitConfig struct {
	Cmd        []string `json:"cmd,omitempty"`
	Entrypoint []string `json:"entrypoint,omitempty"`
	User       string   `json:"user,omitempty"`
}

type LogEntry

type LogEntry struct {
	Timestamp  int64  `json:"timestamp,omitempty"`
	InstanceId string `json:"instance_id,omitempty"`
	Source     string `json:"source,omitempty"`
	Level      string `json:"level,omitempty"`
	Message    string `json:"message,omitempty"`
}

type Machine

type Machine struct {
	Id             string         `json:"id"`
	Namespace      string         `json:"namespace"`
	FleetId        string         `json:"fleet"`
	InstanceId     string         `json:"instance_id"`
	MachineVersion string         `json:"machine_version"`
	Region         string         `json:"region"`
	Config         MachineConfig  `json:"config"`
	CreatedAt      time.Time      `json:"created_at"`
	UpdatedAt      time.Time      `json:"updated_at"`
	Events         []MachineEvent `json:"events"`
	Status         MachineStatus  `json:"state"`
	Health         HealthStatus   `json:"health,omitempty"`
	GatewayEnabled bool           `json:"gateway_enabled"`
	Metadata       *Metadata      `json:"metadata,omitempty"`
}

type MachineConfig

type MachineConfig struct {
	Image      string      `json:"image"`
	Guest      GuestConfig `json:"guest"`
	Workload   Workload    `json:"workload,omitempty"`
	StopConfig *StopConfig `json:"stop_config,omitempty"`
}

type MachineDestroyEventPayload

type MachineDestroyEventPayload struct {
	AutoDestroy bool   `json:"auto_destroy"`
	Reason      string `json:"reason"`
	Force       bool   `json:"force"`
}

type MachineEvent

type MachineEvent struct {
	Id         string              `json:"id"`
	MachineId  string              `json:"machine_id"`
	InstanceId string              `json:"instance_id"`
	Status     MachineStatus       `json:"status"`
	Type       MachineEventType    `json:"type"`
	Origin     Origin              `json:"origin"`
	Payload    MachineEventPayload `json:"payload"`
	Timestamp  time.Time           `json:"timestamp"`
}

func (MachineEvent) EventType

func (me MachineEvent) EventType() MachineEventType

type MachineEventPayload

type MachineEventPayload struct {
	PrepareFailed *MachinePrepareFailedEventPayload `json:"prepare_failed,omitempty"`
	Stop          *MachineStopEventPayload          `json:"stop,omitempty"`
	Start         *MachineStartEventPayload         `json:"start,omitempty"`
	StartFailed   *MachineStartFailedEventPayload   `json:"start_failed,omitempty"`
	Started       *MachineStartedEventPayload       `json:"started,omitempty"`
	Exited        *MachineExitedEventPayload        `json:"stopped,omitempty"`
	Destroy       *MachineDestroyEventPayload       `json:"destroy,omitempty"`
}

type MachineEventType

type MachineEventType string
const (
	MachineCreated       MachineEventType = "machine.created"
	MachinePrepare       MachineEventType = "machine.prepare"
	MachinePrepared      MachineEventType = "machine.prepared"
	MachinePrepareFailed MachineEventType = "machine.prepare_failed"
	MachineStart         MachineEventType = "machine.start"
	MachineStartFailed   MachineEventType = "machine.start_failed"
	MachineStarted       MachineEventType = "machine.started"
	MachineStop          MachineEventType = "machine.stop"
	MachineStopFailed    MachineEventType = "machine.stop_failed"
	MachineExited        MachineEventType = "machine.exited"
	MachineDestroy       MachineEventType = "machine.destroy"
	MachineDestroyed     MachineEventType = "machine.destroyed"
)

type MachineExitedEventPayload

type MachineExitedEventPayload struct {
	ExitCode int       `json:"exit_code"`
	ExitedAt time.Time `json:"exited_at"`
}

type MachinePrepareFailedEventPayload

type MachinePrepareFailedEventPayload struct {
	Error string `json:"error"`
}

type MachineStartEventPayload

type MachineStartEventPayload struct {
	IsRestart bool `json:"is_restart"`
}

type MachineStartFailedEventPayload

type MachineStartFailedEventPayload struct {
	Error string `json:"error"`
}

type MachineStartedEventPayload

type MachineStartedEventPayload struct {
	StartedAt time.Time `json:"started_at"`
}

type MachineStatus

type MachineStatus string
const (
	MachineStatusCreated    MachineStatus = "created"
	MachineStatusPreparing  MachineStatus = "preparing"
	MachineStatusStarting   MachineStatus = "starting"
	MachineStatusRunning    MachineStatus = "running"
	MachineStatusStopping   MachineStatus = "stopping"
	MachineStatusStopped    MachineStatus = "stopped"
	MachineStatusDestroying MachineStatus = "destroying"
	MachineStatusDestroyed  MachineStatus = "destroyed"
)

type MachineStopEventPayload

type MachineStopEventPayload struct {
	Config *StopConfig `json:"config,omitempty"`
}

type MachineVersion

type MachineVersion struct {
	Id        string        `json:"id"`
	MachineId string        `json:"machine_id"`
	Namespace string        `json:"namespace"`
	Config    MachineConfig `json:"config"`
	Resources Resources     `json:"resources"`
}

type Metadata

type Metadata struct {
	Labels      map[string]string `json:"labels,omitempty"`
	Annotations map[string]string `json:"annotations,omitempty"`
}

Metadata represents labels and annotations for resources (fleets and machines). Labels are key-value pairs used for organization and filtering. Annotations are key-value pairs for storing larger metadata like descriptions or JSON data.

type Namespace

type Namespace struct {
	Name      string    `json:"name"`
	CreatedAt time.Time `json:"created_at"`
}

type Node

type Node struct {
	Id            string    `json:"id"`
	Address       string    `json:"address"`
	AgentPort     int       `json:"agent_port"`
	HttpProxyPort int       `json:"proxy_port"`
	Region        string    `json:"region"`
	HeartbeatedAt time.Time `json:"heartbeated_at"`
}

func (*Node) AgentAddress

func (n *Node) AgentAddress() string

func (*Node) HttpProxyAddress

func (n *Node) HttpProxyAddress() string

type Origin

type Origin string
const (
	OriginRavel Origin = "ravel"
	OriginUser  Origin = "user"
)

type PrivateNetwork

type PrivateNetwork struct {
	Name string `json:"name" doc:"Name of the private network to join"`
	IP   string `json:"ip" doc:"IP address for this machine in the private network (e.g., 10.0.1.2/24)"`
}

type Resources

type Resources struct {
	CpusMHz  int `json:"cpus_mhz" toml:"cpus_mhz"`   // in MHz
	MemoryMB int `json:"memory_mb" toml:"memory_mb"` // in MB
}

func (*Resources) Add

func (r *Resources) Add(other Resources) Resources

Add returns a new Resources object which is the sum of the resources.

func (*Resources) GT

func (r *Resources) GT(other Resources) bool

GT returns true if the resources are greater than the other resources.

func (*Resources) Sub

func (r *Resources) Sub(other Resources) Resources

type RestartPolicy

type RestartPolicy string
const (
	RestartPolicyAlways    RestartPolicy = "always"
	RestartPolicyOnFailure RestartPolicy = "on-failure"
	RestartPolicyNever     RestartPolicy = "never"
)

type RestartPolicyConfig

type RestartPolicyConfig struct {
	Policy     RestartPolicy `json:"policy,omitempty"`
	MaxRetries int           `json:"max_retries,omitempty"`
}

type Secret

type Secret struct {
	Id        string    `json:"id"`
	Name      string    `json:"name"`
	Namespace string    `json:"namespace"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

type SecretRef

type SecretRef struct {
	Name   string `json:"name" doc:"Name of the secret in the namespace"`
	EnvVar string `json:"env_var" doc:"Environment variable name to inject the secret into"`
}

type StopConfig

type StopConfig struct {
	Timeout *int    `json:"timeout,omitempty"` // in seconds
	Signal  *string `json:"signal,omitempty"`
}

func GetDefaultStopConfig

func GetDefaultStopConfig() *StopConfig

type UpdateFleetMetadataPayload

type UpdateFleetMetadataPayload struct {
	Metadata Metadata `json:"metadata"`
}

UpdateFleetMetadataPayload is the request payload for updating fleet metadata

type UpdateMachineMetadataPayload

type UpdateMachineMetadataPayload struct {
	Metadata Metadata `json:"metadata"`
}

UpdateMachineMetadataPayload is the request payload for updating machine metadata

type UpdateSecretPayload

type UpdateSecretPayload struct {
	Value string `json:"value" minLength:"1" doc:"New secret value"`
}

type VolumeMount

type VolumeMount struct {
	Name string `json:"name" doc:"Name of the disk to mount"`
	Path string `json:"path" doc:"Mount path inside the machine"`
}

type Workload

type Workload struct {
	Restart         RestartPolicyConfig `json:"restart,omitempty"`
	Env             []string            `json:"env,omitempty"`
	Secrets         []SecretRef         `json:"secrets,omitempty"`
	Volumes         []VolumeMount       `json:"volumes,omitempty"`
	Init            InitConfig          `json:"init,omitempty"`
	HealthCheck     *HealthCheck        `json:"health_check,omitempty"`
	PrivateNetworks []PrivateNetwork    `json:"private_networks,omitempty"`
	AutoDestroy     bool                `json:"auto_destroy,omitempty"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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