hostapi

package
v2.0.0-alpha.2 Latest Latest
Warning

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

Go to latest
Published: May 11, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// HomeDir is the home directory inside container
	HomeDir = "/home/action"

	// SysinnerDir is the sysinner config directory inside container
	SysinnerDir = "/home/action/.sysinner"

	// AppInstanceFile is the app instance config file path inside container
	AppInstanceFile = "/home/action/.sysinner/app_instance.json"

	// IninitFile is the ininit script path inside container
	IninitFile = "/home/action/.sysinner/ininit"

	// InagentFile is the inagent binary path inside container
	InagentFile = "/home/action/.sysinner/inagent"

	// InagentSock is the inagent unix socket path inside container
	InagentSock = "unix:/home/action/.sysinner/inagent.sock"

	// ContainerEntrypoint is the default container entrypoint command
	ContainerEntrypoint = "/bin/sh"
)

Container internal paths (paths inside the container)

Variables

View Source
var (
	// ContainerNameValid validates container names generated by ContainerName().
	// Format: app-{appId}-{replicaId:04x}
	// Example: app-abc123def456-0001
	// - Prefix: "app-"
	// - AppId: alphanumeric (min 3, max 64 chars to accommodate various ID formats)
	// - ReplicaId: 4-digit hexadecimal (lowercase)
	ContainerNameValid = regexp.MustCompile("^app-[a-f0-9]{8,16}-[0-9a-f]{4}$")
)
View Source
var InitDirs = []string{
	"/home/action/local/bin",
	"/home/action/local/share",
	"/home/action/local/profile.d",
	"/home/action/var/tmp",
	"/home/action/var/log",
	"/home/action/.ssh",
}

InitDirs are directories to be created on container initialization

Functions

func ContainerCmd

func ContainerCmd() []string

ContainerCmd returns the container entrypoint command

Types

type AppReplicaInstanceList

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

func (*AppReplicaInstanceList) TryStore

type ContainerCreateOptions

type ContainerCreateOptions struct {
	Name          string            // container name
	Image         string            // image name
	Cmd           []string          // entrypoint command
	Env           []string          // environment variables
	Labels        map[string]string // metadata labels
	Hostname      string            // container hostname
	CpuLimit      int64             // CPU limit (millicores, 1000 = 1 core)
	MemoryLimit   int64             // memory limit (bytes)
	Ports         []PortBinding     // port mappings
	Mounts        []MountBind       // volume mounts
	RestartPolicy string            // no, always, on-failure, unless-stopped
	DnsServers    []string          // DNS servers for container
	VpcIPv4       string            // VPC IP to assign to container
	VpcSubnet     string            // VPC subnet CIDR for Docker network creation
}

ContainerCreateOptions defines container creation parameters.

type ContainerInfo

type ContainerInfo struct {
	ID          string                `json:"id"`
	Name        string                `json:"name"`
	Image       string                `json:"image"`
	ImageID     string                `json:"image_id"`
	State       string                `json:"state"`             // running, exited, paused, etc.
	Status      string                `json:"status"`            // detailed status
	Pid         int                   `json:"pid"`               // process ID
	IP          string                `json:"ip"`                // container IP
	Ports       map[int32]PortBinding `json:"ports"`             // port mappings (key: container port)
	Created     int64                 `json:"created"`           // unix timestamp (seconds)
	Started     int64                 `json:"started,omitempty"` // unix timestamp (seconds)
	Labels      map[string]string     `json:"labels,omitempty"`
	CpuLimit    int64                 `json:"cpu_limit,omitempty"`    // CPU limit (millicores)
	MemoryLimit int64                 `json:"memory_limit,omitempty"` // memory limit (bytes)
	Binds       []string              `json:"binds,omitempty"`        // volume binds from HostConfig

	LastInspectTime int64 `json:"-"`
}

ContainerInfo represents container instance details.

type ContainerStats

type ContainerStats struct {
	Time          int64 `json:"time"`            // unix timestamp (seconds)
	CpuTotalUsage int64 `json:"cpu_total_usage"` // CPU total usage (nanoseconds)
	MemoryUsage   int64 `json:"memory_usage"`    // memory usage (bytes)
	MemoryCache   int64 `json:"memory_cache"`    // memory cache (bytes)
	NetRxBytes    int64 `json:"net_rx_bytes"`    // network received bytes
	NetTxBytes    int64 `json:"net_tx_bytes"`    // network transmitted bytes
	BlkReadBytes  int64 `json:"blk_read_bytes"`  // block device read bytes
	BlkWriteBytes int64 `json:"blk_write_bytes"` // block device write bytes
	BlkReadOps    int64 `json:"blk_read_ops"`    // block device read operations
	BlkWriteOps   int64 `json:"blk_write_ops"`   // block device write operations
}

ContainerStats holds a snapshot of resource usage statistics for a container.

type Driver

type Driver interface {
	Name() string

	Info(ctx context.Context) (*DriverInfo, error)
	Ping(ctx context.Context) error

	ContainerList(ctx context.Context) ([]*ContainerInfo, error)
	ContainerInspect(ctx context.Context, nameOrId string) (*ContainerInfo, error)
	ContainerCreate(ctx context.Context, opts *ContainerCreateOptions) (*ContainerInfo, error)
	ContainerStart(ctx context.Context, nameOrId string) error
	ContainerStop(ctx context.Context, nameOrId string) error
	ContainerRemove(ctx context.Context, nameOrId string) error

	ImageList(ctx context.Context) ([]*ImageInfo, error)
	ImagePull(ctx context.Context, image string) error
}

Driver defines the container runtime driver interface.

type DriverInfo

type DriverInfo struct {
	Name         string `json:"name"`
	Version      string `json:"version"`
	APIVersion   string `json:"api_version,omitempty"`
	OS           string `json:"os,omitempty"`
	Arch         string `json:"arch,omitempty"`
	Kernel       string `json:"kernel,omitempty"`
	ContainerNum int    `json:"container_num,omitempty"`
	ImageNum     int    `json:"image_num,omitempty"`
}

DriverInfo represents container driver metadata.

type HostSourcePaths

type HostSourcePaths struct {
	// Prefix is the installation prefix directory
	Prefix string
}

HostSourcePaths contains paths for source files on host

func NewHostSourcePaths

func NewHostSourcePaths(prefix string) *HostSourcePaths

NewHostSourcePaths creates a HostSourcePaths instance

func (*HostSourcePaths) InagentSrc

func (h *HostSourcePaths) InagentSrc(arch string) string

InagentSrc returns the source path of inagent binary for given architecture

func (*HostSourcePaths) IninitSrc

func (h *HostSourcePaths) IninitSrc() string

IninitSrc returns the source path of ininit script

type ImageInfo

type ImageInfo struct {
	Name        string            `json:"name"`
	ID          string            `json:"id"`
	RepoTags    []string          `json:"repo_tags"`
	RepoDigests []string          `json:"repo_digests"`
	Size        int64             `json:"size"`    // bytes
	Created     int64             `json:"created"` // unix timestamp (seconds)
	Labels      map[string]string `json:"labels,omitempty"`
}

ImageInfo represents container image metadata.

type MountBind

type MountBind struct {
	HostPath      string `json:"host_path"`      // host path
	ContainerPath string `json:"container_path"` // container path
	ReadOnly      bool   `json:"read_only"`      // read-only flag
	UID           int    `json:"uid,omitempty"`  // user id for chown (0 means no change)
	GID           int    `json:"gid,omitempty"`  // group id for chown (0 means no change)
}

MountBind represents a directory mount configuration.

type PodPaths

type PodPaths struct {
	// PodBase is the base path for pod data on host
	PodBase string
	// ContainerName is the container name
	ContainerName string
}

PodPaths contains paths for a specific pod/container

func NewPodPaths

func NewPodPaths(podBase, containerName string) *PodPaths

NewPodPaths creates a PodPaths instance

func (*PodPaths) AppInstanceFile

func (p *PodPaths) AppInstanceFile() string

AppInstanceFile returns the app instance json file path on host

func (*PodPaths) ContainerPodDir

func (p *PodPaths) ContainerPodDir() string

ContainerPodDir returns the container-specific directory on host

func (*PodPaths) HomeDir

func (p *PodPaths) HomeDir() string

HomeDir returns the /home mount directory on host

func (*PodPaths) InagentFile

func (p *PodPaths) InagentFile() string

InagentFile returns the inagent binary path on host

func (*PodPaths) IninitFile

func (p *PodPaths) IninitFile() string

IninitFile returns the ininit script path on host

func (*PodPaths) OptDir

func (p *PodPaths) OptDir() string

OptDir returns the /opt mount directory on host

func (*PodPaths) SysinnerDir

func (p *PodPaths) SysinnerDir() string

SysinnerDir returns the sysinner directory on host

type PortBinding

type PortBinding struct {
	HostIP        string `json:"host_ip"`
	HostPort      int32  `json:"host_port"`
	ContainerPort int32  `json:"container_port"`
	Protocol      string `json:"protocol"` // tcp, udp
}

PortBinding represents a port mapping configuration.

Jump to

Keyboard shortcuts

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