Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 20 additions & 17 deletions lib/automaticupgrades/channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,26 +179,29 @@ func (c *Channel) GetCritical(ctx context.Context) (bool, error) {
return c.criticalTrigger.CanStart(ctx, nil)
}

var newDefaultChannel = sync.OnceValues[*Channel, error](
func() (*Channel, error) {
forwardURL := GetChannel()
if forwardURL == "" {
forwardURL = stableCloudVersionBaseURL
}
defaultChannel := &Channel{
ForwardURL: forwardURL,
}
if err := defaultChannel.CheckAndSetDefaults(); err != nil {
return nil, trace.Wrap(err)
}
return defaultChannel, nil
})

// NewDefaultChannel creates a default automatic upgrade channel
// It looks up the environment variable, and if not found uses the default
// base URL. This default channel can be used in the proxy (to back its own version server)
// or in other Teleport process such as integration services deploying and
// It looks up the TELEPORT_AUTOMATIC_UPGRADES_CHANNEL environment variable for
// backward compatibility, and if not found uses the default base URL.
// This default channel can be used in the proxy (to back its own version server)
// or in other Teleport processes such as integration services deploying and
// updating teleport agents.
func NewDefaultChannel() (*Channel, error) {
return sync.OnceValues[*Channel, error](
func() (*Channel, error) {
forwardURL := GetChannel()
if forwardURL == "" {
forwardURL = stableCloudVersionBaseURL
}
defaultChannel := &Channel{
ForwardURL: forwardURL,
}
if err := defaultChannel.CheckAndSetDefaults(); err != nil {
return nil, trace.Wrap(err)
}
return defaultChannel, nil
})()
return newDefaultChannel()
}

func parseMajorFromVersionString(v string) (int, error) {
Expand Down
4 changes: 1 addition & 3 deletions lib/web/apiserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -1604,9 +1604,7 @@ func (h *Handler) getWebConfig(w http.ResponseWriter, r *http.Request, p httprou
var automaticUpgradesTargetVersion string
if automaticUpgradesEnabled {
automaticUpgradesTargetVersion, err = h.cfg.AutomaticUpgradesChannels.DefaultVersion(r.Context())
if err != nil {
return nil, trace.Wrap(err)
}
h.log.WithError(err).Error("Cannot read target version")
}

webCfg := webclient.WebConfig{
Expand Down