本文整理匯總了Golang中github.com/getcarina/dvm/dvm-helper/dockerversion.Version.IsEmpty方法的典型用法代碼示例。如果您正苦於以下問題:Golang Version.IsEmpty方法的具體用法?Golang Version.IsEmpty怎麽用?Golang Version.IsEmpty使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/getcarina/dvm/dvm-helper/dockerversion.Version
的用法示例。
在下文中一共展示了Version.IsEmpty方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: 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)
}
示例2: 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)
}
示例3: 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)
}
示例4: 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)
}