Merge pull request #273 from ericchiang/version

cmd: add version to command worker and overlord, print go version
This commit is contained in:
Eric Chiang 2016-02-05 09:30:48 -08:00
commit 907f536e74
3 changed files with 24 additions and 2 deletions

View file

@ -7,6 +7,8 @@ import (
"net/http"
"net/url"
"os"
"runtime"
"strings"
"time"
"github.com/coreos/go-oidc/key"
@ -50,6 +52,8 @@ func main() {
logDebug := fs.Bool("log-debug", false, "log debug-level information")
logTimestamps := fs.Bool("log-timestamps", false, "prefix log lines with timestamps")
printVersion := fs.Bool("version", false, "Print the version and exit")
if err := fs.Parse(os.Args[1:]); err != nil {
fmt.Fprintln(os.Stderr, err.Error())
os.Exit(1)
@ -60,6 +64,11 @@ func main() {
os.Exit(1)
}
if *printVersion {
fmt.Printf("dex version %s\ngo version %s\n", strings.TrimPrefix(version, "v"), strings.TrimPrefix(runtime.Version(), "go"))
os.Exit(0)
}
if *logDebug {
log.EnableDebug()
}

View file

@ -7,6 +7,8 @@ import (
"net/http"
"net/url"
"os"
"runtime"
"strings"
"time"
"github.com/coreos/pkg/flagutil"
@ -63,6 +65,7 @@ func main() {
dbMaxIdleConns := fs.Int("db-max-idle-conns", 0, "maximum number of connections in the idle connection pool")
dbMaxOpenConns := fs.Int("db-max-open-conns", 0, "maximum number of open connections to the database")
printVersion := fs.Bool("version", false, "Print the version and exit")
// used only if --no-db is set
connectors := fs.String("connectors", "./static/fixtures/connectors.json", "JSON file containg set of IDPC configs")
@ -82,6 +85,11 @@ func main() {
os.Exit(1)
}
if *printVersion {
fmt.Printf("dex version %s\ngo version %s\n", strings.TrimPrefix(version, "v"), strings.TrimPrefix(runtime.Version(), "go"))
os.Exit(0)
}
if *logDebug {
log.EnableDebug()
log.Infof("Debug logging enabled.")

View file

@ -1,6 +1,11 @@
package main
import "github.com/spf13/cobra"
import (
"runtime"
"strings"
"github.com/spf13/cobra"
)
var (
// set by the top level build script
@ -11,7 +16,7 @@ var (
Short: "Print the dexctl version.",
Long: "Print the dexctl version.",
Run: func(cmd *cobra.Command, args []string) {
stdout(version)
stdout("dex version %s\ngo version %s", strings.TrimPrefix(version, "v"), strings.TrimPrefix(runtime.Version(), "go"))
},
}
)