-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: move version params to a package (#45)
* chore: move version to a package * releaser * reducing redirection * pkgs -> pkg
- Loading branch information
Deepak Sharma
authored
Apr 8, 2021
1 parent
97dfad1
commit 6d1e1a8
Showing
4 changed files
with
57 additions
and
44 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
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,46 @@ | ||
package version | ||
|
||
import ( | ||
"fmt" | ||
"runtime" | ||
"strconv" | ||
"time" | ||
) | ||
|
||
// Version string populated by releaser Job | ||
var ( | ||
// The current version of crda cli | ||
version string = "0.0.0" | ||
|
||
// commitHash contains the current Git revision. | ||
commitHash string = "abcd" | ||
|
||
// Timestamp contains the UnixTimestamp of the binary build. | ||
timestamp string = "0" | ||
|
||
// VendorInfo contains vendor notes about the current build. | ||
vendorInfo string = "Local Build" | ||
) | ||
|
||
// GetCRDAVersion returns CRDA CLI Version | ||
func GetCRDAVersion() string { | ||
return version | ||
} | ||
|
||
// BuildVersion builds version string for command output | ||
func BuildVersion() string { | ||
version := "v" + version | ||
version += "-" + commitHash | ||
osArch := runtime.GOOS + "/" + runtime.GOARCH | ||
|
||
versionString := fmt.Sprintf("%s %s ", | ||
version, osArch) | ||
|
||
i, err := strconv.ParseInt(timestamp, 10, 64) | ||
if err == nil { | ||
tm := time.Unix(i, 0) | ||
versionString += fmt.Sprintf(" BuildDate: %s", tm.Format(time.RFC1123)) | ||
} | ||
versionString += fmt.Sprintf(" Vendor: %s", vendorInfo) | ||
return versionString | ||
} |