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 ¶
- type BT
- func (t *BT) Configure() error
- func (t *BT) ContainerID(ctx context.Context) string
- func (t *BT) ContainerInspect(ctx context.Context) (Inspecter, error)
- func (t *BT) ContainerInspectRefresh(ctx context.Context) (Inspecter, error)
- func (t *BT) ContainerLogs(ctx context.Context, follow bool, lines int) (<-chan []byte, error)
- func (t *BT) ContainerName() string
- func (t *BT) EncapCmd(ctx context.Context, args []string, env []string, stdin io.Reader) (resource.Commander, error)
- func (t *BT) EncapCp(ctx context.Context, src, dst string) error
- func (t *BT) Enter(ctx context.Context) error
- func (t *BT) Executer() Executer
- func (t *BT) FormatNS(s string) (string, error)
- func (t *BT) GenEnv(ctx context.Context) (envL []string, envM map[string]string, err error)
- func (t *BT) GetHostname() string
- func (t *BT) GetOsvcRootPath() string
- func (t *BT) IsAlwaysImagePullPolicy() bool
- func (t *BT) Label(_ context.Context) string
- func (t *BT) Labels() map[string]string
- func (t *BT) LinkNames() []string
- func (t *BT) ManifestWithID(drvID driver.ID) *manifest.T
- func (t *BT) Mounts(ctx context.Context) ([]BindMount, error)
- func (t *BT) NeedPreStartRemove() bool
- func (t *BT) NetNSPath(ctx context.Context) (string, error)
- func (t *BT) PID(ctx context.Context) int
- func (t *BT) Provision(_ context.Context) error
- func (t *BT) Provisioned(ctx context.Context) (provisioned.T, error)
- func (t *BT) RemoveContainer(ctx context.Context) error
- func (t *BT) Signal(ctx context.Context, sig syscall.Signal) error
- func (t *BT) Start(ctx context.Context) error
- func (t *BT) Status(ctx context.Context) status.T
- func (t *BT) StatusInfo(ctx context.Context) map[string]any
- func (t *BT) Stop(ctx context.Context) error
- func (t *BT) Unprovision(_ context.Context) error
- func (t *BT) WithExecuter(c Executer) *BT
- type BindMount
- type ExecuteContainer
- type ExecuteEncaper
- type ExecuteImager
- type ExecuteInspecter
- type ExecuteLogger
- type ExecuteWaiter
- type Executer
- type ExecuterGetter
- type Executor
- func (e *Executor) EncapCmd(ctx context.Context, args []string, env []string, stdin io.Reader) (*exec.Cmd, error)
- func (e *Executor) EncapCp(ctx context.Context, src, dst string) error
- func (e *Executor) Enter(ctx context.Context) error
- func (e *Executor) ExecutorArgser() ExecutorArgser
- func (e *Executor) HasImage(ctx context.Context) (bool, string, error)
- func (e *Executor) Inspect(ctx context.Context) (Inspecter, error)
- func (e *Executor) InspectRefresh(ctx context.Context) (Inspecter, error)
- func (e *Executor) Logs(ctx context.Context, follow bool, lines int) (<-chan []byte, error)
- func (e *Executor) Pull(ctx context.Context) error
- func (e *Executor) Remove(ctx context.Context) error
- func (e *Executor) Run(ctx context.Context) error
- func (e *Executor) Start(ctx context.Context) error
- func (e *Executor) Stop(ctx context.Context) error
- func (e *Executor) WaitNotRunning(ctx context.Context) error
- func (e *Executor) WaitRemoved(ctx context.Context) error
- type ExecutorArg
- func (ea *ExecutorArg) CpCmdArgs(src, dst string) []string
- func (ea *ExecutorArg) EnterCmdArgs(pid int) []string
- func (ea *ExecutorArg) EnterCmdCheckArgs(pid int) []string
- func (ea *ExecutorArg) ExecCmdArgs(args []string, env []string, interactive bool) []string
- func (ea *ExecutorArg) HasImageArgs() *args.T
- func (ea *ExecutorArg) InspectArgs() *args.T
- func (ea *ExecutorArg) InspectParser(b []byte) (Inspecter, error)
- func (ea *ExecutorArg) Log() *plog.Logger
- func (ea *ExecutorArg) LogsArgs(follow bool, lines int) *args.T
- func (ea *ExecutorArg) PullArgs() *args.T
- func (ea *ExecutorArg) RemoveArgs() *args.T
- func (ea *ExecutorArg) RunArgsBase(ctx context.Context) (*args.T, error)
- func (ea *ExecutorArg) RunArgsCommand() (*args.T, error)
- func (ea *ExecutorArg) RunArgsImage() (*args.T, error)
- func (ea *ExecutorArg) RunCmdEnv() (map[string]string, error)
- func (ea *ExecutorArg) StartArgs(ctx context.Context) (*args.T, error)
- func (ea *ExecutorArg) StopArgs() *args.T
- func (ea *ExecutorArg) WaitNotRunning(ctx context.Context) error
- func (ea *ExecutorArg) WaitRemoved(ctx context.Context) error
- type ExecutorArgser
- type ExecutorArgserGetter
- type ExecutorBaseArgser
- type ExecutorContainerArgser
- type ExecutorImageArgser
- type ExecutorInspectArgser
- type ExecutorLogArgser
- type InspectData
- func (i *InspectData) Config() *InspectDataConfig
- func (i *InspectData) Defined() bool
- func (i *InspectData) ExitCode() int
- func (i *InspectData) HostConfig() *InspectDataHostConfig
- func (i *InspectData) ID() string
- func (i *InspectData) ImageID() string
- func (i *InspectData) PID() int
- func (i *InspectData) Running() bool
- func (i *InspectData) SandboxKey() string
- func (i *InspectData) Status() string
- type InspectDataConfig
- type InspectDataConfigEntrypoint
- type InspectDataHostConfig
- type InspectDataState
- type Inspecter
- type Logger
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) ContainerID ¶
ContainerID returns the container inspect ID, or ""
func (*BT) ContainerInspectRefresh ¶
func (*BT) ContainerLogs ¶
func (*BT) ContainerName ¶
ContainerName formats a docker container name
func (*BT) GenEnv ¶
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 ¶
Implement the resource.Hostnamer interface, used by ip resources to obtain a hostname-based DNS record
func (*BT) GetOsvcRootPath ¶
func (*BT) IsAlwaysImagePullPolicy ¶
func (*BT) Label ¶
Label implements Label from resource.Driver interface, it returns a formatted short description of the Resource
func (*BT) ManifestWithID ¶
ManifestWithID exposes to the core the input expected by the driver.
func (*BT) NeedPreStartRemove ¶
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) Provisioned ¶
func (*BT) WithExecuter ¶
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 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 ¶
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 ¶
type Executer interface {
ExecuteContainer
ExecuteImager
ExecuteInspecter
ExecuteWaiter
ExecuteEncaper
ExecuteLogger
}
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) ExecutorArgser ¶
func (e *Executor) ExecutorArgser() ExecutorArgser
ExecutorArgser implements ExecutorArgserGetter for external tests
func (*Executor) Inspect ¶
Inspect returns Inspecter from cache. On cache miss a new Inspecter is created from InspectRefresh(ctx).
func (*Executor) InspectRefresh ¶
InspectRefresh creates new Inspecter (from inspect command line). It updates e Inspecter cache that may be used Inspect(ctx).
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) PullArgs ¶
func (ea *ExecutorArg) PullArgs() *args.T
func (*ExecutorArg) RemoveArgs ¶
func (ea *ExecutorArg) RemoveArgs() *args.T
func (*ExecutorArg) RunArgsBase ¶
func (*ExecutorArg) RunArgsCommand ¶
func (ea *ExecutorArg) RunArgsCommand() (*args.T, error)
func (*ExecutorArg) RunArgsImage ¶
func (ea *ExecutorArg) RunArgsImage() (*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 ¶
type ExecutorArgser interface {
ExecutorContainerArgser
ExecutorImageArgser
ExecutorInspectArgser
ExecutorLogArgser
ExecuteWaiter
}
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 ¶
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 ¶
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 InspectDataState ¶
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.