-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #34 from Xelon-AG/fix/version-info
fix: inject version info via ldflags
- Loading branch information
Showing
8 changed files
with
91 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,5 +3,6 @@ build/ | |
deploy/ | ||
test/ | ||
tools/ | ||
Makefile | ||
README.md | ||
.golangci.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package driver | ||
|
||
import ( | ||
"fmt" | ||
"runtime" | ||
) | ||
|
||
// These are set during build time via -ldflags | ||
var ( | ||
gitCommit = "none" | ||
gitTreeState = "none" | ||
sourceDateEpoch = "0" | ||
version = "dev" | ||
) | ||
|
||
type VersionInfo struct { | ||
GitCommit string `json:"git_commit,omitempty"` | ||
GitTreeState string `json:"git_tree_state,omitempty"` | ||
GoVersion string `json:"go_version,omitempty"` | ||
SourceDateEpoch string `json:"source_data_epoch,omitempty"` | ||
Version string `json:"version,omitempty"` | ||
} | ||
|
||
func GetVersion() string { | ||
return version | ||
} | ||
|
||
func GetVersionInfo() VersionInfo { | ||
return VersionInfo{ | ||
GitCommit: gitCommit, | ||
GitTreeState: gitTreeState, | ||
GoVersion: runtime.Version(), | ||
SourceDateEpoch: sourceDateEpoch, | ||
Version: version, | ||
} | ||
} | ||
|
||
func UserAgent() string { | ||
return fmt.Sprintf("xelon-csi/%s", version) | ||
} |