docker_test_vars.go 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package main
  2. import (
  3. "fmt"
  4. "os"
  5. "os/exec"
  6. )
  7. var (
  8. // the docker binary to use
  9. dockerBinary = "docker"
  10. // the private registry image to use for tests involving the registry
  11. registryImageName = "registry"
  12. // the private registry to use for tests
  13. privateRegistryURL = "127.0.0.1:5000"
  14. execDriverPath = "/var/lib/docker/execdriver/native"
  15. volumesConfigPath = "/var/lib/docker/volumes"
  16. workingDirectory string
  17. )
  18. func init() {
  19. if dockerBin := os.Getenv("DOCKER_BINARY"); dockerBin != "" {
  20. dockerBinary = dockerBin
  21. } else {
  22. whichCmd := exec.Command("which", "docker")
  23. out, _, err := runCommandWithOutput(whichCmd)
  24. if err == nil {
  25. dockerBinary = stripTrailingCharacters(out)
  26. } else {
  27. fmt.Printf("ERROR: couldn't resolve full path to the Docker binary")
  28. os.Exit(1)
  29. }
  30. }
  31. if registryImage := os.Getenv("REGISTRY_IMAGE"); registryImage != "" {
  32. registryImageName = registryImage
  33. }
  34. if registry := os.Getenv("REGISTRY_URL"); registry != "" {
  35. privateRegistryURL = registry
  36. }
  37. workingDirectory, _ = os.Getwd()
  38. }