docker

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 26, 2024 License: MIT Imports: 8 Imported by: 2

README

ExecFunc: Docker 🐳

This allows for executing nescript Cmds and Scripts on Docker container targets denoted by their container ID. For this, an initialized docker client must also be provided.

There are some quirks when using the Docker ExecFunc:

  • Any subprocess spawned by a Cmd, or any Script executed will have access to the containers Env vars by default.
  • Metrics can not be obtained, specifically timing data as is possible with local script execution.

Example

containerID := "abcdef0123"
dockerClient, err := client.NewClientWithOpts(client.FromEnv)
if err != nil {
	panic(err)
}
dockerExecutor := docker.Executor(dockerClient, containerID, "")

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Executor

func Executor(client *docker.Client, containerID, workdir string) nescript.ExecFunc

Executor provides an ExecFunc that will start the script/cmd process in the docker container with the given container ID. An initialized docker client must also be passed for communication with the relevant docker engine. Optionally, a WorkDir may be set, setting the precess working directory (path should be in the context of the container's file system). This ExecFunc does not require that the cmd/script be converted to a string, so is Formatter agnostic.

Types

type DockerProcess

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

func (*DockerProcess) Close

func (p *DockerProcess) Close()

func (*DockerProcess) Kill

func (p *DockerProcess) Kill() error

func (*DockerProcess) Result

func (p *DockerProcess) Result() (*nescript.Result, error)

func (*DockerProcess) Signal

func (p *DockerProcess) Signal(s os.Signal) error

func (*DockerProcess) Write

func (p *DockerProcess) Write(input string) error

Jump to

Keyboard shortcuts

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