testcontainersdocker

package
v0.20.1 Latest Latest
Warning

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

Go to latest
Published: May 10, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
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           = `` /* 659-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 + `?$`
)
View Source
const (
	LabelBase      = "org.testcontainers"
	LabelLang      = LabelBase + ".lang"
	LabelReaper    = LabelBase + ".reaper"
	LabelSessionID = LabelBase + ".sessionId"
	LabelVersion   = LabelBase + ".version"
)

Variables

View Source
var DockerHostContextKey = dockerHostContext("docker_host")

Functions

func ExtractDockerHost

func ExtractDockerHost(ctx context.Context) (dockerHostPath string)

Extracts the docker host from the context, or returns the default value

func ExtractImagesFromDockerfile added in v0.19.0

func ExtractImagesFromDockerfile(dockerfile string, buildArgs map[string]*string) ([]string, error)

func ExtractRegistry added in v0.19.0

func ExtractRegistry(image string, fallback string) string

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 added in v0.19.0

func IsURL(str string) bool

IsURL checks if the string is an URL. Extracted from https://github.com/asaskevich/govalidator/blob/f21760c49a8d/validator.go#L104

func NewClient added in v0.20.0

func NewClient(ctx context.Context, ops ...client.Opt) (*client.Client, error)

NewClient returns a new docker client with the default options

Types

This section is empty.

Jump to

Keyboard shortcuts

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