Documentation ¶
Index ¶
- Constants
- Variables
- func ObserveState(ctx context.Context, socket string) (<-chan State, error)
- type BuildConfig
- type CLIClient
- func (c *CLIClient) BuildConfig() (*BuildConfig, error)
- func (c *CLIClient) Create(id, bundle string, stdin, tty bool, flags ...string) (io.WriteCloser, error)
- func (c *CLIClient) Delete(id string) error
- func (c *CLIClient) Exec(ctx context.Context, id string, stdin io.Reader, stdout, stderr io.Writer, ...) error
- func (c *CLIClient) ExecSync(ctx context.Context, id string, args, envs []string) (*ExecResponse, error)
- func (c *CLIClient) Kill(id string, force bool) error
- func (c *CLIClient) PrepareExec(ctx context.Context, id string, args, envs []string) *exec.Cmd
- func (c *CLIClient) Signal(id, sig string) error
- func (c *CLIClient) Start(id string) error
- func (c *CLIClient) State(id string) (*ociruntime.State, error)
- func (c *CLIClient) UpdateContainerResources(id string, req *specs.LinuxResources) error
- type ExecResponse
- type State
Constants ¶
const ( // LogLevelEnv name for env on which client relies while selecting log level. LogLevelEnv = "SINGULARITY_LOG_LEVEL" // LogLevelDebug singularity client will be launched with -d flag. LogLevelDebug = "debug" )
Variables ¶
var ErrNotFound = fmt.Errorf("no instance found for provided name")
ErrNotFound us returned when Singularity OCI engine responds with corresponding error message and exit status 255
Functions ¶
func ObserveState ¶
ObserveState listens on passed socket for container state changes and passes them to the channel. ObserveState creates socket if necessary. The returned channel is buffered to eliminate any goroutine leaks. The channel will be closed if either container has transmitted into StateExited or any error during networking occurred. ObserveState returns error only if it fails to start listener on the passed socket.
Types ¶
type BuildConfig ¶
type BuildConfig struct {
SingularityConfdir string
}
BuildConfig is Singularity's build configuration.
type CLIClient ¶
type CLIClient struct {
// contains filtered or unexported fields
}
CLIClient is a type for convenient interaction with singularity OCI runtime engine via CLI.
func (*CLIClient) BuildConfig ¶
func (c *CLIClient) BuildConfig() (*BuildConfig, error)
BuildConfig returns configuration which was used to build current Singularity installation.
func (*CLIClient) Create ¶
func (c *CLIClient) Create(id, bundle string, stdin, tty bool, flags ...string) (io.WriteCloser, error)
Create asks runtime to create a container with passed parameters. When stdin is false no stdin stream is allocated and all reads from stdin in the container will always result in EOF. When no tty is allocated by the runtime, Create returns master end of the allocated tty (need to allocate it to separate stderr) that can be used to propagate any input into container, if stdin was requested. Master end should be closed as soon as container is not running any more. For pod master end can be closed immediately.
func (*CLIClient) Delete ¶
Delete asks runtime to delete container with passed id. If runtime fails to find object with given id, ErrNotFound is returned.
func (*CLIClient) Exec ¶
func (c *CLIClient) Exec(ctx context.Context, id string, stdin io.Reader, stdout, stderr io.Writer, args, envs []string) error
Exec executes passed command inside a container setting io streams to passed ones.
func (*CLIClient) ExecSync ¶
func (c *CLIClient) ExecSync(ctx context.Context, id string, args, envs []string) (*ExecResponse, error)
ExecSync executes a command inside a container synchronously until context is done and returns the result.
func (*CLIClient) Kill ¶
Kill asks runtime to send SIGINT to container with passed id. If force is true that SIGKILL is sent instead.
func (*CLIClient) PrepareExec ¶
PrepareExec simply prepares command to call to execute inside a given container. It makes sure singularity exec script is called.
func (*CLIClient) State ¶
func (c *CLIClient) State(id string) (*ociruntime.State, error)
State returns state of a container with passed id. If runtime fails to find object with given id, ErrNotFound is returned.
func (*CLIClient) UpdateContainerResources ¶
UpdateContainerResources asks runtime to update container resources according to the passed parameter.
type ExecResponse ¶
type ExecResponse struct { // Captured command stdout output. Stdout []byte // Captured command stderr output. Stderr []byte // Exit code the command finished with. ExitCode int32 }
ExecResponse holds result of command execution inside a container.
type State ¶
type State int
State represents an OCI container state.
const ( // StateUnknown means current state is unknown (perhaps, something went wrong). StateUnknown State = iota // StateCreating means container is being created at the moment. StateCreating // StateCreated means container is created without any errors. StateCreated // StateRunning means container is running at the moment. StateRunning // StateExited means container has finished possibly with errors. StateExited )
func StatusToState ¶
StatusToState is a helper func to convert container OCI status to State.