-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
version.go
49 lines (42 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
42
43
44
45
46
47
48
49
// Copyright 2016 The OPA Authors. All rights reserved.
// Use of this source code is governed by an Apache2
// license that can be found in the LICENSE file.
// Package version contains version information that is set at build time.
package version
import (
"runtime"
"runtime/debug"
)
// Version is the canonical version of OPA.
var Version = "0.65.0-dev"
// GoVersion is the version of Go this was built with
var GoVersion = runtime.Version()
// Platform is the runtime OS and architecture of this OPA binary
var Platform = runtime.GOOS + "/" + runtime.GOARCH
// Additional version information that is displayed by the "version" command and used to
// identify the version of running instances of OPA.
var (
Vcs = ""
Timestamp = ""
Hostname = ""
)
func init() {
bi, ok := debug.ReadBuildInfo()
if !ok {
return
}
dirty := false
for _, s := range bi.Settings {
switch s.Key {
case "vcs.time":
Timestamp = s.Value
case "vcs.revision":
Vcs = s.Value
case "vcs.modified":
dirty = s.Value == "true"
}
}
if dirty {
Vcs = Vcs + "-dirty"
}
}