version.go 1.9 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
/*
Copyright 2016 The Kubernetes Authors All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package version

19 20 21 22 23 24
import (
	"strings"

	"github.com/blang/semver"
)

25
// VersionPrefix is the prefix of the git tag for a version
26 27
const VersionPrefix = "v"

28 29 30
// The current version of the minikube

// version is a private field and should be set when compiling with --ldflags="-X k8s.io/minikube/pkg/version.version=vX.Y.Z"
31 32
var version = "v0.0.0-unset"

33
// gitCommitID is a private field and should be set when compiling with --ldflags="-X k8s.io/minikube/pkg/version.gitCommitID=<commit-id>"
34 35
var gitCommitID = ""

36
// isoVersion is a private field and should be set when compiling with --ldflags="-X k8s.io/minikube/pkg/version.isoVersion=vX.Y.Z"
M
Matt Rickard 已提交
37 38
var isoVersion = "v0.0.0-unset"

39 40
var isoPath = "minikube/iso"

41
// GetVersion returns the current minikube version
42 43 44
func GetVersion() string {
	return version
}
45

46 47 48 49 50
// GetGitCommitID returns the git commit id from which it is being built
func GetGitCommitID() string {
	return gitCommitID
}

51
// GetISOVersion returns the current minikube.iso version
52
func GetISOVersion() string {
M
Matt Rickard 已提交
53 54 55
	return isoVersion
}

56
// GetISOPath returns the remote path to the minikube.iso
57
func GetISOPath() string {
58 59 60
	return isoPath
}

61
// GetSemverVersion returns the current minikube semantic version (semver)
62 63 64
func GetSemverVersion() (semver.Version, error) {
	return semver.Make(strings.TrimPrefix(GetVersion(), VersionPrefix))
}