diff --git a/Makefile b/Makefile index da4c7f9b91..9598d36009 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: build package run stop run-client run-server stop-client stop-server restart restart-server restart-client start-docker clean-dist clean nuke check-style check-client-style check-server-style check-unit-tests test dist prepare-enteprise run-client-tests setup-run-client-tests cleanup-run-client-tests test-client build-linux build-osx build-windows internal-test-web-client vet run-server-for-web-client-tests +.PHONY: build package run stop run-client run-server stop-client stop-server restart restart-server restart-client start-docker clean-dist clean nuke check-style check-client-style check-server-style check-unit-tests test dist prepare-enteprise run-client-tests setup-run-client-tests cleanup-run-client-tests test-client build-linux build-osx build-windows internal-test-web-client vet run-server-for-web-client-tests diff-config ROOT := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) @@ -410,6 +410,9 @@ config-reset: ## Resets the config/config.json file to the default. rm -f config/config.json OUTPUT_CONFIG=$(PWD)/config/config.json go generate ./config +diff-config: ## Compares default configuration between two mattermost versions + @./scripts/diff-config.sh + clean: stop-docker ## Clean up everything except persistant server data. @echo Cleaning diff --git a/scripts/diff-config.sh b/scripts/diff-config.sh new file mode 100755 index 0000000000..6eb45c5120 --- /dev/null +++ b/scripts/diff-config.sh @@ -0,0 +1,53 @@ +#!/usr/bin/env bash + +jq_cmd=jq +[[ $(type -P "$jq_cmd") ]] || { + echo "'$jq_cmd' command line JSON processor not found"; + echo "Please install on linux with 'sudo apt-get install jq'" + echo "Please install on mac with 'brew install jq'" + exit 1; +} + +if [ -z "$FROM" ] +then + echo "Missing FROM version. Usage: make diff-config FROM=1.1.1 TO=2.2.2" + exit 1 +fi + +if [ -z "$TO" ] +then + echo "Missing TO version. Usage: make diff-config FROM=1.1.1 TO=2.2.2" + exit 1 +fi + +# Returns the config file for a specific release +fetch_config() { + local url="https://releases.mattermost.com/$1/mattermost-$1-linux-amd64.tar.gz" + curl -sf "$url" | tar -xzOf - mattermost/config/config.json | jq -S . +} + +echo Fetching config files +from_config="$(fetch_config "$FROM")" +if [ -z "$from_config" ] +then + echo Invalid version "$FROM" + exit 1 +fi + +to_config=$(fetch_config "$TO") +if [ -z "$to_config" ] +then + echo Invalid version "$TO" + exit 1 +fi + +echo Comparing config files +diff -y <(echo "$from_config") <(echo "$to_config") + +# We ignore exits with 1 since it just means there's a difference, which is fine for us. +diff_exit=$? +if [ $diff_exit -eq 1 ]; then + exit 0 +else + exit $diff_exit +fi