containers

package
v1.2.0-rc3 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package containers provides shared testcontainers runtime setup (Podman/Docker socket, Ryuk, API version) for integration preflight and e2e auxiliary services.

Index

Constants

View Source
const E2EAuxHostEnv = "E2E_AUX_HOST"

E2EAuxHostEnv is the env var to override the host used for registry/git/prometheus (e.g. when the test VM has multiple NICs and the cluster is on a different interface).

Variables

This section is empty.

Functions

func ConfigureDockerHost

func ConfigureDockerHost()

ConfigureDockerHost sets up the container runtime environment for testcontainers. Call this from test setup (e.g. TestMain, e2e aux Get, preflight) or it runs lazily on first use of this package (RuntimeCLIName, GetDockerNetwork, etc.) via sync.Once.

func ContainerExistsByName

func ContainerExistsByName(name string) bool

ContainerExistsByName returns true if a container with the given name exists (running or stopped).

func ContainerRunningByName

func ContainerRunningByName(name string) bool

ContainerRunningByName returns true if a container with the given name exists and is running. Uses the same CLI selection as ContainerExistsByName (see auxiliary.Registry.Reused / E2E aux).

func GenericStart

GenericStart starts a container with the Flight Control testcontainers provider defaults.

func GetContainerHostname

func GetContainerHostname() string

GetContainerHostname returns the hostname for host access from inside containers.

func GetDockerNetwork

func GetDockerNetwork() string

GetDockerNetwork returns the network name for testcontainers (kind, host, podman, bridge).

func GetHostIP

func GetHostIP() string

GetHostIP returns the host's external IP for container access.

func GetProviderType

func GetProviderType() testcontainers.ProviderType

GetProviderType returns the testcontainers provider type based on the detected runtime.

func IsPodman

func IsPodman() bool

IsPodman reports whether the selected container runtime is Podman (same rule as RuntimeCLIName / DOCKER_HOST).

func NamePSFilter

func NamePSFilter(runtimeCLI, name string) string

NamePSFilter returns a docker|podman ps --filter value for a container by name. Podman applies the "name" filter as a regular expression, so an anchored, quoted pattern matches a single name even when the name could contain metacharacters.

Docker Engine typically treats the "name" filter as a plain substring, not a regex. Using "^...$" there matches nothing because '^' and '$' are taken literally, which breaks any helper that uses ps -f to detect an existing container (e2e registry reuse).

func RemoveContainerByName

func RemoveContainerByName(name string) error

RemoveContainerByName force-removes a container by name (best effort).

func RuntimeCLIName

func RuntimeCLIName() string

RuntimeCLIName returns the CLI binary that matches DOCKER_HOST.

Types

type ContainerRequestOption

type ContainerRequestOption func(*testcontainers.ContainerRequest)

ContainerRequestOption modifies a container request.

func WithHostAccess

func WithHostAccess() ContainerRequestOption

WithHostAccess adds host.containers.internal for Podman.

func WithNetwork

func WithNetwork(network string) ContainerRequestOption

WithNetwork sets the container network.

Jump to

Keyboard shortcuts

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