Volt CLI: source-available under AGPSL v5.0
Complete infrastructure platform CLI: - Container runtime (systemd-nspawn) - VoltVisor VMs (Neutron Stardust / QEMU) - Stellarium CAS (content-addressed storage) - ORAS Registry - GitOps integration - Landlock LSM security - Compose orchestration - Mesh networking Copyright (c) Armored Gates LLC. All rights reserved. Licensed under AGPSL v5.0
This commit is contained in:
99
pkg/backend/backend.go
Normal file
99
pkg/backend/backend.go
Normal file
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
Backend Interface - Container runtime abstraction for Volt CLI.
|
||||
|
||||
All container backends (systemd-nspawn, proot, etc.) implement this interface
|
||||
to provide a uniform API for the CLI command layer.
|
||||
*/
|
||||
package backend
|
||||
|
||||
import "time"
|
||||
|
||||
// ContainerInfo holds metadata about a container.
|
||||
type ContainerInfo struct {
|
||||
Name string
|
||||
Image string
|
||||
Status string // created, running, stopped
|
||||
PID int
|
||||
RootFS string
|
||||
Memory string
|
||||
CPU int
|
||||
CreatedAt time.Time
|
||||
StartedAt time.Time
|
||||
IPAddress string
|
||||
OS string
|
||||
}
|
||||
|
||||
// CreateOptions specifies parameters for container creation.
|
||||
type CreateOptions struct {
|
||||
Name string
|
||||
Image string
|
||||
RootFS string
|
||||
Memory string
|
||||
CPU int
|
||||
Network string
|
||||
Start bool
|
||||
Env []string
|
||||
Ports []PortMapping
|
||||
Volumes []VolumeMount
|
||||
}
|
||||
|
||||
// PortMapping maps a host port to a container port.
|
||||
type PortMapping struct {
|
||||
HostPort int
|
||||
ContainerPort int
|
||||
Protocol string // tcp, udp
|
||||
}
|
||||
|
||||
// VolumeMount binds a host path into a container.
|
||||
type VolumeMount struct {
|
||||
HostPath string
|
||||
ContainerPath string
|
||||
ReadOnly bool
|
||||
}
|
||||
|
||||
// ExecOptions specifies parameters for executing a command in a container.
|
||||
type ExecOptions struct {
|
||||
Command []string
|
||||
TTY bool
|
||||
Env []string
|
||||
}
|
||||
|
||||
// LogOptions specifies parameters for retrieving container logs.
|
||||
type LogOptions struct {
|
||||
Tail int
|
||||
Follow bool
|
||||
}
|
||||
|
||||
// ContainerBackend defines the interface that all container runtimes must implement.
|
||||
type ContainerBackend interface {
|
||||
// Name returns the backend name (e.g., "systemd", "proot")
|
||||
Name() string
|
||||
|
||||
// Available returns true if this backend can run on the current system
|
||||
Available() bool
|
||||
|
||||
// Init initializes the backend
|
||||
Init(dataDir string) error
|
||||
|
||||
// Container lifecycle
|
||||
Create(opts CreateOptions) error
|
||||
Start(name string) error
|
||||
Stop(name string) error
|
||||
Delete(name string, force bool) error
|
||||
|
||||
// Container interaction
|
||||
Exec(name string, opts ExecOptions) error
|
||||
Logs(name string, opts LogOptions) (string, error)
|
||||
CopyToContainer(name string, src string, dst string) error
|
||||
CopyFromContainer(name string, src string, dst string) error
|
||||
|
||||
// Container info
|
||||
List() ([]ContainerInfo, error)
|
||||
Inspect(name string) (*ContainerInfo, error)
|
||||
|
||||
// Platform capabilities
|
||||
SupportsVMs() bool
|
||||
SupportsServices() bool
|
||||
SupportsNetworking() bool
|
||||
SupportsTuning() bool
|
||||
}
|
||||
Reference in New Issue
Block a user