github.com/stchris/docker@v1.4.2-0.20150106053530-1510a324dbd5/integration-cli/docker_test_vars.go (about)

     1  package main
     2  
     3  import (
     4  	"fmt"
     5  	"os"
     6  	"os/exec"
     7  	"runtime"
     8  )
     9  
    10  var (
    11  	// the docker binary to use
    12  	dockerBinary = "docker"
    13  
    14  	// the private registry image to use for tests involving the registry
    15  	registryImageName = "registry"
    16  
    17  	// the private registry to use for tests
    18  	privateRegistryURL = "127.0.0.1:5000"
    19  
    20  	dockerBasePath       = "/var/lib/docker"
    21  	execDriverPath       = dockerBasePath + "/execdriver/native"
    22  	volumesConfigPath    = dockerBasePath + "/volumes"
    23  	volumesStoragePath   = dockerBasePath + "/vfs/dir"
    24  	containerStoragePath = dockerBasePath + "/containers"
    25  
    26  	workingDirectory string
    27  )
    28  
    29  func binarySearchCommand() *exec.Cmd {
    30  	if runtime.GOOS == "windows" {
    31  		// Windows where.exe is included since Windows Server 2003. It accepts
    32  		// wildcards, which we use here to match the development builds binary
    33  		// names (such as docker-$VERSION.exe).
    34  		return exec.Command("where.exe", "docker*.exe")
    35  	}
    36  	return exec.Command("which", "docker")
    37  }
    38  
    39  func init() {
    40  	if dockerBin := os.Getenv("DOCKER_BINARY"); dockerBin != "" {
    41  		dockerBinary = dockerBin
    42  	} else {
    43  		whichCmd := binarySearchCommand()
    44  		out, _, err := runCommandWithOutput(whichCmd)
    45  		if err == nil {
    46  			dockerBinary = stripTrailingCharacters(out)
    47  		} else {
    48  			fmt.Printf("ERROR: couldn't resolve full path to the Docker binary (%v)", err)
    49  			os.Exit(1)
    50  		}
    51  	}
    52  	if registryImage := os.Getenv("REGISTRY_IMAGE"); registryImage != "" {
    53  		registryImageName = registryImage
    54  	}
    55  	if registry := os.Getenv("REGISTRY_URL"); registry != "" {
    56  		privateRegistryURL = registry
    57  	}
    58  	workingDirectory, _ = os.Getwd()
    59  }