[MM-14400] Programmatically generate default.json (#10551)

* create/update config.json using go generate

* added default config generator
added config-reset to Jenkins and make package, updated defaults to consider 'isNew' flag

* corrections after code review

* fixed Config.isValid to handle empty encryption keys

* fixed Config.isValid to handle empty encryption keys

* fixed Config.isValid to handle empty encryption keys

* isUpdate now only checks for nil

* Addressed review comments, added unit testing for default config generator

* err shadowing

* license

* provide output file for config generator via ENV variable, since go generate doesn't support arguments and we need two output paths (config-reset and package)

* cleanup

* proper defaults for PushNotificationServer and SendPushNotifications

* corrected generating defaults for TrustedProxyIPHeader to be consistent with default.json in master

* Check for empty SiteURL as well as nil

* corrected SiteURL settings and checking

* crazy typos fixed

* corrected tests to newly expected values

* relaxed the checks

* fixed formatting
Этот коммит содержится в:
Eli Yukelzon
2019-06-06 20:57:01 +03:00
коммит произвёл Jesse Hallam
родитель 978ee13262
Коммит 6a42ad2af5
16 изменённых файлов: 197 добавлений и 497 удалений

Просмотреть файл

@@ -136,7 +136,7 @@ podTemplate(label: 'jenkins-slave',
sh 'apt-get update && apt-get install zip -y'
// Modify config to run on jenkins
sh 'mv /go/src/github.com/mattermost/mattermost-server/config/default.json /go/src/github.com/mattermost/mattermost-server/config/config.json'
sh 'cd /go/src/github.com/mattermost/mattermost-server && make config-reset'
sh 'cd /go/src/github.com/mattermost/mattermost-server && sed -i \'s/dockerhost/localhost/g\' config/config.json'
sh 'cd /go/src/github.com/mattermost/mattermost-server && sed -i \'s/2500/10025/g\' config/config.json'
}

Просмотреть файл

@@ -100,7 +100,7 @@ pipeline {
ansiColor('xterm') {
sh """
cd /go/src/github.com/mattermost/mattermost-server
mv config/default.json config/config.json || echo ""
make config-reset
make check-style BUILD_NUMBER='${BRANCH_NAME}-${BUILD_NUMBER}'
make build BUILD_NUMBER='${BRANCH_NAME}-${BUILD_NUMBER}'
make package BUILD_NUMBER='${BRANCH_NAME}-${BUILD_NUMBER}'

Просмотреть файл

@@ -34,7 +34,7 @@ package:
@# Resource directories
mkdir -p $(DIST_PATH)/config
cp -L config/README.md $(DIST_PATH)/config
cp -L config/config.json $(DIST_PATH)/config
OUTPUT_CONFIG=$(PWD)/$(DIST_PATH)/config/config.json go generate ./config
cp -RL fonts $(DIST_PATH)
cp -RL templates $(DIST_PATH)
cp -RL i18n $(DIST_PATH)