forked from docker/app
-
Notifications
You must be signed in to change notification settings - Fork 0
/
version.go
41 lines (36 loc) · 1.06 KB
/
version.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package internal
import (
"fmt"
"runtime"
"strings"
"time"
"github.com/docker/app/internal/renderer"
)
var (
// Version is the git tag that this was built from.
Version = "unknown"
// GitCommit is the commit that this was built from.
GitCommit = "unknown"
// BuildTime is the time at which the binary was built.
BuildTime = "unknown"
)
// FullVersion returns a string of version information.
func FullVersion() string {
res := []string{
fmt.Sprintf("Version: %s", Version),
fmt.Sprintf("Git commit: %s", GitCommit),
fmt.Sprintf("Built: %s", reformatDate(BuildTime)),
fmt.Sprintf("OS/Arch: %s/%s", runtime.GOOS, runtime.GOARCH),
fmt.Sprintf("Experimental: %s", Experimental),
fmt.Sprintf("Renderers: %s", strings.Join(renderer.Drivers(), ", ")),
}
return strings.Join(res, "\n")
}
// FIXME(chris-crone): use function in docker/cli/cli/command/system/version.go.
func reformatDate(buildTime string) string {
t, errTime := time.Parse(time.RFC3339Nano, buildTime)
if errTime == nil {
return t.Format(time.ANSIC)
}
return buildTime
}