Documentation
¶
Overview ¶
Package containers provides shared testcontainers runtime setup (Podman/Docker socket, Ryuk, API version) for integration preflight and e2e auxiliary services.
Index ¶
- Constants
- func ConfigureDockerHost()
- func ContainerExistsByName(name string) bool
- func ContainerRunningByName(name string) bool
- func GenericStart(ctx context.Context, req testcontainers.ContainerRequest, reuse bool, ...) (testcontainers.Container, error)
- func GetContainerHostname() string
- func GetDockerNetwork() string
- func GetHostIP() string
- func GetProviderType() testcontainers.ProviderType
- func IsPodman() bool
- func NamePSFilter(runtimeCLI, name string) string
- func RemoveContainerByName(name string) error
- func RuntimeCLIName() string
- type ContainerRequestOption
Constants ¶
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 ¶
ContainerExistsByName returns true if a container with the given name exists (running or stopped).
func ContainerRunningByName ¶
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 ¶
func GenericStart(ctx context.Context, req testcontainers.ContainerRequest, reuse bool, opts ...ContainerRequestOption) (testcontainers.Container, error)
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 ¶
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 ¶
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.