本文整理匯總了Golang中github.com/getcarina/dvm/dvm-helper/dockerversion.Version類的典型用法代碼示例。如果您正苦於以下問題:Golang Version類的具體用法?Golang Version怎麽用?Golang Version使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Version類的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: getVersionDir
func getVersionDir(version dockerversion.Version) string {
versionPath := version.SemVer.String()
if version.IsExperimental() {
versionPath = dockerversion.ExperimentalAlias
}
return filepath.Join(getVersionsDir(), versionPath)
}
示例2: downloadRelease
func downloadRelease(version dockerversion.Version) {
url := buildDownloadURL(version)
binaryName := getBinaryName()
binaryPath := filepath.Join(getVersionDir(version), binaryName)
if version.ShouldUseArchivedRelease() {
archivedFile := path.Join("docker", binaryName)
downloadArchivedFileWithChecksum(url, archivedFile, binaryPath)
} else {
downloadFileWithChecksum(url, binaryPath)
}
writeDebug("Downloaded Docker %s to %s.", version, binaryPath)
}
示例3: versionExists
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
}
示例4: isVersionInstalled
func isVersionInstalled(version dockerversion.Version) bool {
writeDebug("Checking if version is installed: %s", version)
installedVersions := getInstalledVersions("*")
for _, availableVersion := range installedVersions {
writeDebug("Checking version: %s", availableVersion)
if version.Equals(availableVersion) {
writeDebug("Version %s is installed", version)
return true
}
}
return false
}
示例5: alias
func alias(alias string, version dockerversion.Version) {
if alias == "" || version.IsEmpty() {
die("The alias command requires both an alias name and a version.", nil, retCodeInvalidArgument)
}
if !isVersionInstalled(version) {
die("The aliased version, %s, is not installed.", nil, retCodeInvalidArgument, version)
}
aliasPath := getAliasPath(alias)
if _, err := os.Stat(aliasPath); err == nil {
writeDebug("Overwriting existing alias.")
}
writeFile(aliasPath, version.SemVer.String())
writeInfo("Aliased %s to %s.", alias, version)
}
示例6: uninstall
func uninstall(version dockerversion.Version) {
if version.IsEmpty() {
die("The uninstall command requires that a version is specified.", nil, retCodeInvalidArgument)
}
current, _ := getCurrentDockerVersion()
if current.Equals(version) {
die("Cannot uninstall the currently active Docker version.", nil, retCodeInvalidOperation)
}
versionDir := getVersionDir(version)
if _, err := os.Stat(versionDir); os.IsNotExist(err) {
writeWarning("%s is not installed.", version)
return
}
err := os.RemoveAll(versionDir)
if err != nil {
die("Unable to uninstall Docker version %s located in %s.", err, retCodeRuntimeError, version, versionDir)
}
writeInfo("Uninstalled Docker %s.", version)
}
示例7: install
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)
}
示例8: buildDownloadURL
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)
}
示例9: use
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)
}