summaryrefslogtreecommitdiffstats
path: root/app/admin.go
diff options
context:
space:
mode:
authorSaturnino Abril <saturnino.abril@gmail.com>2017-09-06 03:42:18 +0800
committerGitHub <noreply@github.com>2017-09-06 03:42:18 +0800
commit8d680cf64ec7fb6c8b242b8048989d0f0550cb68 (patch)
tree700d39986d1973b51c875ab9bf50241762fc3e54 /app/admin.go
parent7405f66036537095b52c277d9b56969df33bfa57 (diff)
downloadchat-8d680cf64ec7fb6c8b242b8048989d0f0550cb68.tar.gz
chat-8d680cf64ec7fb6c8b242b8048989d0f0550cb68.tar.bz2
chat-8d680cf64ec7fb6c8b242b8048989d0f0550cb68.zip
[PLT-7475] Add S3 region to system console and add S3 validation (#7373)
* add S3 region to system console and add S3 validation * update translation message * add bool as return value to Validate* functions * update Validate* functions to be pure
Diffstat (limited to 'app/admin.go')
-rw-r--r--app/admin.go31
1 files changed, 30 insertions, 1 deletions
diff --git a/app/admin.go b/app/admin.go
index 609e37c96..531163046 100644
--- a/app/admin.go
+++ b/app/admin.go
@@ -11,13 +11,14 @@ import (
"runtime/debug"
+ "net/http"
+
l4g "github.com/alecthomas/log4go"
"github.com/mattermost/platform/einterfaces"
"github.com/mattermost/platform/jobs"
"github.com/mattermost/platform/model"
"github.com/mattermost/platform/store"
"github.com/mattermost/platform/utils"
- "net/http"
)
func GetLogs(page, perPage int) ([]string, *model.AppError) {
@@ -153,6 +154,34 @@ func SaveConfig(cfg *model.Config, sendConfigChangeClusterMessage bool) *model.A
return err
}
+ if *cfg.FileSettings.DriverName == model.IMAGE_DRIVER_S3 {
+ if !utils.ValidateAmazonS3Endpoint(*cfg.FileSettings.AmazonS3Endpoint) {
+ *cfg.FileSettings.AmazonS3Endpoint = model.FILE_SETTINGS_DEFAULT_AMAZON_S3_ENDPOINT
+ l4g.Warn(utils.T("utils.config.set_amazon_endpoint"), model.FILE_SETTINGS_DEFAULT_AMAZON_S3_ENDPOINT)
+ }
+
+ if !utils.ValidateAmazonS3Region(*cfg.FileSettings.AmazonS3Region) {
+ *cfg.FileSettings.AmazonS3Region = model.FILE_SETTINGS_DEFAULT_AMAZON_S3_REGION
+ l4g.Warn(utils.T("utils.config.set_amazon_region"), model.FILE_SETTINGS_DEFAULT_AMAZON_S3_REGION)
+ }
+
+ _, bucketLocation, err := utils.ValidateAmazonS3Bucket(cfg)
+ if err != nil {
+ return err
+ }
+
+ for endpoint, region := range utils.AWS_S3_ENDPOINT_MAP {
+ if bucketLocation == *cfg.FileSettings.AmazonS3Region {
+ *cfg.FileSettings.AmazonS3Endpoint = endpoint
+ l4g.Warn(utils.T("utils.config.set_amazon_endpoint"), endpoint)
+
+ *cfg.FileSettings.AmazonS3Region = region
+ l4g.Warn(utils.T("utils.config.set_amazon_region"), region)
+ break
+ }
+ }
+ }
+
if *utils.Cfg.ClusterSettings.Enable && *utils.Cfg.ClusterSettings.ReadOnlyConfig {
return model.NewAppError("saveConfig", "ent.cluster.save_config.error", nil, "", http.StatusForbidden)
}