package testcontainersdocker
import "github.com/testcontainers/testcontainers-go/internal/testcontainersdocker"
Index ¶
- Constants
- Variables
- func DefaultGatewayIP() (string, error)
- func ExtractDockerHost(ctx context.Context) (dockerHostPath string)
- func ExtractImagesFromDockerfile(dockerfile string, buildArgs map[string]*string) ([]string, error)
- func ExtractRegistry(image string, fallback string) string
- func InAContainer() bool
- func IsURL(str string) bool
Constants ¶
const ( IndexDockerIO = "https://index.docker.io/v1/" URLSchema = `((ftp|tcp|udp|wss?|https?):\/\/)` URLUsername = `(\S+(:\S*)?@)` URLIP = `([1-9]\d?|1\d\d|2[01]\d|22[0-3]|24\d|25[0-5])(\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])){2}(?:\.([0-9]\d?|1\d\d|2[0-4]\d|25[0-5]))` IP = "" /* 661 byte string literal not displayed */ URLSubdomain = `((www\.)|([a-zA-Z0-9]+([-_\.]?[a-zA-Z0-9])*[a-zA-Z0-9]\.[a-zA-Z0-9]+))` URLPath = `((\/|\?|#)[^\s]*)` URLPort = `(:(\d{1,5}))` URL = `^` + URLSchema + `?` + URLUsername + `?` + `((` + URLIP + `|(\[` + IP + `\])|(([a-zA-Z0-9]([a-zA-Z0-9-_]+)?[a-zA-Z0-9]([-\.][a-zA-Z0-9]+)*)|(` + URLSubdomain + `?))?(([a-zA-Z\x{00a1}-\x{ffff}0-9]+-?-?)*[a-zA-Z\x{00a1}-\x{ffff}0-9]+)(?:\.([a-zA-Z\x{00a1}-\x{ffff}]{1,}))?))\.?` + URLPort + `?` + URLPath + `?$` )
const ( LabelBase = "org.testcontainers" LabelLang = LabelBase + ".lang" LabelReaper = LabelBase + ".reaper" LabelSessionID = LabelBase + ".sessionId" LabelVersion = LabelBase + ".version" )
Variables ¶
var DockerHostContextKey = dockerHostContext("docker_host")
Functions ¶
func DefaultGatewayIP ¶
func ExtractDockerHost ¶
Extracts the docker host from the context, or returns the default value
func ExtractImagesFromDockerfile ¶
func ExtractRegistry ¶
ExtractRegistry extracts the registry from the image name, using a regular expression to extract the registry from the image name. regular expression to extract the registry from the image name the regular expression is based on the grammar defined in - image:tag - image - repository/image:tag - repository/image - registry/image:tag - registry/image - registry/repository/image:tag - registry/repository/image - registry:port/repository/image:tag - registry:port/repository/image - registry:port/image:tag - registry:port/image Once extracted the registry, it is validated to check if it is a valid URL or an IP address.
func InAContainer ¶
func InAContainer() bool
InAContainer returns true if the code is running inside a container See https://github.com/docker/docker/blob/a9fa38b1edf30b23cae3eade0be48b3d4b1de14b/daemon/initlayer/setup_unix.go#L25
func IsURL ¶
IsURL checks if the string is an URL. Extracted from https://github.com/asaskevich/govalidator/blob/f21760c49a8d/validator.go#L104
Source Files ¶
docker_host.go images.go labels.go
- Version
- v0.19.0
- Published
- Mar 8, 2023
- Platform
- js/wasm
- Imports
- 9 packages
- Last checked
- 3 hours ago –
Tools for package owners.