mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Merge pull request #242 from philips/add-version-flag-0.2
feat(etcd): add version flag
This commit is contained in:
commit
e0636ce655
10
etcd.go
10
etcd.go
@ -2,6 +2,7 @@ package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"strings"
|
||||
@ -31,6 +32,8 @@ var (
|
||||
|
||||
force bool
|
||||
|
||||
printVersion bool
|
||||
|
||||
maxSize int
|
||||
|
||||
snapshot bool
|
||||
@ -45,6 +48,8 @@ var (
|
||||
)
|
||||
|
||||
func init() {
|
||||
flag.BoolVar(&printVersion, "version", false, "print the version and exit")
|
||||
|
||||
flag.BoolVar(&log.Verbose, "v", false, "verbose logging")
|
||||
flag.BoolVar(&veryVerbose, "vv", false, "very verbose logging")
|
||||
|
||||
@ -116,6 +121,11 @@ type Info struct {
|
||||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
if printVersion {
|
||||
fmt.Println(server.ReleaseVersion)
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
if cpuprofile != "" {
|
||||
runCPUProfile()
|
||||
}
|
||||
|
@ -4,5 +4,5 @@ VER=$(git describe --tags HEAD)
|
||||
|
||||
cat <<EOF
|
||||
package server
|
||||
const releaseVersion = "$VER"
|
||||
const ReleaseVersion = "$VER"
|
||||
EOF
|
||||
|
@ -195,7 +195,7 @@ func (s *Server) OriginAllowed(origin string) bool {
|
||||
// Handler to return the current version of etcd.
|
||||
func (s *Server) GetVersionHandler(w http.ResponseWriter, req *http.Request) error {
|
||||
w.WriteHeader(http.StatusOK)
|
||||
fmt.Fprintf(w, "etcd %s", releaseVersion)
|
||||
fmt.Fprintf(w, "etcd %s", ReleaseVersion)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -5,4 +5,4 @@ const Version = "v2"
|
||||
// TODO: The release version (generated from the git tag) will be the raft
|
||||
// protocol version for now. When things settle down we will fix it like the
|
||||
// client API above.
|
||||
const PeerVersion = releaseVersion
|
||||
const PeerVersion = ReleaseVersion
|
||||
|
Loading…
x
Reference in New Issue
Block a user