environment.go 1009 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. var (
  8. // DefaultClientBinary is the name of the docker binary
  9. DefaultClientBinary = os.Getenv("TEST_CLIENT_BINARY")
  10. )
  11. func init() {
  12. if DefaultClientBinary == "" {
  13. DefaultClientBinary = "docker"
  14. }
  15. }
  16. // Execution contains information about the current test execution and daemon
  17. // under test
  18. type Execution struct {
  19. environment.Execution
  20. dockerBinary string
  21. }
  22. // DockerBinary returns the docker binary for this testing environment
  23. func (e *Execution) DockerBinary() string {
  24. return e.dockerBinary
  25. }
  26. // New returns details about the testing environment
  27. func New() (*Execution, error) {
  28. env, err := environment.New()
  29. if err != nil {
  30. return nil, err
  31. }
  32. dockerBinary, err := exec.LookPath(DefaultClientBinary)
  33. if err != nil {
  34. return nil, err
  35. }
  36. return &Execution{
  37. Execution: *env,
  38. dockerBinary: dockerBinary,
  39. }, nil
  40. }