chore: centralize build info for site (#13104)

The build info passed to the frontend via HTML was incorrect.
This commit is contained in:
Kyle Carberry
2024-04-29 20:50:49 -04:00
committed by GitHub
parent 1bda8a0856
commit fbb98b950a
3 changed files with 16 additions and 20 deletions
+2 -7
View File
@@ -34,7 +34,6 @@ import (
"golang.org/x/sync/singleflight"
"golang.org/x/xerrors"
"github.com/coder/coder/v2/buildinfo"
"github.com/coder/coder/v2/coderd/appearance"
"github.com/coder/coder/v2/coderd/database"
"github.com/coder/coder/v2/coderd/database/db2sdk"
@@ -78,6 +77,7 @@ type Options struct {
SiteFS fs.FS
OAuth2Configs *httpmw.OAuth2Configs
DocsURL string
BuildInfo codersdk.BuildInfoResponse
AppearanceFetcher *atomic.Pointer[appearance.Fetcher]
}
@@ -149,12 +149,7 @@ func New(opts *Options) *Handler {
// static files.
OnlyFiles(opts.SiteFS))),
)
buildInfo := codersdk.BuildInfoResponse{
ExternalURL: buildinfo.ExternalURL(),
Version: buildinfo.Version(),
}
buildInfoResponse, err := json.Marshal(buildInfo)
buildInfoResponse, err := json.Marshal(opts.BuildInfo)
if err != nil {
panic("failed to marshal build info: " + err.Error())
}