mirror of
https://github.com/distribution/distribution.git
synced 2025-09-17 07:40:38 +00:00
Report version in registry binary
We've added support to the registry command to report the current version of the distribution package. The version package is generated with a shell script that gets the latest tag and add "+unknown". This allows builds from "go get" and "go install" to have a rough version number. Generated periodically, it will provide a decent indication of what code built the binary. For more accurate versioning, one can build with the "binaries" make target. Linker flags are used to replace the version string with the actual current tag at build time. Signed-off-by: Stephen J Day <stephen.day@docker.com>
This commit is contained in:
@@ -3,6 +3,7 @@ package main
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
_ "net/http/pprof"
|
||||
"os"
|
||||
@@ -19,12 +20,24 @@ import (
|
||||
_ "github.com/docker/distribution/storagedriver/filesystem"
|
||||
_ "github.com/docker/distribution/storagedriver/inmemory"
|
||||
_ "github.com/docker/distribution/storagedriver/s3"
|
||||
"github.com/docker/distribution/version"
|
||||
)
|
||||
|
||||
var showVersion bool
|
||||
|
||||
func init() {
|
||||
flag.BoolVar(&showVersion, "version", false, "show the version and exit")
|
||||
}
|
||||
|
||||
func main() {
|
||||
flag.Usage = usage
|
||||
flag.Parse()
|
||||
|
||||
if showVersion {
|
||||
printVersion(os.Stdout)
|
||||
return
|
||||
}
|
||||
|
||||
config, err := resolveConfiguration()
|
||||
if err != nil {
|
||||
fatalf("configuration error: %v", err)
|
||||
@@ -46,6 +59,10 @@ func usage() {
|
||||
flag.PrintDefaults()
|
||||
}
|
||||
|
||||
func printVersion(w io.Writer) {
|
||||
fmt.Fprintln(w, os.Args[0], version.Package, version.Version)
|
||||
}
|
||||
|
||||
func fatalf(format string, args ...interface{}) {
|
||||
fmt.Fprintf(os.Stderr, format+"\n", args...)
|
||||
usage()
|
||||
|
Reference in New Issue
Block a user