container

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Initialize

func Initialize(
	errorHandler func(err error),
	traceHandler func(format string, a ...any))

func ListTags

func ListTags(path string, baseURL string) []string

ListTags lists all tags for a container image located at a given path in the container registry. It takes the path to the image and the URL of the registry as input and returns a slice of strings containing the tags.

Types

type Controller

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

func NewController

func NewController() (c *Controller)

NewController creates a new Controller struct, which is used to interact with a container runtime engine (e.g. Docker or Podman etc.). It initializes engine client by calling client.NewClientWithOpts(client.FromEnv) and setting the cli field of the Controller struct to the result. The Controller struct is then returned.

func (Controller) ContainerExists

func (c Controller) ContainerExists(id string) (exists bool)

ContainerExists checks if a container with the given ID exists in the system. It does this by using the container runtime API to list all containers and filtering by the given ID. If a container with the given ID is found, it returns true; otherwise, it returns false.

func (Controller) ContainerFiles

func (c Controller) ContainerFiles(id string, filespec string) (files []string)

ContainerFiles returns a list of files matching a specified pattern within a given container. It takes an id argument, which specifies the ID of the container to search, and a filespec argument, which is a string pattern used to match files within the container. The function returns a []string slice containing the names of all files that match the specified pattern.

func (Controller) ContainerRemove

func (c Controller) ContainerRemove(id string) (err error)

ContainerRemove removes the container with the specified ID using the container runtime API. The function takes the ID of the container to be removed as an input argument, and returns an error if one occurs during the removal process.

func (Controller) ContainerRun

func (c Controller) ContainerRun(
	image string,
	env []string,
	port int,
	name string,
	hostname string,
	architecture string,
	os string,
	command []string,
	unitTestFailure bool,
) string

ContainerRun creates a new container using the provided image and env values and binds it to the specified port number. It then starts the container and returns the ID of the container.

func (Controller) ContainerRunning added in v0.13.0

func (c Controller) ContainerRunning(id string) (running bool)

ContainerRunning returns true if the container with the given ID is running. It returns false if the container is not running or if there is an issue getting the container's status.

func (Controller) ContainerStart added in v0.13.0

func (c Controller) ContainerStart(id string) (err error)

ContainerStart starts the container with the given ID. The function returns an error if there is an issue starting the container.

func (Controller) ContainerStop

func (c Controller) ContainerStop(id string) (err error)

ContainerStop stops the container with the given ID. The function returns an error if there is an issue stopping the container.

func (Controller) ContainerWaitForLogEntry

func (c Controller) ContainerWaitForLogEntry(id string, text string)

ContainerWaitForLogEntry is used to wait for a specific string to be written to the logs of a container with the given ID. The function takes in the ID of the container and the string to look for in the logs. It creates a reader to stream the logs from the container, and scans the logs line by line until it finds the specified string. Once the string is found, the function breaks out of the loop and returns.

This function is useful for waiting until a specific event has occurred in the container (e.g. a server has started up) before continuing with other operations.

func (Controller) DownloadFile added in v0.13.0

func (c Controller) DownloadFile(id string, src string, destFolder string)

func (Controller) EnsureImage

func (c Controller) EnsureImage(image string) (err error)

EnsureImage creates a new instance of the Controller struct and initializes the container engine client by calling client.NewClientWithOpts() with the client.FromEnv option. It returns the Controller instance and an error if one occurred while creating the client. The Controller struct has a method EnsureImage() which pulls an image with the given name from a registry and logs the output to the console.

Jump to

Keyboard shortcuts

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