mirror of
https://github.com/distribution/distribution.git
synced 2025-09-07 01:41:02 +00:00
version: export getter functions
Future-proof the version package's exported interface by only making the data available through getter functions. This affords us the flexibility to e.g. implement them in terms of "runtime/debug".ReadBuildInfo() in the future. Signed-off-by: Cory Snider <csnider@mirantis.com>
This commit is contained in:
@@ -6,6 +6,24 @@ import (
|
||||
"os"
|
||||
)
|
||||
|
||||
// Package returns the overall, canonical project import path under
|
||||
// which the package was built.
|
||||
func Package() string {
|
||||
return mainpkg
|
||||
}
|
||||
|
||||
// Version returns returns the module version the running binary was
|
||||
// built from.
|
||||
func Version() string {
|
||||
return version
|
||||
}
|
||||
|
||||
// Revision returns the VCS (e.g. git) revision being used to build
|
||||
// the program at linking time.
|
||||
func Revision() string {
|
||||
return revision
|
||||
}
|
||||
|
||||
// FprintVersion outputs the version string to the writer, in the following
|
||||
// format, followed by a newline:
|
||||
//
|
||||
@@ -16,7 +34,7 @@ import (
|
||||
//
|
||||
// registry github.com/distribution/distribution v2.0
|
||||
func FprintVersion(w io.Writer) {
|
||||
fmt.Fprintln(w, os.Args[0], Package, Version)
|
||||
fmt.Fprintln(w, os.Args[0], Package(), Version())
|
||||
}
|
||||
|
||||
// PrintVersion outputs the version information, from Fprint, to stdout.
|
@@ -1,15 +1,15 @@
|
||||
package version
|
||||
|
||||
// Package is the overall, canonical project import path under which the
|
||||
// mainpkg is the overall, canonical project import path under which the
|
||||
// package was built.
|
||||
var Package = "github.com/distribution/distribution/v3"
|
||||
var mainpkg = "github.com/distribution/distribution/v3"
|
||||
|
||||
// Version indicates which version of the binary is running. This is set to
|
||||
// version indicates which version of the binary is running. This is set to
|
||||
// the latest release tag by hand, always suffixed by "+unknown". During
|
||||
// build, it will be replaced by the actual version. The value here will be
|
||||
// used if the registry is run after a go get based install.
|
||||
var Version = "v3.0.0-alpha.1"
|
||||
var version = "v3.0.0-alpha.1.m+unknown"
|
||||
|
||||
// Revision is filled with the VCS (e.g. git) revision being used to build
|
||||
// revision is filled with the VCS (e.g. git) revision being used to build
|
||||
// the program at linking time.
|
||||
var Revision = ""
|
||||
var revision = ""
|
||||
|
@@ -10,17 +10,17 @@ set -e
|
||||
cat <<EOF
|
||||
package version
|
||||
|
||||
// Package is the overall, canonical project import path under which the
|
||||
// mainpkg is the overall, canonical project import path under which the
|
||||
// package was built.
|
||||
var Package = "$(go list -m)"
|
||||
var mainpkg = "$(go list -m)"
|
||||
|
||||
// Version indicates which version of the binary is running. This is set to
|
||||
// version indicates which version of the binary is running. This is set to
|
||||
// the latest release tag by hand, always suffixed by "+unknown". During
|
||||
// build, it will be replaced by the actual version. The value here will be
|
||||
// used if the registry is run after a go get based install.
|
||||
var Version = "$(git describe --match 'v[0-9]*' --dirty='.m' --always)+unknown"
|
||||
var version = "$(git describe --match 'v[0-9]*' --dirty='.m' --always)+unknown"
|
||||
|
||||
// Revision is filled with the VCS (e.g. git) revision being used to build
|
||||
// revision is filled with the VCS (e.g. git) revision being used to build
|
||||
// the program at linking time.
|
||||
var Revision = ""
|
||||
var revision = ""
|
||||
EOF
|
||||
|
Reference in New Issue
Block a user