Documentation ¶
Index ¶
- func InitFromStateDir(stateDir string) (err error)
- func PrepareSpec(spec *specs.Spec, bundle string)
- type Container
- type ContainerFS
- type FS
- func (r *FS) Create(id, bundle string, spec specs.Spec) (*Container, error)
- func (r *FS) Kill(id string, signal syscall.Signal) (err error)
- func (r *FS) List() (containers []specs.State, err error)
- func (r *FS) Remove(id string) (err error)
- func (r *FS) Start(id string) (err error)
- func (r *FS) State(id string) (state specs.State, err error)
- type StateManager
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InitFromStateDir ¶
InitFromStateDir initializes the container environment using the state directory. It reads the OCI specification from the state directory and then proceeds with initialization.
func PrepareSpec ¶
func PrepareSpec(spec *specs.Spec, bundle string)
PrepareSpec ensures that the root filesystem path in the container specification is absolute. If the path is relative, it will be joined with the provided bundle path.
Types ¶
type Container ¶
type Container struct {
// contains filtered or unexported fields
}
Container represents a container with its associated state and configuration.
func CreateContainer ¶
CreateContainer creates a new container using the container filesystem, id, and bundle path. It reads the container's specification, prepares it, creates the container, initializes it, and updates its state. Returns the created container
type ContainerFS ¶
type ContainerFS interface { // Create initializes and creates a new container with the given ID, bundle path, and OCI runtime specification. // Returns the created container and any error encountered. Create(id, bundle string, spec specs.Spec) (container *Container, err error) // Start launches the container with the specified ID. // It returns any error encountered during the start process. Start(id string) (err error) // Kill sends a termination signal to the container with the specified ID. // It accepts a signal of type syscall.Signal and returns any error encountered. Kill(id string, signal syscall.Signal) (err error) // Remove deletes the container with the given ID. // It returns any error encountered during the removal process. Remove(id string) (err error) // State retrieves the current state of the container with the specified ID. // It returns the container's state and any error encountered. State(id string) (state specs.State, err error) // List returns a list of all containers' states. // It returns the list of container states and any error encountered. List() (containers []specs.State, err error) }
ContainerFS defines the interface for container file system operations.
type FS ¶
type FS struct {
// contains filtered or unexported fields
}
FS represents a file system that manages containers.
func NewContainerFS ¶
NewContainerFS creates a new FS instance with the specified container directory. It initializes the directory structure if it does not already exist.
func (*FS) Create ¶
Create initializes and creates a new container with the given ID, bundle path, and OCI runtime specification. It returns the created container and any error encountered.
func (*FS) Kill ¶
Kill sends a termination signal to the container with the specified ID. It returns any error encountered during the process.
func (*FS) List ¶
List returns a list of all containers' states. It returns the list of container states and any error encountered.
func (*FS) Remove ¶
Remove deletes the container with the specified ID. It returns any error encountered during the removal process.
type StateManager ¶
type StateManager struct {
// contains filtered or unexported fields
}
func LoadStateManager ¶
func LoadStateManager(stateDir string) (*StateManager, error)
LoadStateManager loads an existing state from the state directory. It initializes a new StateManager and attempts to load the state from the state file. Returns a pointer to the StateManager and an error if loading the state fails.
func NewStateManager ¶
func NewStateManager(stateDir string, state *specs.State) (*StateManager, error)
NewStateManager creates a new StateManager instance and updates the state file. It takes the state directory and an initial state as input. Returns a pointer to the StateManager and an error if updating the state fails.
func (*StateManager) LoadState ¶
func (s *StateManager) LoadState() (err error)
LoadState reads the state from the state file. Returns an error if the file reading fails, or if the file does not exist.
func (*StateManager) SetBundle ¶
func (s *StateManager) SetBundle(bundle string)
SetBundle sets the bundle path of the container
func (*StateManager) SetPid ¶
func (s *StateManager) SetPid(pid int)
SetPid sets the PID of the container process
func (*StateManager) SetStatus ¶
func (s *StateManager) SetStatus(state specs.ContainerState)
SetStatus sets the container status
func (*StateManager) State ¶
func (s *StateManager) State() specs.State
State returns a copy of the current container state.
func (*StateManager) UpdateState ¶
func (s *StateManager) UpdateState() (err error)
UpdateState writes the current state to the state file. Returns an error if the file writing fails.