Documentation
¶
Index ¶
- Variables
- func New(log hclog.Logger) drivers.DriverPlugin
- type Config
- type Plugin
- func (*Plugin) Capabilities() (*drivers.Capabilities, error)
- func (*Plugin) ConfigSchema() (*hclspec.Spec, error)
- func (p *Plugin) DestroyTask(taskID string, force bool) error
- func (p *Plugin) ExecTask(taskID string, cmd []string, timeout time.Duration) (*drivers.ExecTaskResult, error)
- func (p *Plugin) ExecTaskStreamingRaw(ctx context.Context, taskID string, command []string, tty bool, ...) error
- func (p *Plugin) Fingerprint(ctx context.Context) (<-chan *drivers.Fingerprint, error)
- func (p *Plugin) InspectTask(taskID string) (*drivers.TaskStatus, error)
- func (*Plugin) PluginInfo() (*base.PluginInfoResponse, error)
- func (p *Plugin) RecoverTask(handle *drivers.TaskHandle) error
- func (p *Plugin) SetConfig(c *base.Config) error
- func (p *Plugin) SignalTask(taskID, signal string) error
- func (p *Plugin) StartTask(config *drivers.TaskConfig) (*drivers.TaskHandle, *drivers.DriverNetwork, error)
- func (p *Plugin) StopTask(taskID string, timeout time.Duration, signal string) error
- func (*Plugin) TaskConfigSchema() (*hclspec.Spec, error)
- func (*Plugin) TaskEvents(ctx context.Context) (<-chan *drivers.TaskEvent, error)
- func (p *Plugin) TaskStats(ctx context.Context, taskID string, interval time.Duration) (<-chan *drivers.TaskResourceUsage, error)
- func (p *Plugin) WaitTask(ctx context.Context, taskID string) (<-chan *drivers.ExitResult, error)
- type TaskConfig
Constants ¶
This section is empty.
Variables ¶
var PluginConfig = &loader.InternalPluginConfig{ Config: make(map[string]any), Factory: func(_ context.Context, l hclog.Logger) any { return New(l) }, }
PluginConfig is the exec driver factory function registered in the plugin catalog.
var PluginID = loader.PluginID{ Name: name, PluginType: base.PluginTypeDriver, }
PluginID is the exec plugin metadata registered in the plugin catalog.
Functions ¶
Types ¶
type Config ¶
type Config struct {
UnveilDefaults bool `codec:"unveil_defaults"`
UnveilPaths []string `codec:"unveil_paths"`
UnveilByTask bool `codec:"unveil_by_task"`
AllowCaps []string `codec:"allow_caps"`
}
Config represents the exec2 driver plugin configuration that gets set in the Nomad client configuration file.
type Plugin ¶
type Plugin struct {
// contains filtered or unexported fields
}
func (*Plugin) Capabilities ¶
func (*Plugin) Capabilities() (*drivers.Capabilities, error)
func (*Plugin) DestroyTask ¶
DestroyTask will stop the given task if necessary and remove its state from memory. If the task is currently running it will only be stopped and removed if the force option is set.
func (*Plugin) ExecTask ¶
func (p *Plugin) ExecTask(taskID string, cmd []string, timeout time.Duration) (*drivers.ExecTaskResult, error)
ExecTask runs cmd synchronously inside the running task's Linux namespaces and returns the buffered stdout, stderr, and exit code. It is used by Nomad for script checks.
func (*Plugin) ExecTaskStreamingRaw ¶ added in v0.2.0
func (p *Plugin) ExecTaskStreamingRaw( ctx context.Context, taskID string, command []string, tty bool, stream drivers.ExecTaskStream, ) error
ExecTaskStreamingRaw services the driver ExecTaskStreaming RPC via the drivers.ExecTaskStreamingRawDriver interface. It enters the task's namespaces with nsenter and runs the command, handling both requests: when tty is true it allocates a PTY for an interactive shell, otherwise it wires stdin/stdout/stderr over pipes.
func (*Plugin) Fingerprint ¶
func (*Plugin) InspectTask ¶
func (p *Plugin) InspectTask(taskID string) (*drivers.TaskStatus, error)
InspectTask returns status information for the task associated with the given taskID.
func (*Plugin) PluginInfo ¶
func (*Plugin) PluginInfo() (*base.PluginInfoResponse, error)
func (*Plugin) RecoverTask ¶
func (p *Plugin) RecoverTask(handle *drivers.TaskHandle) error
RecoverTask will re-create the in-memory state of a task from a TaskHandle coming from Nomad.
func (*Plugin) SignalTask ¶
SignalTask will use the kill() syscall to send signal to the unix process of the task.
func (*Plugin) StartTask ¶
func (p *Plugin) StartTask(config *drivers.TaskConfig) (*drivers.TaskHandle, *drivers.DriverNetwork, error)
StartTask will setup the environment for and then launch the actual unix process of the task. This information will be encoded into, stored as, and returned as a task handle.
func (*Plugin) StopTask ¶
StopTask will issue the given signal to the task, followed by KILL if the process does not exit within the given timeout.
func (*Plugin) TaskEvents ¶
TaskEvents produces an empty chan of TaskEvents.
type TaskConfig ¶
type TaskConfig struct {
Command string `codec:"command"`
Args []string `codec:"args"`
Unveil []string `codec:"unveil"`
OOMScoreAdj int `codec:"oom_score_adj"`
CapAdd []string `codec:"cap_add"`
CapDrop []string `codec:"cap_drop"`
WorkDir string `codec:"work_dir"`
}
TaskConfig represents the exec2 driver task configuration that gets set in a Nomad job file.