docker

package
v0.0.0-...-73fc7c8 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2023 License: MIT Imports: 8 Imported by: 0

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