From 71cdd9e486399f20039eaf147cb12dbcbff002a6 Mon Sep 17 00:00:00 2001 From: Tim Scheuermann Date: Thu, 9 Jun 2022 11:45:17 +0200 Subject: [PATCH] [MM-44364] make config override actually override defaults (#20379) --- Makefile | 112 ++++++++++++++++++++++++++++++------------------------- 1 file changed, 61 insertions(+), 51 deletions(-) diff --git a/Makefile b/Makefile index b973ac7660..54299aeaa3 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: build package run stop run-client run-server run-haserver stop-haserver stop-client stop-server restart restart-server restart-client restart-haserver start-docker clean-dist clean nuke check-style check-client-style check-server-style check-unit-tests test dist run-client-tests setup-run-client-tests cleanup-run-client-tests test-client build-linux build-osx build-windows package-prep package-linux package-osx package-windows internal-test-web-client vet run-server-for-web-client-tests diff-config prepackaged-plugins prepackaged-binaries test-server test-server-ee test-server-quick test-server-race start-docker-check migrations-bindata new-migration +.PHONY: build package run stop run-client run-server run-haserver stop-haserver stop-client stop-server restart restart-server restart-client restart-haserver start-docker clean-dist clean nuke check-style check-client-style check-server-style check-unit-tests test dist run-client-tests setup-run-client-tests cleanup-run-client-tests test-client build-linux build-osx build-windows package-prep package-linux package-osx package-windows internal-test-web-client vet run-server-for-web-client-tests diff-config prepackaged-plugins prepackaged-binaries test-server test-server-ee test-server-quick test-server-race migrations-bindata new-migration ROOT := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) @@ -39,14 +39,14 @@ BUILD_ENTERPRISE_READY = false BUILD_TYPE_NAME = team BUILD_HASH_ENTERPRISE = none ifneq ($(wildcard $(BUILD_ENTERPRISE_DIR)/.),) - ifeq ($(BUILD_ENTERPRISE),true) - BUILD_ENTERPRISE_READY = true - BUILD_TYPE_NAME = enterprise - BUILD_HASH_ENTERPRISE = $(shell cd $(BUILD_ENTERPRISE_DIR) && git rev-parse HEAD) - else - BUILD_ENTERPRISE_READY = false - BUILD_TYPE_NAME = team - endif + ifeq ($(BUILD_ENTERPRISE),true) + BUILD_ENTERPRISE_READY = true + BUILD_TYPE_NAME = enterprise + BUILD_HASH_ENTERPRISE = $(shell cd $(BUILD_ENTERPRISE_DIR) && git rev-parse HEAD) + else + BUILD_ENTERPRISE_READY = false + BUILD_TYPE_NAME = team + endif else BUILD_ENTERPRISE_READY = false BUILD_TYPE_NAME = team @@ -55,14 +55,14 @@ BUILD_WEBAPP_DIR ?= ../mattermost-webapp BUILD_CLIENT = false BUILD_HASH_CLIENT = independent ifneq ($(wildcard $(BUILD_WEBAPP_DIR)/.),) - ifeq ($(BUILD_CLIENT),true) - BUILD_CLIENT = true - BUILD_HASH_CLIENT = $(shell cd $(BUILD_WEBAPP_DIR) && git rev-parse HEAD) - else - BUILD_CLIENT = false - endif + ifeq ($(BUILD_CLIENT),true) + BUILD_CLIENT = true + BUILD_HASH_CLIENT = $(shell cd $(BUILD_WEBAPP_DIR) && git rev-parse HEAD) + else + BUILD_CLIENT = false + endif else - BUILD_CLIENT = false + BUILD_CLIENT = false endif # We need current user's UID for `run-haserver` so docker compose does not run server @@ -146,14 +146,22 @@ endif EE_PACKAGES=$(shell $(GO) list $(BUILD_ENTERPRISE_DIR)/...) ifeq ($(BUILD_ENTERPRISE_READY),true) -ALL_PACKAGES=$(TE_PACKAGES) $(EE_PACKAGES) + ALL_PACKAGES=$(TE_PACKAGES) $(EE_PACKAGES) else -ALL_PACKAGES=$(TE_PACKAGES) + ALL_PACKAGES=$(TE_PACKAGES) endif all: run ## Alias for 'run'. -include config.override.mk + +# Make sure not to modify an overridden ENABLED_DOCKER_SERVICES variable +DOCKER_SERVICES_OVERRIDE=false +ifneq (,$(ENABLED_DOCKER_SERVICES)) + $(info ENABLED_DOCKER_SERVICES has been overridden) + DOCKER_SERVICES_OVERRIDE=true +endif + include config.mk include build/*.mk @@ -166,22 +174,23 @@ endif DOCKER_COMPOSE_OVERRIDE= ifneq ("$(wildcard ./docker-compose.override.yaml)","") - DOCKER_COMPOSE_OVERRIDE=-f docker-compose.override.yaml + DOCKER_COMPOSE_OVERRIDE=-f docker-compose.override.yaml endif -start-docker-check: -ifeq (,$(findstring minio,$(ENABLED_DOCKER_SERVICES))) - TEMP_DOCKER_SERVICES:=$(TEMP_DOCKER_SERVICES) minio -endif -ifeq ($(BUILD_ENTERPRISE_READY),true) - ifeq (,$(findstring openldap,$(ENABLED_DOCKER_SERVICES))) - TEMP_DOCKER_SERVICES:=$(TEMP_DOCKER_SERVICES) openldap +ifneq ($(DOCKER_SERVICES_OVERRIDE),true) + ifeq (,$(findstring minio,$(ENABLED_DOCKER_SERVICES))) + TEMP_DOCKER_SERVICES:=$(TEMP_DOCKER_SERVICES) minio endif - ifeq (,$(findstring elasticsearch,$(ENABLED_DOCKER_SERVICES))) - TEMP_DOCKER_SERVICES:=$(TEMP_DOCKER_SERVICES) elasticsearch + ifeq ($(BUILD_ENTERPRISE_READY),true) + ifeq (,$(findstring openldap,$(ENABLED_DOCKER_SERVICES))) + TEMP_DOCKER_SERVICES:=$(TEMP_DOCKER_SERVICES) openldap + endif + ifeq (,$(findstring elasticsearch,$(ENABLED_DOCKER_SERVICES))) + TEMP_DOCKER_SERVICES:=$(TEMP_DOCKER_SERVICES) elasticsearch + endif endif + ENABLED_DOCKER_SERVICES:=$(ENABLED_DOCKER_SERVICES) $(TEMP_DOCKER_SERVICES) endif -ENABLED_DOCKER_SERVICES:=$(ENABLED_DOCKER_SERVICES) $(TEMP_DOCKER_SERVICES) start-docker: ## Starts the docker containers for local development. ifneq ($(IS_CI),false) @@ -191,13 +200,14 @@ else ifeq ($(MM_NO_DOCKER),true) else @echo Starting docker containers + docker-compose rm start_dependencies $(GO) run ./build/docker-compose-generator/main.go $(ENABLED_DOCKER_SERVICES) | docker-compose -f docker-compose.makefile.yml -f /dev/stdin $(DOCKER_COMPOSE_OVERRIDE) run -T --rm start_dependencies -ifneq (,$(findstring openldap,$(ENABLED_DOCKER_SERVICES))) + ifneq (,$(findstring openldap,$(ENABLED_DOCKER_SERVICES))) cat tests/${LDAP_DATA}-data.ldif | docker-compose -f docker-compose.makefile.yml $(DOCKER_COMPOSE_OVERRIDE) exec -T openldap bash -c 'ldapadd -x -D "cn=admin,dc=mm,dc=test,dc=com" -w mostest || true'; -endif -ifneq (,$(findstring mysql-read-replica,$(ENABLED_DOCKER_SERVICES))) + endif + ifneq (,$(findstring mysql-read-replica,$(ENABLED_DOCKER_SERVICES))) ./scripts/replica-mysql-config.sh -endif + endif endif run-haserver: @@ -255,9 +265,9 @@ golangci-lint: ## Run golangci-lint on codebase @echo Running golangci-lint $(GOBIN)/golangci-lint run ./... ifeq ($(BUILD_ENTERPRISE_READY),true) -ifneq ($(MM_NO_ENTERPRISE_LINT),true) + ifneq ($(MM_NO_ENTERPRISE_LINT),true) $(GOBIN)/golangci-lint run ../enterprise/... -endif + endif endif app-layers: ## Extract interface from App struct @@ -381,7 +391,7 @@ gomodtidy: fi; @rm go.*.orig; -test-server-pre: check-prereqs-enterprise start-docker-check start-docker go-junit-report do-cover-file ## Runs tests. +test-server-pre: check-prereqs-enterprise start-docker go-junit-report do-cover-file ## Runs tests. ifeq ($(BUILD_ENTERPRISE_READY),true) @echo Running all tests else @@ -390,27 +400,27 @@ endif test-server-race: test-server-pre ./scripts/test.sh "$(GO)" "-race $(GOFLAGS)" "$(ALL_PACKAGES)" "$(TESTS)" "$(TESTFLAGS)" "$(GOBIN)" "90m" "atomic" - ifneq ($(IS_CI),true) - ifneq ($(MM_NO_DOCKER),true) - ifneq ($(TEMP_DOCKER_SERVICES),) - @echo Stopping temporary docker services - docker-compose stop $(TEMP_DOCKER_SERVICES) - endif +ifneq ($(IS_CI),true) + ifneq ($(MM_NO_DOCKER),true) + ifneq ($(TEMP_DOCKER_SERVICES),) + @echo Stopping temporary docker services + docker-compose stop $(TEMP_DOCKER_SERVICES) endif endif +endif test-server: test-server-pre ./scripts/test.sh "$(GO)" "$(GOFLAGS)" "$(ALL_PACKAGES)" "$(TESTS)" "$(TESTFLAGS)" "$(GOBIN)" "45m" "count" - ifneq ($(IS_CI),true) - ifneq ($(MM_NO_DOCKER),true) - ifneq ($(TEMP_DOCKER_SERVICES),) - @echo Stopping temporary docker services - docker-compose stop $(TEMP_DOCKER_SERVICES) - endif +ifneq ($(IS_CI),true) + ifneq ($(MM_NO_DOCKER),true) + ifneq ($(TEMP_DOCKER_SERVICES),) + @echo Stopping temporary docker services + docker-compose stop $(TEMP_DOCKER_SERVICES) endif endif +endif -test-server-ee: check-prereqs-enterprise start-docker-check start-docker go-junit-report do-cover-file ## Runs EE tests. +test-server-ee: check-prereqs-enterprise start-docker go-junit-report do-cover-file ## Runs EE tests. @echo Running only EE tests ./scripts/test.sh "$(GO)" "$(GOFLAGS)" "$(EE_PACKAGES)" "$(TESTS)" "$(TESTFLAGS)" "$(GOBIN)" "20m" "count" @@ -645,9 +655,9 @@ vet: ## Run mattermost go vet specific checks fi; \ $(GO) vet -vettool=$(GOBIN)/mattermost-govet $$VET_CMD ./... ifeq ($(BUILD_ENTERPRISE_READY),true) -ifneq ($(MM_NO_ENTERPRISE_LINT),true) + ifneq ($(MM_NO_ENTERPRISE_LINT),true) $(GO) vet -vettool=$(GOBIN)/mattermost-govet -enterpriseLicense -structuredLogging -tFatal ../enterprise/... -endif + endif endif gen-serialized: export LICENSE_HEADER:=$(LICENSE_HEADER)