Documentation
¶
Index ¶
- func Initialize(errorHandler func(err error), traceHandler func(format string, a ...any))
- func ListTags(path string, baseURL string) []string
- type Controller
- func (c Controller) ContainerExists(id string) (exists bool)
- func (c Controller) ContainerFiles(id string, filespec string) (files []string)
- func (c Controller) ContainerRemove(id string) (err error)
- func (c Controller) ContainerRun(image string, env []string, port int, name string, hostname string, ...) string
- func (c Controller) ContainerRunning(id string) (running bool)
- func (c Controller) ContainerStart(id string) (err error)
- func (c Controller) ContainerStop(id string) (err error)
- func (c Controller) ContainerWaitForLogEntry(id string, text string)
- func (c Controller) DownloadFile(id string, src string, destFolder string)
- func (c Controller) EnsureImage(image string) (err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Initialize ¶
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.