mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat: Add support for update checks and notifications (#4810)
Co-authored-by: Kira Pilot <kira@coder.com>
This commit is contained in:
co-authored by
Kira Pilot
parent
4f1cf6c9d8
commit
d9f2aaf3b4
@@ -63,6 +63,7 @@ import (
|
||||
"github.com/coder/coder/coderd/prometheusmetrics"
|
||||
"github.com/coder/coder/coderd/telemetry"
|
||||
"github.com/coder/coder/coderd/tracing"
|
||||
"github.com/coder/coder/coderd/updatecheck"
|
||||
"github.com/coder/coder/codersdk"
|
||||
"github.com/coder/coder/cryptorand"
|
||||
"github.com/coder/coder/provisioner/echo"
|
||||
@@ -373,6 +374,25 @@ func Server(vip *viper.Viper, newAPI func(context.Context, *coderd.Options) (*co
|
||||
options.TLSCertificates = tlsConfig.Certificates
|
||||
}
|
||||
|
||||
if cfg.UpdateCheck.Value {
|
||||
options.UpdateCheckOptions = &updatecheck.Options{
|
||||
// Avoid spamming GitHub API checking for updates.
|
||||
Interval: 24 * time.Hour,
|
||||
// Inform server admins of new versions.
|
||||
Notify: func(r updatecheck.Result) {
|
||||
if semver.Compare(r.Version, buildinfo.Version()) > 0 {
|
||||
options.Logger.Info(
|
||||
context.Background(),
|
||||
"new version of coder available",
|
||||
slog.F("new_version", r.Version),
|
||||
slog.F("url", r.URL),
|
||||
slog.F("upgrade_instructions", "https://coder.com/docs/coder-oss/latest/admin/upgrade"),
|
||||
)
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
if cfg.OAuth2.Github.ClientSecret.Value != "" {
|
||||
options.GithubOAuth2Config, err = configureGithubOAuth2(accessURLParsed,
|
||||
cfg.OAuth2.Github.ClientID.Value,
|
||||
|
||||
Reference in New Issue
Block a user