MM28858 Basic framework for use of feature flags. Enviroment variable overrides. (#15544)
* Basic framework for use of feature flags. Enviroment variable overrides. * Use Apperr instead of error number increments. * Undo random viper change. * Update model/config_test.go Co-authored-by: Jesse Hallam <jesse.hallam@gmail.com> Co-authored-by: Jesse Hallam <jesse.hallam@gmail.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
61f08d397c
Коммит
e974b7b9be
@@ -2882,6 +2882,7 @@ type Config struct {
|
||||
GuestAccountsSettings GuestAccountsSettings
|
||||
ImageProxySettings ImageProxySettings
|
||||
CloudSettings CloudSettings
|
||||
FeatureFlags *FeatureFlags `json:",omitempty"`
|
||||
}
|
||||
|
||||
func (o *Config) Clone() *Config {
|
||||
@@ -2969,6 +2970,10 @@ func (o *Config) SetDefaults() {
|
||||
o.GuestAccountsSettings.SetDefaults()
|
||||
o.ImageProxySettings.SetDefaults(o.ServiceSettings)
|
||||
o.CloudSettings.SetDefaults()
|
||||
if o.FeatureFlags == nil {
|
||||
o.FeatureFlags = &FeatureFlags{}
|
||||
o.FeatureFlags.SetDefaults()
|
||||
}
|
||||
}
|
||||
|
||||
func (o *Config) IsValid() *AppError {
|
||||
|
||||
@@ -1326,3 +1326,21 @@ func TestConfigMarketplaceDefaults(t *testing.T) {
|
||||
require.Equal(t, "https://marketplace.example.com", *c.PluginSettings.MarketplaceUrl)
|
||||
})
|
||||
}
|
||||
|
||||
func TestSetDefaultFeatureFlagBehaviour(t *testing.T) {
|
||||
cfg := Config{}
|
||||
cfg.SetDefaults()
|
||||
|
||||
require.NotNil(t, cfg.FeatureFlags)
|
||||
require.Equal(t, "off", cfg.FeatureFlags.TestFeature)
|
||||
|
||||
cfg = Config{
|
||||
FeatureFlags: &FeatureFlags{
|
||||
TestFeature: "somevalue",
|
||||
},
|
||||
}
|
||||
cfg.SetDefaults()
|
||||
require.NotNil(t, cfg.FeatureFlags)
|
||||
require.Equal(t, "somevalue", cfg.FeatureFlags.TestFeature)
|
||||
|
||||
}
|
||||
|
||||
14
model/feature_flags.go
Обычный файл
14
model/feature_flags.go
Обычный файл
@@ -0,0 +1,14 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
package model
|
||||
|
||||
type FeatureFlags struct {
|
||||
// Exists only for unit and manual testing.
|
||||
// When set to a value, will be returned by the ping endpoint.
|
||||
TestFeature string
|
||||
}
|
||||
|
||||
func (f *FeatureFlags) SetDefaults() {
|
||||
f.TestFeature = "off"
|
||||
}
|
||||
Ссылка в новой задаче
Block a user