1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00
moby--moby/integration-cli/environment/environment.go
Daniel Nephin f85ef42ea5 Refactor test environment
split all non-cli portions into a new internal/test/environment package

Set a test environment on packages instead of creating new ones.

Signed-off-by: Daniel Nephin <dnephin@docker.com>
2017-08-30 13:13:18 -04:00

79 lines
2 KiB
Go

package environment
import (
"os"
"os/exec"
"github.com/docker/docker/internal/test/environment"
)
var (
// DefaultClientBinary is the name of the docker binary
DefaultClientBinary = os.Getenv("TEST_CLIENT_BINARY")
)
func init() {
if DefaultClientBinary == "" {
DefaultClientBinary = "docker"
}
}
// Execution contains information about the current test execution and daemon
// under test
type Execution struct {
environment.Execution
dockerBinary string
}
// DockerBinary returns the docker binary for this testing environment
func (e *Execution) DockerBinary() string {
return e.dockerBinary
}
// New returns details about the testing environment
func New() (*Execution, error) {
env, err := environment.New()
if err != nil {
return nil, err
}
dockerBinary, err := exec.LookPath(DefaultClientBinary)
if err != nil {
return nil, err
}
return &Execution{
Execution: *env,
dockerBinary: dockerBinary,
}, nil
}
// DockerBasePath is the base path of the docker folder (by default it is -/var/run/docker)
// TODO: remove
// Deprecated: use Execution.DaemonInfo.DockerRootDir
func (e *Execution) DockerBasePath() string {
return e.DaemonInfo.DockerRootDir
}
// ExperimentalDaemon tell whether the main daemon has
// experimental features enabled or not
// Deprecated: use DaemonInfo.ExperimentalBuild
func (e *Execution) ExperimentalDaemon() bool {
return e.DaemonInfo.ExperimentalBuild
}
// DaemonPlatform is held globally so that tests can make intelligent
// decisions on how to configure themselves according to the platform
// of the daemon. This is initialized in docker_utils by sending
// a version call to the daemon and examining the response header.
// Deprecated: use Execution.DaemonInfo.OSType
func (e *Execution) DaemonPlatform() string {
return e.DaemonInfo.OSType
}
// MinimalBaseImage is the image used for minimal builds (it depends on the platform)
// Deprecated: use Execution.PlatformDefaults.BaseImage
func (e *Execution) MinimalBaseImage() string {
return e.PlatformDefaults.BaseImage
}