2016-12-25 14:28:38 -05:00
|
|
|
package environment
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
2017-08-25 18:48:36 -04:00
|
|
|
|
2017-03-23 13:35:22 -04:00
|
|
|
"os/exec"
|
2016-12-25 14:28:38 -05:00
|
|
|
|
2017-08-25 18:48:36 -04:00
|
|
|
"github.com/docker/docker/internal/test/environment"
|
2016-12-25 14:28:38 -05:00
|
|
|
)
|
|
|
|
|
2017-04-17 19:18:46 -04:00
|
|
|
var (
|
|
|
|
// DefaultClientBinary is the name of the docker binary
|
|
|
|
DefaultClientBinary = os.Getenv("TEST_CLIENT_BINARY")
|
2017-03-23 13:35:22 -04:00
|
|
|
)
|
|
|
|
|
2017-04-17 19:18:46 -04:00
|
|
|
func init() {
|
|
|
|
if DefaultClientBinary == "" {
|
|
|
|
DefaultClientBinary = "docker"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-25 18:48:36 -04:00
|
|
|
// Execution contains information about the current test execution and daemon
|
|
|
|
// under test
|
2016-12-25 14:28:38 -05:00
|
|
|
type Execution struct {
|
2017-08-25 18:48:36 -04:00
|
|
|
environment.Execution
|
2017-03-23 13:35:22 -04:00
|
|
|
dockerBinary string
|
2017-08-25 18:48:36 -04:00
|
|
|
}
|
2017-03-01 12:45:04 -05:00
|
|
|
|
2017-08-25 18:48:36 -04:00
|
|
|
// DockerBinary returns the docker binary for this testing environment
|
|
|
|
func (e *Execution) DockerBinary() string {
|
|
|
|
return e.dockerBinary
|
2016-12-25 14:28:38 -05:00
|
|
|
}
|
|
|
|
|
2017-08-25 18:48:36 -04:00
|
|
|
// New returns details about the testing environment
|
2016-12-25 14:28:38 -05:00
|
|
|
func New() (*Execution, error) {
|
2017-08-25 18:48:36 -04:00
|
|
|
env, err := environment.New()
|
2016-12-25 14:28:38 -05:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2017-03-23 13:35:22 -04:00
|
|
|
|
2017-04-17 19:18:46 -04:00
|
|
|
dockerBinary, err := exec.LookPath(DefaultClientBinary)
|
2017-03-23 13:35:22 -04:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2016-12-25 14:28:38 -05:00
|
|
|
return &Execution{
|
2017-08-25 18:48:36 -04:00
|
|
|
Execution: *env,
|
|
|
|
dockerBinary: dockerBinary,
|
2016-12-25 14:28:38 -05:00
|
|
|
}, nil
|
|
|
|
}
|
2017-08-25 18:48:36 -04:00
|
|
|
|
|
|
|
// 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
|
2016-12-25 14:28:38 -05:00
|
|
|
}
|
|
|
|
|
2017-08-25 18:48:36 -04:00
|
|
|
// 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
|
2016-12-25 14:28:38 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// 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.
|
2017-09-20 08:47:49 -04:00
|
|
|
// Deprecated: use Execution.OSType
|
2016-12-25 14:28:38 -05:00
|
|
|
func (e *Execution) DaemonPlatform() string {
|
2017-09-20 08:47:49 -04:00
|
|
|
return e.OSType
|
2016-12-25 14:28:38 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// MinimalBaseImage is the image used for minimal builds (it depends on the platform)
|
2017-08-25 18:48:36 -04:00
|
|
|
// Deprecated: use Execution.PlatformDefaults.BaseImage
|
2016-12-25 14:28:38 -05:00
|
|
|
func (e *Execution) MinimalBaseImage() string {
|
2017-08-25 18:48:36 -04:00
|
|
|
return e.PlatformDefaults.BaseImage
|
2017-03-23 13:35:22 -04:00
|
|
|
}
|