Establish beta and staging release channels, move indexes to helper

This commit is contained in:
Daniel
2021-06-03 23:28:41 +02:00
parent 8a46e78c0f
commit 642e2eb112
7 changed files with 161 additions and 120 deletions

View File

@@ -4,6 +4,7 @@ import (
"context"
"github.com/safing/portbase/notifications"
"github.com/safing/portmaster/updates/helper"
"github.com/tevino/abool"
"github.com/safing/portbase/config"
@@ -20,6 +21,7 @@ var (
devMode config.BoolOption
enableUpdates config.BoolOption
initialReleaseChannel string
previousReleaseChannel string
updatesCurrentlyEnabled bool
previousDevMode bool
@@ -29,21 +31,28 @@ var (
func registerConfig() error {
err := config.Register(&config.Option{
Name: "Release Channel",
Key: releaseChannelKey,
Key: helper.ReleaseChannelKey,
Description: "Switch release channel.",
OptType: config.OptTypeString,
ExpertiseLevel: config.ExpertiseLevelDeveloper,
ReleaseLevel: config.ReleaseLevelExperimental,
RequiresRestart: false,
DefaultValue: releaseChannelStable,
RequiresRestart: true,
DefaultValue: helper.ReleaseChannelStable,
PossibleValues: []config.PossibleValue{
{
Name: "Stable",
Value: releaseChannelStable,
Name: "Stable",
Description: "Production releases.",
Value: helper.ReleaseChannelStable,
},
{
Name: "Beta",
Value: releaseChannelBeta,
Name: "Beta",
Description: "Production releases for testing new features that may break and cause interruption.",
Value: helper.ReleaseChannelBeta,
},
{
Name: "Staging",
Description: "Development releases for testing random things and experimenting. Dangerous - only use when told so.",
Value: helper.ReleaseChannelStaging,
},
},
Annotations: config.Annotations{
@@ -78,7 +87,8 @@ func registerConfig() error {
}
func initConfig() {
releaseChannel = config.GetAsString(releaseChannelKey, releaseChannelStable)
releaseChannel = config.GetAsString(helper.ReleaseChannelKey, helper.ReleaseChannelStable)
initialReleaseChannel = releaseChannel()
previousReleaseChannel = releaseChannel()
enableUpdates = config.GetAsBool(enableUpdatesKey, true)
@@ -107,7 +117,7 @@ func updateRegistryConfig(_ context.Context, _ interface{}) error {
changed := false
if releaseChannel() != previousReleaseChannel {
registry.SetBeta(releaseChannel() == releaseChannelBeta)
registry.SetUsePreReleases(releaseChannel() != helper.ReleaseChannelStable)
previousReleaseChannel = releaseChannel()
changed = true
}