Documentation ¶
Index ¶
- Constants
- func StrPtr(str string) *string
- type BuildOpts
- type Client
- func (c *Client) Build(opts *BuildOpts) error
- func (c *Client) EnsureImage(image string) error
- func (c *Client) GetFileFromVolume(volume operatingsystem.Volume, volumeMnt string, path string) (io.Reader, error)
- func (c *Client) MustCreateVolume() operatingsystem.Volume
- func (c *Client) MustRemoveVolumes(volumeNames ...operatingsystem.Volume)
- func (c *Client) Run(opts *RunOpts) (containerOut string, err error)
- func (c *Client) WriteFileToVolume(volume operatingsystem.Volume, volumeMnt string, path string, contents string) error
- type RunOpts
Constants ¶
const ( // BusyBoxImage is the image to use for BusyBox, this is used as the smallest Docker image that we can create a container from. // We cannot use scratch unless we build our own blank image from scratch, which adds more complexity. BusyBoxImage = "docker.io/library/busybox:1.33.1" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client abstracts the docker client into useful functions.
func MustClient ¶
func MustClient() *Client
MustClient returns a new docker client, fatally logging any errors.
func (*Client) EnsureImage ¶
EnsureImage ensures that the given image exists locally in Docker and can be used for creating containers by checking if the given image exists, pulling it if not.
func (*Client) GetFileFromVolume ¶
func (c *Client) GetFileFromVolume(volume operatingsystem.Volume, volumeMnt string, path string) (io.Reader, error)
GetFileFromVolume returns a reader for the contents of a file in the given volume and path. TODO: split into smaller functions
func (*Client) MustCreateVolume ¶
func (c *Client) MustCreateVolume() operatingsystem.Volume
MustCreateVolume creates a new docker volume and returns its name, fatally logging any errors.
func (*Client) MustRemoveVolumes ¶
func (c *Client) MustRemoveVolumes(volumeNames ...operatingsystem.Volume)
MustRemoveVolumes removes the given volumes, fatally logging any errors.
func (*Client) Run ¶
Run runs the given docker image, returning its output as a string. TODO: break down into smaller functions
func (*Client) WriteFileToVolume ¶
func (c *Client) WriteFileToVolume(volume operatingsystem.Volume, volumeMnt string, path string, contents string) error
WriteFileToVolume writes the given contents to the given path with the given volume and its mount point. TODO: split into smaller functions
type RunOpts ¶
type RunOpts struct { Image string Entrypoint []string Cmd []string // Volumes are volumes to mount to the container in the format <volume name>:<mount path>. Volumes map[operatingsystem.Volume]string WorkingDir string Env map[string]string }
RunOpts abstracts the Docker API away from the end-user.