2018-02-05 21:05:59 +00:00
|
|
|
package environment // import "github.com/docker/docker/integration-cli/environment"
|
2016-12-25 19:28:38 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
2017-03-23 17:35:22 +00:00
|
|
|
"os/exec"
|
2016-12-25 19:28:38 +00:00
|
|
|
|
2017-08-25 22:48:36 +00:00
|
|
|
"github.com/docker/docker/internal/test/environment"
|
2016-12-25 19:28:38 +00:00
|
|
|
)
|
|
|
|
|
2017-04-17 23:18:46 +00:00
|
|
|
var (
|
|
|
|
// DefaultClientBinary is the name of the docker binary
|
|
|
|
DefaultClientBinary = os.Getenv("TEST_CLIENT_BINARY")
|
2017-03-23 17:35:22 +00:00
|
|
|
)
|
|
|
|
|
2017-04-17 23:18:46 +00:00
|
|
|
func init() {
|
|
|
|
if DefaultClientBinary == "" {
|
|
|
|
DefaultClientBinary = "docker"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-25 22:48:36 +00:00
|
|
|
// Execution contains information about the current test execution and daemon
|
|
|
|
// under test
|
2016-12-25 19:28:38 +00:00
|
|
|
type Execution struct {
|
2017-08-25 22:48:36 +00:00
|
|
|
environment.Execution
|
2017-03-23 17:35:22 +00:00
|
|
|
dockerBinary string
|
2017-08-25 22:48:36 +00:00
|
|
|
}
|
2017-03-01 17:45:04 +00:00
|
|
|
|
2017-08-25 22:48:36 +00:00
|
|
|
// DockerBinary returns the docker binary for this testing environment
|
|
|
|
func (e *Execution) DockerBinary() string {
|
|
|
|
return e.dockerBinary
|
2016-12-25 19:28:38 +00:00
|
|
|
}
|
|
|
|
|
2017-08-25 22:48:36 +00:00
|
|
|
// New returns details about the testing environment
|
2016-12-25 19:28:38 +00:00
|
|
|
func New() (*Execution, error) {
|
2017-08-25 22:48:36 +00:00
|
|
|
env, err := environment.New()
|
2016-12-25 19:28:38 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2017-03-23 17:35:22 +00:00
|
|
|
|
2017-04-17 23:18:46 +00:00
|
|
|
dockerBinary, err := exec.LookPath(DefaultClientBinary)
|
2017-03-23 17:35:22 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2016-12-25 19:28:38 +00:00
|
|
|
return &Execution{
|
2017-08-25 22:48:36 +00:00
|
|
|
Execution: *env,
|
|
|
|
dockerBinary: dockerBinary,
|
2016-12-25 19:28:38 +00:00
|
|
|
}, nil
|
|
|
|
}
|