rescontainerocibase

package
v3.0.0-rc21 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2026 License: Apache-2.0 Imports: 41 Imported by: 0

Documentation

Overview

Package rescontainerocibase provides base settings for to implement resource container oci drivers.

It Defines BT that may help container oci composition for resource container oci driver interface.

It Defines Executor that implements Executer interface.

It Defines ExecutorArg that implements ExecutorArgser interface.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BT

type BT struct {
	resource.T
	resource.Restart
	resource.SCSIPersistentReservation
	ObjectDomain    string         `json:"object_domain"`
	PG              pg.Config      `json:"pg"`
	Path            naming.Path    `json:"path"`
	ObjectID        uuid.UUID      `json:"object_id"`
	SCSIReserv      bool           `json:"scsireserv"`
	PromoteRW       bool           `json:"promote_rw"`
	NoPreemptAbort  bool           `json:"no_preempt_abort"`
	OsvcRootPath    string         `json:"osvc_root_path"`
	GuestOS         string         `json:"guest_os"`
	Name            string         `json:"name"`
	Hostname        string         `json:"hostname"`
	Image           string         `json:"image"`
	ImagePullPolicy string         `json:"image_pull_policy"`
	CWD             string         `json:"cwd"`
	User            string         `json:"user"`
	Command         []string       `json:"command"`
	DNS             []string       `json:"dns"`
	DNSSearch       []string       `json:"dns_search"`
	RunArgs         []string       `json:"run_args"`
	Entrypoint      []string       `json:"entrypoint"`
	Detach          bool           `json:"detach"`
	Remove          bool           `json:"remove"`
	Privileged      bool           `json:"privileged"`
	Init            bool           `json:"init"`
	Interactive     bool           `json:"interactive"`
	TTY             bool           `json:"tty"`
	VolumeMounts    []string       `json:"volume_mounts"`
	Env             []string       `json:"environment"`
	SecretsEnv      []string       `json:"secrets_environment"`
	ConfigsEnv      []string       `json:"configs_environment"`
	Devices         []string       `json:"devices"`
	NetNS           string         `json:"netns"`
	UserNS          string         `json:"userns"`
	PIDNS           string         `json:"pidns"`
	IPCNS           string         `json:"ipcns"`
	UTSNS           string         `json:"utsns"`
	ReadOnly        string         `json:"read_only"`
	RegistryCreds   string         `json:"registry_creds"`
	PullTimeout     *time.Duration `json:"pull_timeout"`
	StartTimeout    *time.Duration `json:"start_timeout"`
	StopTimeout     *time.Duration `json:"stop_timeout"`
	Sysctl          []string       `json:"sysctl"`
	LogOutputs      bool           `json:"log_outputs"`
	// contains filtered or unexported fields
}

func (*BT) Configure

func (t *BT) Configure() error

func (*BT) ContainerID

func (t *BT) ContainerID(ctx context.Context) string

ContainerID returns the container inspect ID, or ""

func (*BT) ContainerInspect

func (t *BT) ContainerInspect(ctx context.Context) (Inspecter, error)

func (*BT) ContainerInspectRefresh

func (t *BT) ContainerInspectRefresh(ctx context.Context) (Inspecter, error)

func (*BT) ContainerLogs

func (t *BT) ContainerLogs(ctx context.Context, follow bool, lines int) (<-chan []byte, error)

func (*BT) ContainerName

func (t *BT) ContainerName() string

ContainerName formats a docker container name

func (*BT) EncapCmd

func (t *BT) EncapCmd(ctx context.Context, args []string, env []string, stdin io.Reader) (resource.Commander, error)

func (*BT) EncapCp

func (t *BT) EncapCp(ctx context.Context, src, dst string) error

func (*BT) Enter

func (t *BT) Enter(ctx context.Context) error

func (*BT) Executer

func (t *BT) Executer() Executer

Executer implements ExecuterGetter for external tests

func (*BT) FormatNS

func (t *BT) FormatNS(s string) (string, error)

func (*BT) GenEnv

func (t *BT) GenEnv(ctx context.Context) (envL []string, envM map[string]string, err error)

GenEnv returns the list of environment variables from the resource/object and its ConfigsEnv: []string{"PUBLICVAR1=Value", ...} secret var names from its SecretsEnv are added to the list: "SECRETVAR1", "SECRETVAR2",... values for secrets are added to the returned envM: {"SECRETVAR1":"SECRETVALUE1", ...} It may be used by executorArgser to prepare run args and run command environment.

func (*BT) GetHostname

func (t *BT) GetHostname() string

Implement the resource.Hostnamer interface, used by ip resources to obtain a hostname-based DNS record

func (*BT) GetOsvcRootPath

func (t *BT) GetOsvcRootPath() string

func (*BT) IsAlwaysImagePullPolicy

func (t *BT) IsAlwaysImagePullPolicy() bool

func (*BT) Label

func (t *BT) Label(_ context.Context) string

Label implements Label from resource.Driver interface, it returns a formatted short description of the Resource

func (*BT) Labels

func (t *BT) Labels() map[string]string

func (*BT) LinkNames

func (t *BT) LinkNames() []string

func (*BT) ManifestWithID

func (t *BT) ManifestWithID(drvID driver.ID) *manifest.T

ManifestWithID exposes to the core the input expected by the driver.

func (*BT) Mounts

func (t *BT) Mounts(ctx context.Context) ([]BindMount, error)

func (*BT) NeedPreStartRemove

func (t *BT) NeedPreStartRemove() bool

NeedPreStartRemove return true when container has Remove or not Detach. During Start existing container (with Remove true or Detach false) must be removed,

func (*BT) NetNSPath

func (t *BT) NetNSPath(ctx context.Context) (string, error)

NetNSPath returns the container inspect SandboxKey or ""

func (*BT) PID

func (t *BT) PID(ctx context.Context) int

PID returns the container inspect PID or 0

func (*BT) Provision

func (t *BT) Provision(_ context.Context) error

func (*BT) Provisioned

func (t *BT) Provisioned(ctx context.Context) (provisioned.T, error)

func (*BT) RemoveContainer

func (t *BT) RemoveContainer(ctx context.Context) error

func (*BT) Signal

func (t *BT) Signal(ctx context.Context, sig syscall.Signal) error

Signal implements object.Signaler

func (*BT) Start

func (t *BT) Start(ctx context.Context) error

func (*BT) Status

func (t *BT) Status(ctx context.Context) status.T

func (*BT) StatusInfo

func (t *BT) StatusInfo(ctx context.Context) map[string]any

func (*BT) Stop

func (t *BT) Stop(ctx context.Context) error

func (*BT) Unprovision

func (t *BT) Unprovision(_ context.Context) error

func (*BT) WithExecuter

func (t *BT) WithExecuter(c Executer) *BT

type BindMount

type BindMount struct {
	Source string
	Target string
	Option string
}

type ExecuteContainer

type ExecuteContainer interface {
	Enter(context.Context) error
	Start(context.Context) error
	Stop(context.Context) error
	Remove(context.Context) error
	Run(context.Context) error
}

ExecuteContainer interface defines the functions used to manage container lifecycle.

type ExecuteEncaper

type ExecuteEncaper interface {
	EncapCp(context.Context, string, string) error
	EncapCmd(context.Context, []string, []string, io.Reader) (*exec.Cmd, error)
}

type ExecuteImager

type ExecuteImager interface {
	HasImage(context.Context) (bool, string, error)
	Pull(context.Context) error
}

ExecuteImager interface defines the functions used to manage container image lifecycle.

type ExecuteInspecter

type ExecuteInspecter interface {
	Inspect(context.Context) (Inspecter, error)
	InspectRefresh(context.Context) (Inspecter, error)
}

ExecuteInspecter interface defines the functions used to retrieve container inspecter.

type ExecuteLogger

type ExecuteLogger interface {
	Logs(context.Context, bool, int) (<-chan []byte, error)
}

ExecuteLogger interface defines the functions used to get container logs.

type ExecuteWaiter

type ExecuteWaiter interface {
	WaitNotRunning(context.Context) error
	WaitRemoved(context.Context) error
}

ExecuteWaiter interface defines the functions used to manage container wait functions.

type Executer

Executer defines interfaces for container operations. It must be implemented by container executors.

type ExecuterGetter

type ExecuterGetter interface {
	Executer() Executer
}

type Executor

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

Executor implements Executer interface to manage containers.

func NewExecutor

func NewExecutor(exe string, args ExecutorArgser, log Logger) *Executor

func (*Executor) EncapCmd

func (e *Executor) EncapCmd(ctx context.Context, args []string, env []string, stdin io.Reader) (*exec.Cmd, error)

func (*Executor) EncapCp

func (e *Executor) EncapCp(ctx context.Context, src, dst string) error

func (*Executor) Enter

func (e *Executor) Enter(ctx context.Context) error

func (*Executor) ExecutorArgser

func (e *Executor) ExecutorArgser() ExecutorArgser

ExecutorArgser implements ExecutorArgserGetter for external tests

func (*Executor) HasImage

func (e *Executor) HasImage(ctx context.Context) (bool, string, error)

func (*Executor) Inspect

func (e *Executor) Inspect(ctx context.Context) (Inspecter, error)

Inspect returns Inspecter from cache. On cache miss a new Inspecter is created from InspectRefresh(ctx).

func (*Executor) InspectRefresh

func (e *Executor) InspectRefresh(ctx context.Context) (Inspecter, error)

InspectRefresh creates new Inspecter (from inspect command line). It updates e Inspecter cache that may be used Inspect(ctx).

func (*Executor) Logs

func (e *Executor) Logs(ctx context.Context, follow bool, lines int) (<-chan []byte, error)

func (*Executor) Pull

func (e *Executor) Pull(ctx context.Context) error

func (*Executor) Remove

func (e *Executor) Remove(ctx context.Context) error

func (*Executor) Run

func (e *Executor) Run(ctx context.Context) error

func (*Executor) Start

func (e *Executor) Start(ctx context.Context) error

func (*Executor) Stop

func (e *Executor) Stop(ctx context.Context) error

func (*Executor) WaitNotRunning

func (e *Executor) WaitNotRunning(ctx context.Context) error

func (*Executor) WaitRemoved

func (e *Executor) WaitRemoved(ctx context.Context) error

type ExecutorArg

type ExecutorArg struct {
	BT *BT

	// RunArgsCGroupParentDisable disable the "--cgroup-parent" RunArgs setting
	RunArgsCGroupParentDisable bool

	// RunArgsDNSOptionOption is the option name used during RunArgs
	// to set container dns options (example "--dns-option").
	RunArgsDNSOptionOption string
	// contains filtered or unexported fields
}

ExecutorArg implements ExecutorArgser

func (*ExecutorArg) CpCmdArgs

func (ea *ExecutorArg) CpCmdArgs(src, dst string) []string

func (*ExecutorArg) EnterCmdArgs

func (ea *ExecutorArg) EnterCmdArgs(pid int) []string

func (*ExecutorArg) EnterCmdCheckArgs

func (ea *ExecutorArg) EnterCmdCheckArgs(pid int) []string

func (*ExecutorArg) ExecCmdArgs

func (ea *ExecutorArg) ExecCmdArgs(args []string, env []string, interactive bool) []string

func (*ExecutorArg) HasImageArgs

func (ea *ExecutorArg) HasImageArgs() *args.T

func (*ExecutorArg) InspectArgs

func (ea *ExecutorArg) InspectArgs() *args.T

func (*ExecutorArg) InspectParser

func (ea *ExecutorArg) InspectParser(b []byte) (Inspecter, error)

func (*ExecutorArg) Log

func (ea *ExecutorArg) Log() *plog.Logger

func (*ExecutorArg) LogsArgs

func (ea *ExecutorArg) LogsArgs(follow bool, lines int) *args.T

func (*ExecutorArg) PullArgs

func (ea *ExecutorArg) PullArgs() *args.T

func (*ExecutorArg) RemoveArgs

func (ea *ExecutorArg) RemoveArgs() *args.T

func (*ExecutorArg) RunArgsBase

func (ea *ExecutorArg) RunArgsBase(ctx context.Context) (*args.T, error)

func (*ExecutorArg) RunArgsCommand

func (ea *ExecutorArg) RunArgsCommand() (*args.T, error)

func (*ExecutorArg) RunArgsImage

func (ea *ExecutorArg) RunArgsImage() (*args.T, error)

func (*ExecutorArg) RunCmdEnv

func (ea *ExecutorArg) RunCmdEnv() (map[string]string, error)

func (*ExecutorArg) StartArgs

func (ea *ExecutorArg) StartArgs(ctx context.Context) (*args.T, error)

func (*ExecutorArg) StopArgs

func (ea *ExecutorArg) StopArgs() *args.T

func (*ExecutorArg) WaitNotRunning

func (ea *ExecutorArg) WaitNotRunning(ctx context.Context) error

func (*ExecutorArg) WaitRemoved

func (ea *ExecutorArg) WaitRemoved(ctx context.Context) error

type ExecutorArgser

ExecutorArgser defines interfaces for container executor args. The ExecutorArgser interface is meant to define the required arguments or methods that a container executor should have, focusing on resource information. These arguments are used by executors to manage containers.

type ExecutorArgserGetter

type ExecutorArgserGetter interface {
	ExecutorArgser() ExecutorArgser
}

type ExecutorBaseArgser

type ExecutorBaseArgser interface {
	ExecBaseArgs() []string
}

ExecutorBaseArgser is an optional interface executor may implement to add base args to all doExecRun commands.

type ExecutorContainerArgser

type ExecutorContainerArgser interface {
	CpCmdArgs(string, string) []string
	EnterCmdArgs(pid int) []string
	EnterCmdCheckArgs(pid int) []string
	ExecCmdArgs([]string, []string, bool) []string
	RemoveArgs() *args.T
	RunArgsBase(ctx context.Context) (*args.T, error)
	RunArgsImage() (*args.T, error)
	RunArgsCommand() (*args.T, error)
	RunCmdEnv() (map[string]string, error)
	StartArgs(ctx context.Context) (*args.T, error)
	StopArgs() *args.T
}

ExecutorContainerArgser defines interfaces functions that provides args for container resource operations.

type ExecutorImageArgser

type ExecutorImageArgser interface {
	PullArgs() *args.T
}

ExecutorImageArgser defines interfaces functions that provides args for image operations.

type ExecutorInspectArgser

type ExecutorInspectArgser interface {
	HasImageArgs() *args.T
	InspectArgs() *args.T
	InspectParser([]byte) (Inspecter, error)
}

ExecutorInspectArgser defines interfaces functions that provides args for container resource inspect operations.

type ExecutorLogArgser

type ExecutorLogArgser interface {
	LogsArgs(follow bool, lines int) *args.T
}

ExecutorLogArgser defines interfaces functions that provides args for container resource log operations.

type InspectData

type InspectData struct {
	Id                    string
	Image                 string
	InspectDataConfig     InspectDataConfig     `json:"Config"`
	InspectDataHostConfig InspectDataHostConfig `json:"HostConfig"`
	NetworkSettings       struct {
		SandboxKey string
	}
	State InspectDataState
}

InspectData implements Inspecter

func (*InspectData) Config

func (i *InspectData) Config() *InspectDataConfig

func (*InspectData) Defined

func (i *InspectData) Defined() bool

func (*InspectData) ExitCode

func (i *InspectData) ExitCode() int

func (*InspectData) HostConfig

func (i *InspectData) HostConfig() *InspectDataHostConfig

func (*InspectData) ID

func (i *InspectData) ID() string

func (*InspectData) ImageID

func (i *InspectData) ImageID() string

func (*InspectData) PID

func (i *InspectData) PID() int

func (*InspectData) Running

func (i *InspectData) Running() bool

func (*InspectData) SandboxKey

func (i *InspectData) SandboxKey() string

func (*InspectData) Status

func (i *InspectData) Status() string

type InspectDataConfig

type InspectDataConfig struct {
	Entrypoint InspectDataConfigEntrypoint
	Hostname   string
	OpenStdin  bool
	Tty        bool
}

type InspectDataConfigEntrypoint

type InspectDataConfigEntrypoint []string

func (*InspectDataConfigEntrypoint) UnmarshalJSON

func (i *InspectDataConfigEntrypoint) UnmarshalJSON(b []byte) error

type InspectDataHostConfig

type InspectDataHostConfig struct {
	AutoRemove     bool
	IpcMode        string
	Privileged     bool
	NetworkMode    string
	PidMode        string
	ReadonlyRootfs bool
	UsernsMode     string
	UTSMode        string
}

type InspectDataState

type InspectDataState struct {
	ExitCode int
	Pid      int
	Running  bool
	Status   string
}

type Inspecter

type Inspecter interface {
	Config() *InspectDataConfig
	Defined() bool
	ID() string
	ImageID() string
	HostConfig() *InspectDataHostConfig
	ExitCode() int
	PID() int
	Running() bool
	SandboxKey() string
	Status() string
}

Inspecter defines interfaces functions that a container inspector must provide.

type Logger

type Logger interface {
	Log() *plog.Logger
}

Jump to

Keyboard shortcuts

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