environment.go 1003 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. package environment // import "github.com/docker/docker/integration-cli/environment"
  2. import (
  3. "os"
  4. "os/exec"
  5. "github.com/docker/docker/testutil/environment"
  6. )
  7. // DefaultClientBinary is the name of the docker binary
  8. var DefaultClientBinary = os.Getenv("TEST_CLIENT_BINARY")
  9. func init() {
  10. if DefaultClientBinary == "" {
  11. DefaultClientBinary = "docker"
  12. }
  13. }
  14. // Execution contains information about the current test execution and daemon
  15. // under test
  16. type Execution struct {
  17. environment.Execution
  18. dockerBinary string
  19. }
  20. // DockerBinary returns the docker binary for this testing environment
  21. func (e *Execution) DockerBinary() string {
  22. return e.dockerBinary
  23. }
  24. // New returns details about the testing environment
  25. func New() (*Execution, error) {
  26. env, err := environment.New()
  27. if err != nil {
  28. return nil, err
  29. }
  30. dockerBinary, err := exec.LookPath(DefaultClientBinary)
  31. if err != nil {
  32. return nil, err
  33. }
  34. return &Execution{
  35. Execution: *env,
  36. dockerBinary: dockerBinary,
  37. }, nil
  38. }