MCPcopy
hub / github.com/ContainerSSH/ContainerSSH / containerFromBuild

Function containerFromBuild

internal/test/docker.go:40–68  ·  view source on GitHub ↗

containerFromBuild starts a container from a local image build. - imageTag specifies the name the built image should be tagged as. - files specifies the list of local files to send as part of the build context. - cmd specifies the command line in execv format if any. - env specifies the environment

(
	t *testing.T,
	imageTag string,
	files map[string][]byte,
	cmd []string,
	env []string,
	ports map[string]string,
)

Source from the content-addressed store, hash-verified

38// - ports specifies the port mappings. The key is the container port, the value is the host port.
39// If the host port is left empty it is automatically mapped and can be retrieved later.
40func containerFromBuild(
41 t *testing.T,
42 imageTag string,
43 files map[string][]byte,
44 cmd []string,
45 env []string,
46 ports map[string]string,
47) container {
48 t.Helper()
49 t.Logf("Creating and starting a container from local build...")
50
51 cnt := &dockerContainer{
52 client: dockerClient(t),
53 files: files,
54 image: imageTag,
55 t: t,
56 cmd: cmd,
57 env: env,
58 ports: ports,
59 }
60
61 cnt.build()
62 cnt.create()
63 t.Cleanup(cnt.remove)
64 cnt.start()
65 cnt.inspect()
66
67 return cnt
68}
69
70// containerFromBuild starts a container from an image pulled from a registry
71//

Callers 3

SSHFunction · 0.85
KerberosFunction · 0.85
RegistryFunction · 0.85

Calls 7

buildMethod · 0.95
createMethod · 0.95
startMethod · 0.95
inspectMethod · 0.95
CleanupMethod · 0.80
dockerClientFunction · 0.70
LogfMethod · 0.65

Tested by

no test coverage detected