Add VersionInfo struct to render in the /info endpoint

This commit is contained in:
Dan Sosedoff 2022-12-01 16:41:46 -06:00
parent 9b8cbb05e3
commit dafda4a977
No known key found for this signature in database
GPG Key ID: 26186197D282B164
2 changed files with 18 additions and 6 deletions

View File

@ -499,12 +499,7 @@ func GetBookmarks(c *gin.Context) {
// GetInfo renders the pgweb system information // GetInfo renders the pgweb system information
func GetInfo(c *gin.Context) { func GetInfo(c *gin.Context) {
successResponse(c, gin.H{ successResponse(c, command.Info)
"version": command.Version,
"go_version": command.GoVersion,
"git_sha": command.GitCommit,
"build_time": command.BuildTime,
})
} }
// DataExport performs database table export // DataExport performs database table export

View File

@ -14,4 +14,21 @@ var (
// GoVersion contains the build time Go version // GoVersion contains the build time Go version
GoVersion string GoVersion string
// Info contains all version information
Info VersionInfo
) )
type VersionInfo struct {
Version string `json:"version"`
GitCommit string `json:"git_sha"`
BuildTime string `json:"build_time"`
GoVersion string `json:"go_version"`
}
func init() {
Info.Version = Version
Info.GitCommit = GitCommit
Info.BuildTime = BuildTime
Info.GoVersion = GoVersion
}