Whitelabelling: Override version in UI from config (#84392)

* Unify how the version is shown in the UI

* use versionString in dashboard help bundles

* fix lint

* remove comment

* fix test types

* make test less flakey
This commit is contained in:
Josh Hunt
2024-03-15 16:39:13 +00:00
committed by GitHub
parent 1ce2ae427f
commit f2628bfad4
11 changed files with 44 additions and 26 deletions

View File

@@ -152,11 +152,15 @@ func (hs *HTTPServer) getFrontendSettings(c *contextmodel.ReqContext) (*dtos.Fro
hideVersion := hs.Cfg.AnonymousHideVersion && !c.IsSignedIn
version := setting.BuildVersion
commit := setting.BuildCommit
commitShort := getShortCommitHash(setting.BuildCommit, 10)
buildstamp := setting.BuildStamp
versionString := fmt.Sprintf(`%s v%s (%s)`, setting.ApplicationName, version, commitShort)
if hideVersion {
version = ""
versionString = setting.ApplicationName
commit = ""
commitShort = ""
buildstamp = 0
}
@@ -226,7 +230,9 @@ func (hs *HTTPServer) getFrontendSettings(c *contextmodel.ReqContext) (*dtos.Fro
BuildInfo: dtos.FrontendSettingsBuildInfoDTO{
HideVersion: hideVersion,
Version: version,
VersionString: versionString,
Commit: commit,
CommitShort: commitShort,
Buildstamp: buildstamp,
Edition: hs.License.Edition(),
LatestVersion: hs.grafanaUpdateChecker.LatestVersion(),
@@ -367,6 +373,13 @@ func isSupportBundlesEnabled(hs *HTTPServer) bool {
return hs.Cfg.SectionWithEnvOverrides("support_bundles").Key("enabled").MustBool(true)
}
func getShortCommitHash(commitHash string, maxLength int) string {
if len(commitHash) > maxLength {
return commitHash[:maxLength]
}
return commitHash
}
func (hs *HTTPServer) getFSDataSources(c *contextmodel.ReqContext, availablePlugins AvailablePlugins) (map[string]plugins.DataSourceDTO, error) {
orgDataSources := make([]*datasources.DataSource, 0)
if c.SignedInUser.GetOrgID() != 0 {