mirror of
https://github.com/crowdsecurity/crowdsec.git
synced 2025-05-10 20:05:55 +02:00
make: remove redundant go version check (#3118)
It's already done by the toolchain with go.mod
This commit is contained in:
parent
96a6eec1fb
commit
aa0c389d2b
3 changed files with 7 additions and 67 deletions
19
Makefile
19
Makefile
|
@ -25,10 +25,6 @@ BUILD_STATIC ?= 0
|
|||
# List of plugins to build
|
||||
PLUGINS ?= $(patsubst ./cmd/notification-%,%,$(wildcard ./cmd/notification-*))
|
||||
|
||||
# Can be overriden, if you can deal with the consequences
|
||||
BUILD_REQUIRE_GO_MAJOR ?= 1
|
||||
BUILD_REQUIRE_GO_MINOR ?= 21
|
||||
|
||||
#--------------------------------------
|
||||
|
||||
GO = go
|
||||
|
@ -128,10 +124,10 @@ endif
|
|||
#--------------------------------------
|
||||
|
||||
.PHONY: build
|
||||
build: pre-build goversion crowdsec cscli plugins ## Build crowdsec, cscli and plugins
|
||||
build: build-info crowdsec cscli plugins ## Build crowdsec, cscli and plugins
|
||||
|
||||
.PHONY: pre-build
|
||||
pre-build: ## Sanity checks and build information
|
||||
.PHONY: build-info
|
||||
build-info: ## Print build information
|
||||
$(info Building $(BUILD_VERSION) ($(BUILD_TAG)) $(BUILD_TYPE) for $(GOOS)/$(GOARCH))
|
||||
|
||||
ifneq (,$(RE2_FAIL))
|
||||
|
@ -195,11 +191,11 @@ clean: clean-debian clean-rpm testclean ## Remove build artifacts
|
|||
)
|
||||
|
||||
.PHONY: cscli
|
||||
cscli: goversion ## Build cscli
|
||||
cscli: ## Build cscli
|
||||
@$(MAKE) -C $(CSCLI_FOLDER) build $(MAKE_FLAGS)
|
||||
|
||||
.PHONY: crowdsec
|
||||
crowdsec: goversion ## Build crowdsec
|
||||
crowdsec: ## Build crowdsec
|
||||
@$(MAKE) -C $(CROWDSEC_FOLDER) build $(MAKE_FLAGS)
|
||||
|
||||
.PHONY: generate
|
||||
|
@ -223,11 +219,11 @@ testenv:
|
|||
@echo 'NOTE: You need to run "make localstack" in a separate shell, "make localstack-stop" to terminate it'
|
||||
|
||||
.PHONY: test
|
||||
test: testenv goversion ## Run unit tests with localstack
|
||||
test: testenv ## Run unit tests with localstack
|
||||
$(GOTEST) $(LD_OPTS) ./...
|
||||
|
||||
.PHONY: go-acc
|
||||
go-acc: testenv goversion ## Run unit tests with localstack + coverage
|
||||
go-acc: testenv ## Run unit tests with localstack + coverage
|
||||
go-acc ./... -o coverage.out --ignore database,notifications,protobufs,cwversion,cstest,models -- $(LD_OPTS)
|
||||
|
||||
check_docker:
|
||||
|
@ -305,5 +301,4 @@ else
|
|||
include test/bats.mk
|
||||
endif
|
||||
|
||||
include mk/goversion.mk
|
||||
include mk/help.mk
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
##This must be called with $(MINIMUM_SUPPORTED_GO_MAJOR_VERSION) $(MINIMUM_SUPPORTED_GO_MINOR_VERSION) in this order
|
||||
$min_major=$args[0]
|
||||
$min_minor=$args[1]
|
||||
$goversion = (go env GOVERSION).replace("go","").split(".")
|
||||
$goversion_major=$goversion[0]
|
||||
$goversion_minor=$goversion[1]
|
||||
$err_msg="Golang version $goversion_major.$goversion_minor is not supported, please use least $min_major.$min_minor"
|
||||
|
||||
if ( $goversion_major -gt $min_major ) {
|
||||
exit 0;
|
||||
}
|
||||
elseif ($goversion_major -lt $min_major) {
|
||||
Write-Output $err_msg;
|
||||
exit 1;
|
||||
}
|
||||
elseif ($goversion_minor -lt $min_minor) {
|
||||
Write-Output $(GO_VERSION_VALIDATION_ERR_MSG);
|
||||
exit 1;
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
|
||||
BUILD_GOVERSION = $(subst go,,$(shell $(GO) env GOVERSION))
|
||||
|
||||
go_major_minor = $(subst ., ,$(BUILD_GOVERSION))
|
||||
GO_MAJOR_VERSION = $(word 1, $(go_major_minor))
|
||||
GO_MINOR_VERSION = $(word 2, $(go_major_minor))
|
||||
|
||||
GO_VERSION_VALIDATION_ERR_MSG = Golang version ($(BUILD_GOVERSION)) is not supported, please use at least $(BUILD_REQUIRE_GO_MAJOR).$(BUILD_REQUIRE_GO_MINOR)
|
||||
|
||||
|
||||
.PHONY: goversion
|
||||
goversion: $(if $(findstring devel,$(shell $(GO) env GOVERSION)),goversion_devel,goversion_check)
|
||||
|
||||
|
||||
.PHONY: goversion_devel
|
||||
goversion_devel:
|
||||
$(warning WARNING: You are using a development version of Golang ($(BUILD_GOVERSION)) which is not supported. For production environments, use a stable version (at least $(BUILD_REQUIRE_GO_MAJOR).$(BUILD_REQUIRE_GO_MINOR)))
|
||||
$(info )
|
||||
|
||||
|
||||
.PHONY: goversion_check
|
||||
goversion_check:
|
||||
ifneq ($(OS), Windows_NT)
|
||||
@if [ $(GO_MAJOR_VERSION) -gt $(BUILD_REQUIRE_GO_MAJOR) ]; then \
|
||||
exit 0; \
|
||||
elif [ $(GO_MAJOR_VERSION) -lt $(BUILD_REQUIRE_GO_MAJOR) ]; then \
|
||||
echo '$(GO_VERSION_VALIDATION_ERR_MSG)';\
|
||||
exit 1; \
|
||||
elif [ $(GO_MINOR_VERSION) -lt $(BUILD_REQUIRE_GO_MINOR) ] ; then \
|
||||
echo '$(GO_VERSION_VALIDATION_ERR_MSG)';\
|
||||
exit 1; \
|
||||
fi
|
||||
else
|
||||
# This needs Set-ExecutionPolicy -Scope CurrentUser Unrestricted
|
||||
@$(CURDIR)/mk/check_go_version.ps1 $(BUILD_REQUIRE_GO_MAJOR) $(BUILD_REQUIRE_GO_MINOR)
|
||||
endif
|
Loading…
Add table
Add a link
Reference in a new issue