func getVersionDir(version dockerversion.Version) string { versionPath := version.SemVer.String() if version.IsExperimental() { versionPath = dockerversion.ExperimentalAlias } return filepath.Join(getVersionsDir(), versionPath) }
func use(version dockerversion.Version) { writeDebug("dvm use %s", version) if version.IsEmpty() { die("The use command requires that a version is specified or the DOCKER_VERSION environment variable is set.", nil, retCodeInvalidOperation) } if version.HasAlias() && aliasExists(version.Alias) { aliasedVersion, _ := ioutil.ReadFile(getAliasPath(version.Alias)) version.SemVer = semver.MustParse(string(aliasedVersion)) writeDebug("Using alias: %s -> %s", version.Alias, version.SemVer) } ensureVersionIsInstalled(version) if version.IsSystem() { version, _ = getSystemDockerVersion() } else if version.IsExperimental() { version, _ = getExperimentalDockerVersion() } removePreviousDockerVersionFromPath() if !version.IsSystem() { prependDockerVersionToPath(version) } writePathScript() writeInfo("Now using Docker %s", version) }
func versionExists(version dockerversion.Version) bool { if version.IsExperimental() { return true } availableVersions := getAvailableVersions(version.SemVer.String()) for _, availableVersion := range availableVersions { if version.Equals(availableVersion) { return true } } return false }
func buildDownloadURL(version dockerversion.Version) string { dockerVersion := version.SemVer.String() if version.IsExperimental() { dockerVersion = "latest" } if mirrorURL == "" { mirrorURL = "https://get.docker.com/builds" if version.IsExperimental() { writeDebug("Downloading from experimental builds mirror") mirrorURL = "https://experimental.docker.com/builds" } } // New Docker versions are released in a zip file, vs. the old way of releasing the client binary only if version.ShouldUseArchivedRelease() { return fmt.Sprintf("%s/%s/%s/docker-%s%s", mirrorURL, dockerOS, dockerArch, dockerVersion, archiveFileExt) } return fmt.Sprintf("%s/%s/%s/docker-%s%s", mirrorURL, dockerOS, dockerArch, dockerVersion, binaryFileExt) }
func install(version dockerversion.Version) { writeDebug("dvm install %s", version) if version.IsEmpty() { die("The install command requires that a version is specified or the DOCKER_VERSION environment variable is set.", nil, retCodeInvalidArgument) } if nocheck { writeDebug("Skipping version validation!") } if !nocheck && !versionExists(version) { die("Version %s not found - try `dvm ls-remote` to browse available versions.", nil, retCodeInvalidOperation, version) } versionDir := getVersionDir(version) if version.IsExperimental() && pathExists(versionDir) { // Always install latest of experimental build err := os.RemoveAll(versionDir) if err != nil { die("Unable to remove experimental version at %s.", err, retCodeRuntimeError, versionDir) } } if _, err := os.Stat(versionDir); err == nil { writeWarning("%s is already installed", version) use(version) return } writeInfo("Installing %s...", version) downloadRelease(version) use(version) }