docker_test_vars.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. dockerBasePath = "/var/lib/docker"
  15. execDriverPath = dockerBasePath + "/execdriver/native"
  16. volumesConfigPath = dockerBasePath + "/volumes"
  17. volumesStoragePath = dockerBasePath + "/vfs/dir"
  18. workingDirectory string
  19. )
  20. func init() {
  21. if dockerBin := os.Getenv("DOCKER_BINARY"); dockerBin != "" {
  22. dockerBinary = dockerBin
  23. } else {
  24. whichCmd := exec.Command("which", "docker")
  25. out, _, err := runCommandWithOutput(whichCmd)
  26. if err == nil {
  27. dockerBinary = stripTrailingCharacters(out)
  28. } else {
  29. fmt.Printf("ERROR: couldn't resolve full path to the Docker binary")
  30. os.Exit(1)
  31. }
  32. }
  33. if registryImage := os.Getenv("REGISTRY_IMAGE"); registryImage != "" {
  34. registryImageName = registryImage
  35. }
  36. if registry := os.Getenv("REGISTRY_URL"); registry != "" {
  37. privateRegistryURL = registry
  38. }
  39. workingDirectory, _ = os.Getwd()
  40. }