-
Notifications
You must be signed in to change notification settings - Fork 1
/
version.go
47 lines (37 loc) · 1.1 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
42
43
44
45
46
47
package common
import (
"fmt"
"runtime"
"time"
"github.com/codegangsta/cli"
)
var NAME = "gitlab-ci-multi-runner"
var VERSION = "dev"
var REVISION = "HEAD"
var BUILT = "now"
var BRANCH = "HEAD"
func VersionPrinter(c *cli.Context) {
fmt.Print(ExtendedVersion())
}
func VersionLine() string {
return fmt.Sprintf("%s %s (%s)", NAME, VERSION, REVISION)
}
func VersionShortLine() string {
return fmt.Sprintf("%s (%s)", VERSION, REVISION)
}
func VersionUserAgent() string {
return fmt.Sprintf("%s %s (%s; %s; %s/%s)", NAME, VERSION, BRANCH, runtime.Version(), runtime.GOOS, runtime.GOARCH)
}
func ExtendedVersion() string {
built := time.Now()
if BUILT != "now" {
built, _ = time.Parse(time.RFC3339, BUILT)
}
version := fmt.Sprintf("Version: %s\n", VERSION)
version += fmt.Sprintf("Git revision: %s\n", REVISION)
version += fmt.Sprintf("Git branch: %s\n", BRANCH)
version += fmt.Sprintf("GO version: %s\n", runtime.Version())
version += fmt.Sprintf("Built: %s\n", built.Format(time.RFC1123Z))
version += fmt.Sprintf("OS/Arch: %s/%s\n", runtime.GOOS, runtime.GOARCH)
return version
}