github.com/gigforks/mattermost-server@v4.9.1-0.20180619094218-800d97fa55d0+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 if esI := a.Elasticsearch; esI != nil { 22 if err := esI.TestConfig(cfg); err != nil { 23 return err 24 } 25 } else { 26 err := model.NewAppError("TestElasticsearch", "ent.elasticsearch.test_config.license.error", nil, "", http.StatusNotImplemented) 27 return err 28 } 29 30 return nil 31 } 32 33 func (a *App) PurgeElasticsearchIndexes() *model.AppError { 34 if esI := a.Elasticsearch; esI != nil { 35 if err := esI.PurgeIndexes(); err != nil { 36 return err 37 } 38 } else { 39 err := model.NewAppError("PurgeElasticsearchIndexes", "ent.elasticsearch.test_config.license.error", nil, "", http.StatusNotImplemented) 40 return err 41 } 42 43 return nil 44 }