docker_test_vars.go 1003 B

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