[MM-16751] golint model (#17896)
Этот коммит содержится в:
коммит произвёл
Claudio Costa
родитель
953eebdef4
Коммит
97ccf0bdf6
@@ -56,7 +56,7 @@ func GenerateClientConfig(c *model.Config, telemetryID string, license *model.Li
|
||||
|
||||
props["ExperimentalCloudUserLimit"] = strconv.FormatInt(*c.ExperimentalSettings.CloudUserLimit, 10)
|
||||
props["ExperimentalCloudBilling"] = strconv.FormatBool(*c.ExperimentalSettings.CloudBilling)
|
||||
if *c.ServiceSettings.ExperimentalChannelOrganization || *c.ServiceSettings.ExperimentalGroupUnreadChannels != model.GROUP_UNREAD_CHANNELS_DISABLED {
|
||||
if *c.ServiceSettings.ExperimentalChannelOrganization || *c.ServiceSettings.ExperimentalGroupUnreadChannels != model.GroupUnreadChannelsDisabled {
|
||||
props["ExperimentalChannelOrganization"] = strconv.FormatBool(true)
|
||||
} else {
|
||||
props["ExperimentalChannelOrganization"] = strconv.FormatBool(false)
|
||||
@@ -137,7 +137,7 @@ func GenerateClientConfig(c *model.Config, telemetryID string, license *model.Li
|
||||
props["CWSUrl"] = ""
|
||||
|
||||
props["CustomUrlSchemes"] = strings.Join(c.DisplaySettings.CustomUrlSchemes, ",")
|
||||
props["IsDefaultMarketplace"] = strconv.FormatBool(*c.PluginSettings.MarketplaceUrl == model.PLUGIN_SETTINGS_DEFAULT_MARKETPLACE_URL)
|
||||
props["IsDefaultMarketplace"] = strconv.FormatBool(*c.PluginSettings.MarketplaceUrl == model.PluginSettingsDefaultMarketplaceUrl)
|
||||
props["ExperimentalSharedChannels"] = "false"
|
||||
props["CollapsedThreads"] = *c.ServiceSettings.CollapsedThreads
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ func TestGetClientConfig(t *testing.T) {
|
||||
"unlicensed",
|
||||
&model.Config{
|
||||
EmailSettings: model.EmailSettings{
|
||||
EmailNotificationContentsType: model.NewString(model.EMAIL_NOTIFICATION_CONTENTS_FULL),
|
||||
EmailNotificationContentsType: model.NewString(model.EmailNotificationContentsFull),
|
||||
},
|
||||
ThemeSettings: model.ThemeSettings{
|
||||
// Ignored, since not licensed.
|
||||
@@ -53,7 +53,7 @@ func TestGetClientConfig(t *testing.T) {
|
||||
"licensed, but not for theme management",
|
||||
&model.Config{
|
||||
EmailSettings: model.EmailSettings{
|
||||
EmailNotificationContentsType: model.NewString(model.EMAIL_NOTIFICATION_CONTENTS_FULL),
|
||||
EmailNotificationContentsType: model.NewString(model.EmailNotificationContentsFull),
|
||||
},
|
||||
ThemeSettings: model.ThemeSettings{
|
||||
// Ignored, since not licensed.
|
||||
@@ -76,7 +76,7 @@ func TestGetClientConfig(t *testing.T) {
|
||||
"licensed for theme management",
|
||||
&model.Config{
|
||||
EmailSettings: model.EmailSettings{
|
||||
EmailNotificationContentsType: model.NewString(model.EMAIL_NOTIFICATION_CONTENTS_FULL),
|
||||
EmailNotificationContentsType: model.NewString(model.EmailNotificationContentsFull),
|
||||
},
|
||||
ThemeSettings: model.ThemeSettings{
|
||||
AllowCustomThemes: model.NewBool(false),
|
||||
@@ -129,7 +129,7 @@ func TestGetClientConfig(t *testing.T) {
|
||||
&model.Config{
|
||||
ServiceSettings: model.ServiceSettings{
|
||||
ExperimentalChannelOrganization: model.NewBool(false),
|
||||
ExperimentalGroupUnreadChannels: model.NewString(model.GROUP_UNREAD_CHANNELS_DEFAULT_ON),
|
||||
ExperimentalGroupUnreadChannels: model.NewString(model.GroupUnreadChannelsDefaultOn),
|
||||
},
|
||||
},
|
||||
"tag1",
|
||||
@@ -142,7 +142,7 @@ func TestGetClientConfig(t *testing.T) {
|
||||
"default marketplace",
|
||||
&model.Config{
|
||||
PluginSettings: model.PluginSettings{
|
||||
MarketplaceUrl: model.NewString(model.PLUGIN_SETTINGS_DEFAULT_MARKETPLACE_URL),
|
||||
MarketplaceUrl: model.NewString(model.PluginSettingsDefaultMarketplaceUrl),
|
||||
},
|
||||
},
|
||||
"tag1",
|
||||
@@ -213,7 +213,7 @@ func TestGetLimitedClientConfig(t *testing.T) {
|
||||
"unlicensed",
|
||||
&model.Config{
|
||||
EmailSettings: model.EmailSettings{
|
||||
EmailNotificationContentsType: model.NewString(model.EMAIL_NOTIFICATION_CONTENTS_FULL),
|
||||
EmailNotificationContentsType: model.NewString(model.EmailNotificationContentsFull),
|
||||
},
|
||||
ThemeSettings: model.ThemeSettings{
|
||||
// Ignored, since not licensed.
|
||||
|
||||
@@ -57,7 +57,7 @@ func init() {
|
||||
AtRestEncryptKey: model.NewString("abcdefghijklmnopqrstuvwxyz0123456789"),
|
||||
},
|
||||
FileSettings: model.FileSettings{
|
||||
DriverName: model.NewString(model.IMAGE_DRIVER_LOCAL),
|
||||
DriverName: model.NewString(model.ImageDriverLocal),
|
||||
Directory: model.NewString("/path/to/directory"),
|
||||
PublicLinkSalt: model.NewString("abcdefghijklmnopqrstuvwxyz0123456789"),
|
||||
},
|
||||
|
||||
@@ -20,7 +20,7 @@ import (
|
||||
)
|
||||
|
||||
func getDsn(driver string, source string) string {
|
||||
if driver == model.DATABASE_DRIVER_MYSQL {
|
||||
if driver == model.DatabaseDriverMysql {
|
||||
return driver + "://" + source
|
||||
}
|
||||
return source
|
||||
@@ -321,7 +321,7 @@ func TestDatabaseStoreGetEnivironmentOverrides(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
defer ds.Close()
|
||||
|
||||
assert.Equal(t, model.TEAM_SETTINGS_DEFAULT_MAX_USERS_PER_TEAM, *ds.Get().TeamSettings.MaxUsersPerTeam)
|
||||
assert.Equal(t, model.TeamSettingsDefaultMaxUsersPerTeam, *ds.Get().TeamSettings.MaxUsersPerTeam)
|
||||
assert.Empty(t, ds.GetEnvironmentOverrides())
|
||||
|
||||
os.Setenv("MM_TEAMSETTINGS_MAXUSERSPERTEAM", "3000")
|
||||
@@ -451,7 +451,7 @@ func TestDatabaseStoreSet(t *testing.T) {
|
||||
defer ds.Close()
|
||||
|
||||
newCfg := &model.Config{}
|
||||
newCfg.LdapSettings.BindPassword = model.NewString(model.FAKE_SETTING)
|
||||
newCfg.LdapSettings.BindPassword = model.NewString(model.FakeSetting)
|
||||
|
||||
_, _, err = ds.Set(newCfg)
|
||||
require.NoError(t, err)
|
||||
@@ -745,7 +745,7 @@ func TestDatabaseStoreLoad(t *testing.T) {
|
||||
assert.Equal(t, map[string]interface{}{"TeamSettings": map[string]interface{}{"MaxUsersPerTeam": true}}, ds.GetEnvironmentOverrides())
|
||||
// check that in DB config does not include overwritten variable
|
||||
_, actualConfig := getActualDatabaseConfig(t)
|
||||
assert.Equal(t, model.TEAM_SETTINGS_DEFAULT_MAX_USERS_PER_TEAM, *actualConfig.TeamSettings.MaxUsersPerTeam)
|
||||
assert.Equal(t, model.TeamSettingsDefaultMaxUsersPerTeam, *actualConfig.TeamSettings.MaxUsersPerTeam)
|
||||
})
|
||||
|
||||
t.Run("do not persist environment variables - int64", func(t *testing.T) {
|
||||
|
||||
@@ -369,7 +369,7 @@ func TestFileStoreGetEnivironmentOverrides(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
defer fs.Close()
|
||||
|
||||
assert.Equal(t, model.TEAM_SETTINGS_DEFAULT_MAX_USERS_PER_TEAM, *fs.Get().TeamSettings.MaxUsersPerTeam)
|
||||
assert.Equal(t, model.TeamSettingsDefaultMaxUsersPerTeam, *fs.Get().TeamSettings.MaxUsersPerTeam)
|
||||
assert.Empty(t, fs.GetEnvironmentOverrides())
|
||||
|
||||
os.Setenv("MM_TEAMSETTINGS_MAXUSERSPERTEAM", "3000")
|
||||
@@ -485,7 +485,7 @@ func TestFileStoreSet(t *testing.T) {
|
||||
defer tearDown()
|
||||
|
||||
newCfg := &model.Config{}
|
||||
newCfg.LdapSettings.BindPassword = model.NewString(model.FAKE_SETTING)
|
||||
newCfg.LdapSettings.BindPassword = model.NewString(model.FakeSetting)
|
||||
|
||||
_, newConfig, err := configStore.Set(newCfg)
|
||||
require.NoError(t, err)
|
||||
@@ -764,7 +764,7 @@ func TestFileStoreLoad(t *testing.T) {
|
||||
assert.Equal(t, map[string]interface{}{"TeamSettings": map[string]interface{}{"MaxUsersPerTeam": true}}, fs.GetEnvironmentOverrides())
|
||||
// check that on disk config does not include overwritten variable
|
||||
actualConfig := getActualFileConfig(t, path)
|
||||
assert.Equal(t, model.TEAM_SETTINGS_DEFAULT_MAX_USERS_PER_TEAM, *actualConfig.TeamSettings.MaxUsersPerTeam)
|
||||
assert.Equal(t, model.TeamSettingsDefaultMaxUsersPerTeam, *actualConfig.TeamSettings.MaxUsersPerTeam)
|
||||
})
|
||||
|
||||
t.Run("do not persist environment variables - int64", func(t *testing.T) {
|
||||
|
||||
@@ -38,7 +38,7 @@ func truncateTable(t *testing.T, table string) {
|
||||
sqlStore := mainHelper.GetSQLStore()
|
||||
|
||||
switch *sqlSetting.DriverName {
|
||||
case model.DATABASE_DRIVER_MYSQL:
|
||||
case model.DatabaseDriverMysql:
|
||||
_, err := sqlStore.GetMaster().Db.Exec(fmt.Sprintf("TRUNCATE TABLE %s", table))
|
||||
if err != nil {
|
||||
if driverErr, ok := err.(*mysql.MySQLError); ok {
|
||||
@@ -50,7 +50,7 @@ func truncateTable(t *testing.T, table string) {
|
||||
}
|
||||
require.NoError(t, err)
|
||||
|
||||
case model.DATABASE_DRIVER_POSTGRES:
|
||||
case model.DatabaseDriverPostgres:
|
||||
_, err := sqlStore.GetMaster().Db.Exec(fmt.Sprintf("TRUNCATE TABLE %s", table))
|
||||
if err != nil {
|
||||
if driverErr, ok := err.(*pq.Error); ok {
|
||||
|
||||
@@ -23,51 +23,51 @@ func marshalConfig(cfg *model.Config) ([]byte, error) {
|
||||
|
||||
// desanitize replaces fake settings with their actual values.
|
||||
func desanitize(actual, target *model.Config) {
|
||||
if target.LdapSettings.BindPassword != nil && *target.LdapSettings.BindPassword == model.FAKE_SETTING {
|
||||
if target.LdapSettings.BindPassword != nil && *target.LdapSettings.BindPassword == model.FakeSetting {
|
||||
*target.LdapSettings.BindPassword = *actual.LdapSettings.BindPassword
|
||||
}
|
||||
|
||||
if *target.FileSettings.PublicLinkSalt == model.FAKE_SETTING {
|
||||
if *target.FileSettings.PublicLinkSalt == model.FakeSetting {
|
||||
*target.FileSettings.PublicLinkSalt = *actual.FileSettings.PublicLinkSalt
|
||||
}
|
||||
if *target.FileSettings.AmazonS3SecretAccessKey == model.FAKE_SETTING {
|
||||
if *target.FileSettings.AmazonS3SecretAccessKey == model.FakeSetting {
|
||||
target.FileSettings.AmazonS3SecretAccessKey = actual.FileSettings.AmazonS3SecretAccessKey
|
||||
}
|
||||
|
||||
if *target.EmailSettings.SMTPPassword == model.FAKE_SETTING {
|
||||
if *target.EmailSettings.SMTPPassword == model.FakeSetting {
|
||||
target.EmailSettings.SMTPPassword = actual.EmailSettings.SMTPPassword
|
||||
}
|
||||
|
||||
if *target.GitLabSettings.Secret == model.FAKE_SETTING {
|
||||
if *target.GitLabSettings.Secret == model.FakeSetting {
|
||||
target.GitLabSettings.Secret = actual.GitLabSettings.Secret
|
||||
}
|
||||
|
||||
if target.GoogleSettings.Secret != nil && *target.GoogleSettings.Secret == model.FAKE_SETTING {
|
||||
if target.GoogleSettings.Secret != nil && *target.GoogleSettings.Secret == model.FakeSetting {
|
||||
target.GoogleSettings.Secret = actual.GoogleSettings.Secret
|
||||
}
|
||||
|
||||
if target.Office365Settings.Secret != nil && *target.Office365Settings.Secret == model.FAKE_SETTING {
|
||||
if target.Office365Settings.Secret != nil && *target.Office365Settings.Secret == model.FakeSetting {
|
||||
target.Office365Settings.Secret = actual.Office365Settings.Secret
|
||||
}
|
||||
|
||||
if target.OpenIdSettings.Secret != nil && *target.OpenIdSettings.Secret == model.FAKE_SETTING {
|
||||
if target.OpenIdSettings.Secret != nil && *target.OpenIdSettings.Secret == model.FakeSetting {
|
||||
target.OpenIdSettings.Secret = actual.OpenIdSettings.Secret
|
||||
}
|
||||
|
||||
if *target.SqlSettings.DataSource == model.FAKE_SETTING {
|
||||
if *target.SqlSettings.DataSource == model.FakeSetting {
|
||||
*target.SqlSettings.DataSource = *actual.SqlSettings.DataSource
|
||||
}
|
||||
if *target.SqlSettings.AtRestEncryptKey == model.FAKE_SETTING {
|
||||
if *target.SqlSettings.AtRestEncryptKey == model.FakeSetting {
|
||||
target.SqlSettings.AtRestEncryptKey = actual.SqlSettings.AtRestEncryptKey
|
||||
}
|
||||
|
||||
if *target.ElasticsearchSettings.Password == model.FAKE_SETTING {
|
||||
if *target.ElasticsearchSettings.Password == model.FakeSetting {
|
||||
*target.ElasticsearchSettings.Password = *actual.ElasticsearchSettings.Password
|
||||
}
|
||||
|
||||
if len(target.SqlSettings.DataSourceReplicas) == len(actual.SqlSettings.DataSourceReplicas) {
|
||||
for i, value := range target.SqlSettings.DataSourceReplicas {
|
||||
if value == model.FAKE_SETTING {
|
||||
if value == model.FakeSetting {
|
||||
target.SqlSettings.DataSourceReplicas[i] = actual.SqlSettings.DataSourceReplicas[i]
|
||||
}
|
||||
}
|
||||
@@ -75,21 +75,21 @@ func desanitize(actual, target *model.Config) {
|
||||
|
||||
if len(target.SqlSettings.DataSourceSearchReplicas) == len(actual.SqlSettings.DataSourceSearchReplicas) {
|
||||
for i, value := range target.SqlSettings.DataSourceSearchReplicas {
|
||||
if value == model.FAKE_SETTING {
|
||||
if value == model.FakeSetting {
|
||||
target.SqlSettings.DataSourceSearchReplicas[i] = actual.SqlSettings.DataSourceSearchReplicas[i]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if *target.MessageExportSettings.GlobalRelaySettings.SmtpPassword == model.FAKE_SETTING {
|
||||
if *target.MessageExportSettings.GlobalRelaySettings.SmtpPassword == model.FakeSetting {
|
||||
*target.MessageExportSettings.GlobalRelaySettings.SmtpPassword = *actual.MessageExportSettings.GlobalRelaySettings.SmtpPassword
|
||||
}
|
||||
|
||||
if target.ServiceSettings.GfycatApiSecret != nil && *target.ServiceSettings.GfycatApiSecret == model.FAKE_SETTING {
|
||||
if target.ServiceSettings.GfycatApiSecret != nil && *target.ServiceSettings.GfycatApiSecret == model.FakeSetting {
|
||||
*target.ServiceSettings.GfycatApiSecret = *actual.ServiceSettings.GfycatApiSecret
|
||||
}
|
||||
|
||||
if *target.ServiceSettings.SplitKey == model.FAKE_SETTING {
|
||||
if *target.ServiceSettings.SplitKey == model.FakeSetting {
|
||||
*target.ServiceSettings.SplitKey = *actual.ServiceSettings.SplitKey
|
||||
}
|
||||
}
|
||||
@@ -102,7 +102,7 @@ func fixConfig(cfg *model.Config) {
|
||||
}
|
||||
|
||||
// Ensure the directory for a local file store has a trailing slash.
|
||||
if *cfg.FileSettings.DriverName == model.IMAGE_DRIVER_LOCAL {
|
||||
if *cfg.FileSettings.DriverName == model.ImageDriverLocal {
|
||||
if *cfg.FileSettings.Directory != "" && !strings.HasSuffix(*cfg.FileSettings.Directory, "/") {
|
||||
*cfg.FileSettings.Directory += "/"
|
||||
}
|
||||
@@ -120,13 +120,13 @@ func FixInvalidLocales(cfg *model.Config) bool {
|
||||
|
||||
locales := i18n.GetSupportedLocales()
|
||||
if _, ok := locales[*cfg.LocalizationSettings.DefaultServerLocale]; !ok {
|
||||
*cfg.LocalizationSettings.DefaultServerLocale = model.DEFAULT_LOCALE
|
||||
*cfg.LocalizationSettings.DefaultServerLocale = model.DefaultLocale
|
||||
mlog.Warn("DefaultServerLocale must be one of the supported locales. Setting DefaultServerLocale to en as default value.")
|
||||
changed = true
|
||||
}
|
||||
|
||||
if _, ok := locales[*cfg.LocalizationSettings.DefaultClientLocale]; !ok {
|
||||
*cfg.LocalizationSettings.DefaultClientLocale = model.DEFAULT_LOCALE
|
||||
*cfg.LocalizationSettings.DefaultClientLocale = model.DefaultLocale
|
||||
mlog.Warn("DefaultClientLocale must be one of the supported locales. Setting DefaultClientLocale to en as default value.")
|
||||
changed = true
|
||||
}
|
||||
|
||||
@@ -44,17 +44,17 @@ func TestDesanitize(t *testing.T) {
|
||||
target.FileSettings.DriverName = model.NewString("file")
|
||||
|
||||
// These settings should be updated from actual
|
||||
target.LdapSettings.BindPassword = model.NewString(model.FAKE_SETTING)
|
||||
target.FileSettings.PublicLinkSalt = model.NewString(model.FAKE_SETTING)
|
||||
target.FileSettings.AmazonS3SecretAccessKey = model.NewString(model.FAKE_SETTING)
|
||||
target.EmailSettings.SMTPPassword = model.NewString(model.FAKE_SETTING)
|
||||
target.GitLabSettings.Secret = model.NewString(model.FAKE_SETTING)
|
||||
target.OpenIdSettings.Secret = model.NewString(model.FAKE_SETTING)
|
||||
target.SqlSettings.DataSource = model.NewString(model.FAKE_SETTING)
|
||||
target.SqlSettings.AtRestEncryptKey = model.NewString(model.FAKE_SETTING)
|
||||
target.ElasticsearchSettings.Password = model.NewString(model.FAKE_SETTING)
|
||||
target.SqlSettings.DataSourceReplicas = []string{model.FAKE_SETTING, model.FAKE_SETTING}
|
||||
target.SqlSettings.DataSourceSearchReplicas = []string{model.FAKE_SETTING, model.FAKE_SETTING}
|
||||
target.LdapSettings.BindPassword = model.NewString(model.FakeSetting)
|
||||
target.FileSettings.PublicLinkSalt = model.NewString(model.FakeSetting)
|
||||
target.FileSettings.AmazonS3SecretAccessKey = model.NewString(model.FakeSetting)
|
||||
target.EmailSettings.SMTPPassword = model.NewString(model.FakeSetting)
|
||||
target.GitLabSettings.Secret = model.NewString(model.FakeSetting)
|
||||
target.OpenIdSettings.Secret = model.NewString(model.FakeSetting)
|
||||
target.SqlSettings.DataSource = model.NewString(model.FakeSetting)
|
||||
target.SqlSettings.AtRestEncryptKey = model.NewString(model.FakeSetting)
|
||||
target.ElasticsearchSettings.Password = model.NewString(model.FakeSetting)
|
||||
target.SqlSettings.DataSourceReplicas = []string{model.FakeSetting, model.FakeSetting}
|
||||
target.SqlSettings.DataSourceSearchReplicas = []string{model.FakeSetting, model.FakeSetting}
|
||||
|
||||
actualClone := actual.Clone()
|
||||
desanitize(actual, target)
|
||||
|
||||
Ссылка в новой задаче
Block a user