cmd/uplinkng: expand version information
This includes the information that used to exist in uplink as well as all of the module versions. Change-Id: Ie6d6fa12da9c04b50611e5885e05ab0c24a2ec0d
This commit is contained in:
parent
1de8a695e8
commit
bd2448bc4d
@ -4,12 +4,16 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"runtime/debug"
|
"runtime/debug"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/zeebo/clingy"
|
"github.com/zeebo/clingy"
|
||||||
"github.com/zeebo/errs"
|
"github.com/zeebo/errs"
|
||||||
|
|
||||||
|
"storj.io/private/version"
|
||||||
)
|
)
|
||||||
|
|
||||||
type cmdVersion struct {
|
type cmdVersion struct {
|
||||||
@ -28,6 +32,28 @@ func (c *cmdVersion) Setup(params clingy.Parameters) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *cmdVersion) Execute(ctx clingy.Context) error {
|
func (c *cmdVersion) Execute(ctx clingy.Context) error {
|
||||||
|
if version.Build.Release {
|
||||||
|
fmt.Fprintln(ctx, "Release build")
|
||||||
|
} else {
|
||||||
|
fmt.Fprintln(ctx, "Development build")
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
tw := newTabbedWriter(ctx.Stdout())
|
||||||
|
if !version.Build.Version.IsZero() {
|
||||||
|
tw.WriteLine("Version:", version.Build.Version.String())
|
||||||
|
}
|
||||||
|
if !version.Build.Timestamp.IsZero() {
|
||||||
|
tw.WriteLine("Build timestamp:", version.Build.Timestamp.Format(time.RFC822))
|
||||||
|
}
|
||||||
|
if version.Build.CommitHash != "" {
|
||||||
|
tw.WriteLine("Git commit:", version.Build.CommitHash)
|
||||||
|
}
|
||||||
|
tw.Done()
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Fprintln(ctx)
|
||||||
|
|
||||||
bi, ok := debug.ReadBuildInfo()
|
bi, ok := debug.ReadBuildInfo()
|
||||||
if !ok {
|
if !ok {
|
||||||
return errs.New("unable to read build info")
|
return errs.New("unable to read build info")
|
||||||
|
@ -31,7 +31,9 @@ func (t *tabbedWriter) Done() {
|
|||||||
|
|
||||||
func (t *tabbedWriter) WriteLine(parts ...interface{}) {
|
func (t *tabbedWriter) WriteLine(parts ...interface{}) {
|
||||||
if !t.wrote {
|
if !t.wrote {
|
||||||
|
if len(t.headers) > 0 {
|
||||||
fmt.Fprintln(t.tw, strings.Join(t.headers, "\t"))
|
fmt.Fprintln(t.tw, strings.Join(t.headers, "\t"))
|
||||||
|
}
|
||||||
t.wrote = true
|
t.wrote = true
|
||||||
}
|
}
|
||||||
for i, part := range parts {
|
for i, part := range parts {
|
||||||
|
Loading…
Reference in New Issue
Block a user