2018-02-05 16:05:59 -05:00
|
|
|
package environment // import "github.com/docker/docker/integration-cli/environment"
|
2016-12-25 14:28:38 -05:00
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
2017-03-23 13:35:22 -04:00
|
|
|
"os/exec"
|
2016-12-25 14:28:38 -05:00
|
|
|
|
2019-08-29 16:52:40 -04:00
|
|
|
"github.com/docker/docker/testutil/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
|
|
|
|
}
|