github.com/lologarithm/mattermost-server@v5.3.2-0.20181002060438-c82a84ed765b+incompatible/app/elasticsearch.go (about) 1 // Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved. 2 // See License.txt for license information. 3 4 package app 5 6 import ( 7 "net/http" 8 9 "github.com/mattermost/mattermost-server/model" 10 ) 11 12 func (a *App) TestElasticsearch(cfg *model.Config) *model.AppError { 13 if *cfg.ElasticsearchSettings.Password == model.FAKE_SETTING { 14 if *cfg.ElasticsearchSettings.ConnectionUrl == *a.Config().ElasticsearchSettings.ConnectionUrl && *cfg.ElasticsearchSettings.Username == *a.Config().ElasticsearchSettings.Username { 15 *cfg.ElasticsearchSettings.Password = *a.Config().ElasticsearchSettings.Password 16 } else { 17 return model.NewAppError("TestElasticsearch", "ent.elasticsearch.test_config.reenter_password", nil, "", http.StatusBadRequest) 18 } 19 } 20 21 esI := a.Elasticsearch 22 if esI == nil { 23 err := model.NewAppError("TestElasticsearch", "ent.elasticsearch.test_config.license.error", nil, "", http.StatusNotImplemented) 24 return err 25 } 26 if err := esI.TestConfig(cfg); err != nil { 27 return err 28 } 29 30 return nil 31 } 32 33 func (a *App) PurgeElasticsearchIndexes() *model.AppError { 34 esI := a.Elasticsearch 35 if esI == nil { 36 err := model.NewAppError("PurgeElasticsearchIndexes", "ent.elasticsearch.test_config.license.error", nil, "", http.StatusNotImplemented) 37 return err 38 } 39 40 if err := esI.PurgeIndexes(); err != nil { 41 return err 42 } 43 44 return nil 45 }