environment.go 1.0 KB

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