-
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.
Add information about build to Prometheus publisher
- Loading branch information
Showing
5 changed files
with
69 additions
and
12 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
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,33 @@ | ||
package version | ||
|
||
import ( | ||
"fmt" | ||
"time" | ||
) | ||
|
||
var ( | ||
// Version is the version of this build | ||
Version string | ||
// Commit is the commit of this build | ||
Commit string | ||
// BuildDate is the build date of this build in RFC3339 format | ||
BuildDate string | ||
// BuildTime is the build date of this build as a Go time.Time | ||
BuildTime time.Time | ||
) | ||
|
||
func init() { | ||
if Version == "" { | ||
Version = "SNAPSHOT" | ||
} | ||
|
||
if BuildDate == "" { | ||
BuildDate = time.Time{}.Format(time.RFC3339) | ||
} | ||
|
||
var err error | ||
BuildTime, err = time.ParseInLocation(time.RFC3339, BuildDate, time.UTC) | ||
if err != nil { | ||
panic(fmt.Sprintf("failed to parse build time: %v", err)) | ||
} | ||
} |