-
Notifications
You must be signed in to change notification settings - Fork 62
/
version.go
52 lines (44 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
48
49
50
51
52
// SPDX-License-Identifier: BSD-3-Clause
// Copyright (c) 2022, Unikraft GmbH and The KraftKit Authors.
// Licensed under the BSD-3-Clause License (the "License").
// You may not use this file except in compliance with the License.
package version
import (
"fmt"
"runtime"
)
var (
version = "No version provided"
commit = "No commit provided"
buildTime = "No build timestamp provided"
agentName = "kraftkit"
)
// Version returns KraftKit's version string.
func Version() string {
return version
}
// Commit return KraftKit's HEAD Git commit SHA.
func Commit() string {
return commit
}
// BuildTime returns the time in which the package or binary was built.
func BuildTime() string {
return buildTime
}
// String returns all version information.
func String() string {
return fmt.Sprintf("%s (%s) %s %s\n",
version,
commit,
runtime.Version(),
buildTime,
)
}
// UserAgent returns KraftKit's agent name and the version to be used when
// making HTTP requests.
func UserAgent() string {
if version != "No version provided" {
return fmt.Sprintf("%s/%s", agentName, version)
}
return agentName
}