exec

package
v0.5.61 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2024 License: MPL-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const TypeExec string = "exec"

TypeExec is the resource string for an Exec resource

View Source
const TypeLocalExec string = "local_exec"

TypeExecLocal is the resource string for a LocalExec resource

View Source
const TypeRemoteExec string = "remote_exec"

TypeExecRemote is the resource string for a ExecRemote resource

Variables

This section is empty.

Functions

This section is empty.

Types

type Exec added in v0.5.55

type Exec struct {
	// embedded type holding name, etc
	types.ResourceMetadata `hcl:",remain"`

	Script           string            `hcl:"script" json:"script"`                                          // script to execute
	WorkingDirectory string            `hcl:"working_directory,optional" json:"working_directory,omitempty"` // Working directory to execute commands
	Daemon           bool              `hcl:"daemon,optional" json:"daemon,omitempty"`                       // Should the process run as a daemon
	Timeout          string            `hcl:"timeout,optional" json:"timeout,omitempty"`                     // Set the timeout for the command
	Environment      map[string]string `hcl:"environment,optional" json:"environment,omitempty"`             // environment variables to set

	// If remote, either Image or Target must be specified
	Image  *ctypes.Image     `hcl:"image,block" json:"image,omitempty"`      // Create a new container and exec
	Target *ctypes.Container `hcl:"target,optional" json:"target,omitempty"` // Attach to a running target and exec

	Networks []ctypes.NetworkAttachment `hcl:"network,block" json:"networks,omitempty"` // Attach to the correct network // only when Image is specified
	Volumes  []ctypes.Volume            `hcl:"volume,block" json:"volumes,omitempty"`   // Volumes to mount to container
	RunAs    *ctypes.User               `hcl:"run_as,block" json:"run_as,omitempty"`    // User block for mapping the user id and group id inside the container

	// output
	PID int `hcl:"pid,optional" json:"pid,omitempty"` // PID stores the ID of the created connector service if it is a local exec
}

Exec allows commands to be executed either locally or remotely

func (*Exec) Process added in v0.5.55

func (e *Exec) Process() error

type LocalExec

type LocalExec struct {
	// embedded type holding name, etc
	types.ResourceMetadata `hcl:",remain"`

	// Script []string `hcl:"script,optional" json:"script,omitempty"` // Script to execute
	Command          []string          `hcl:"command,optional" json:"command,omitempty"`                     // Command to execute
	WorkingDirectory string            `hcl:"working_directory,optional" json:"working_directory,omitempty"` // Working directory to execute commands
	Daemon           bool              `hcl:"daemon,optional" json:"daemon,omitempty"`                       // Should the process run as a daemon
	Timeout          string            `hcl:"timeout,optional" json:"timeout,omitempty"`                     // Set the timeout for the command
	Environment      map[string]string `hcl:"environment,optional" json:"environment,omitempty"`             // environment variables to set

	// Pid stores the ID of the created connector service
	Pid int `hcl:"pid,optional" json:"pid,omitempty"`
}

ExecLocal allows commands to be executed on the local machine

func (*LocalExec) Process

func (e *LocalExec) Process() error

type LocalProvider

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

ExecLocal provider allows the execution of arbitrary commands on the local machine

func (*LocalProvider) Changed

func (p *LocalProvider) Changed() (bool, error)

func (*LocalProvider) Create

func (p *LocalProvider) Create() error

Create a new exec

func (*LocalProvider) Destroy

func (p *LocalProvider) Destroy() error

Destroy satisfies the interface method but is not implemented by LocalExec

func (*LocalProvider) Init

func (p *LocalProvider) Init(cfg htypes.Resource, l sdk.Logger) error

Intit creates a new Local Exec provider

func (*LocalProvider) Lookup

func (p *LocalProvider) Lookup() ([]string, error)

Lookup satisfies the interface method but is not implemented by LocalExec

func (*LocalProvider) Refresh

func (p *LocalProvider) Refresh() error

type Provider added in v0.5.55

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

ExecRemote provider allows the execution of arbitrary commands on an existing target or can create a new container before running

func (*Provider) Changed added in v0.5.55

func (p *Provider) Changed() (bool, error)

func (*Provider) Create added in v0.5.55

func (p *Provider) Create() error

func (*Provider) Destroy added in v0.5.55

func (p *Provider) Destroy() error

func (*Provider) Init added in v0.5.55

func (p *Provider) Init(cfg htypes.Resource, l sdk.Logger) error

Intit creates a new Exec provider

func (*Provider) Lookup added in v0.5.55

func (p *Provider) Lookup() ([]string, error)

func (*Provider) Refresh added in v0.5.55

func (p *Provider) Refresh() error

type RemoteExec

type RemoteExec struct {
	types.ResourceMetadata `hcl:",remain"`

	Networks []ctypes.NetworkAttachment `hcl:"network,block" json:"networks,omitempty"` // Attach to the correct network // only when Image is specified

	// Either Image or Target must be specified
	Image  *ctypes.Image     `hcl:"image,block" json:"image,omitempty"`      // Create a new container and exec
	Target *ctypes.Container `hcl:"target,optional" json:"target,omitempty"` // Attach to a running target and exec

	// Either Script or Command must be specified
	Script           string `hcl:"script,optional" json:"script,omitempty"`                       // Path to a script to execute
	WorkingDirectory string `hcl:"working_directory,optional" json:"working_directory,omitempty"` // Working directory to execute commands

	Volumes     []ctypes.Volume   `hcl:"volume,block" json:"volumes,omitempty"`             // Volumes to mount to container
	Environment map[string]string `hcl:"environment,optional" json:"environment,omitempty"` // environment variables to set when starting the container

	// User block for mapping the user id and group id inside the container
	RunAs *ctypes.User `hcl:"run_as,block" json:"run_as,omitempty"`
}

ExecRemote allows commands to be executed in remote containers

func (*RemoteExec) Process

func (e *RemoteExec) Process() error

type RemoteProvider

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

ExecRemote provider allows the execution of arbitrary commands on an existing target or can create a new container before running

func (*RemoteProvider) Changed

func (p *RemoteProvider) Changed() (bool, error)

func (*RemoteProvider) Create

func (p *RemoteProvider) Create() error

Create a new execution instance

func (*RemoteProvider) Destroy

func (p *RemoteProvider) Destroy() error

Destroy satisfies the interface requirements but is not used as the resource is not persistent

func (*RemoteProvider) Init

func (p *RemoteProvider) Init(cfg htypes.Resource, l sdk.Logger) error

func (*RemoteProvider) Lookup

func (p *RemoteProvider) Lookup() ([]string, error)

Lookup satisfies the interface requirements but is not used as the resource is not persistent

func (*RemoteProvider) Refresh

func (p *RemoteProvider) Refresh() error

Jump to

Keyboard shortcuts

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