Selaa lähdekoodia

Build target for "make tidy" (#2378)

The make tidy target runs "go mod tidy" in the root directory and all plugins.
mmetc 1 vuosi sitten
vanhempi
commit
1a6f12c88e

+ 14 - 4
Makefile

@@ -31,8 +31,8 @@ BUILD_REQUIRE_GO_MINOR ?= 20
 
 #--------------------------------------
 
-GOCMD = go
-GOTEST = $(GOCMD) test
+GO = go
+GOTEST = $(GO) test
 
 BUILD_CODENAME ?= alphaga
 
@@ -209,12 +209,21 @@ PLUGIN_VENDOR = $(foreach plugin,$(PLUGINS),$(shell if [ -f $(PLUGINS_DIR)/$(plu
 vendor:
 	$(foreach plugin_dir,$(PLUGIN_VENDOR), \
 		cd $(plugin_dir) >/dev/null && \
-		$(GOCMD) mod vendor && \
+		$(GO) mod vendor && \
 		cd - >/dev/null; \
 	)
-	$(GOCMD) mod vendor
+	$(GO) mod vendor
 	tar -czf vendor.tgz vendor $(foreach plugin_dir,$(PLUGIN_VENDOR),$(plugin_dir)/vendor)
 
+.PHONY: tidy
+tidy:
+	$(GO) mod tidy
+	$(foreach plugin_dir,$(PLUGIN_VENDOR), \
+		cd $(plugin_dir) >/dev/null && \
+		$(GO) mod tidy && \
+		cd - >/dev/null; \
+	)
+
 # remove vendor directories and vendor.tgz
 .PHONY: vendor-remove
 vendor-remove:
@@ -223,6 +232,7 @@ vendor-remove:
 	)
 	$(RM) vendor vendor.tgz
 
+
 .PHONY: package
 package:
 	@echo "Building Release to dir $(RELDIR)"

+ 3 - 3
cmd/crowdsec-cli/Makefile

@@ -5,9 +5,9 @@ ifeq ($(OS), Windows_NT)
 endif
 
 # Go parameters
-GOCMD = go
-GOBUILD = $(GOCMD) build
-GOTEST = $(GOCMD) test
+GO = go
+GOBUILD = $(GO) build
+GOTEST = $(GO) test
 
 BINARY_NAME = cscli$(EXT)
 PREFIX ?= "/"

+ 3 - 3
cmd/crowdsec/Makefile

@@ -5,9 +5,9 @@ ifeq ($(OS), Windows_NT)
 endif
 
 # Go parameters
-GOCMD = go
-GOBUILD = $(GOCMD) build
-GOTEST = $(GOCMD) test
+GO = go
+GOBUILD = $(GO) build
+GOTEST = $(GO) test
 
 CROWDSEC_BIN = crowdsec$(EXT)
 # names longer than 15 chars break 'pgrep'

+ 1 - 1
docker/test/tests/test_capi_whitelists.py

@@ -25,7 +25,7 @@ def test_capi_whitelists(crowdsec, tmp_path_factory, flavor,):
     with crowdsec(flavor=flavor, environment=env, volumes=volumes) as cs:
         cs.wait_for_log("*Starting processing data*")
         cs.wait_for_http(8080, '/health', want_status=HTTPStatus.OK)
-        res = cs.cont.exec_run(f'cscli config show-yaml')
+        res = cs.cont.exec_run('cscli config show-yaml')
         assert res.exit_code == 0
         stdout = res.output.decode()
         y = yaml.safe_load(stdout)

+ 2 - 2
plugins/notifications/dummy/Makefile

@@ -7,8 +7,8 @@ endif
 PLUGIN = dummy
 BINARY_NAME = notification-$(PLUGIN)$(EXT)
 
-GOCMD = go
-GOBUILD = $(GOCMD) build
+GO = go
+GOBUILD = $(GO) build
 
 build: clean
 	$(GOBUILD) $(LD_OPTS) $(BUILD_VENDOR_FLAGS) -o $(BINARY_NAME)

+ 2 - 2
plugins/notifications/email/Makefile

@@ -7,8 +7,8 @@ endif
 PLUGIN = email
 BINARY_NAME = notification-$(PLUGIN)$(EXT)
 
-GOCMD = go
-GOBUILD = $(GOCMD) build
+GO = go
+GOBUILD = $(GO) build
 
 build: clean
 	$(GOBUILD) $(LD_OPTS) $(BUILD_VENDOR_FLAGS) -o $(BINARY_NAME)

+ 2 - 2
plugins/notifications/http/Makefile

@@ -7,8 +7,8 @@ endif
 PLUGIN=http
 BINARY_NAME = notification-$(PLUGIN)$(EXT)
 
-GOCMD = go
-GOBUILD = $(GOCMD) build
+GO = go
+GOBUILD = $(GO) build
 
 build: clean
 	$(GOBUILD) $(LD_OPTS) $(BUILD_VENDOR_FLAGS) -o $(BINARY_NAME)

+ 2 - 2
plugins/notifications/sentinel/Makefile

@@ -5,8 +5,8 @@ ifeq ($(OS), Windows_NT)
 endif
 
 # Go parameters
-GOCMD = go
-GOBUILD = $(GOCMD) build
+GO = go
+GOBUILD = $(GO) build
 
 BINARY_NAME = notification-sentinel$(EXT)
 

+ 2 - 2
plugins/notifications/slack/Makefile

@@ -7,8 +7,8 @@ endif
 PLUGIN=slack
 BINARY_NAME = notification-$(PLUGIN)$(EXT)
 
-GOCMD = go
-GOBUILD = $(GOCMD) build
+GO = go
+GOBUILD = $(GO) build
 
 build: clean
 	$(GOBUILD) $(LD_OPTS) $(BUILD_VENDOR_FLAGS) -o $(BINARY_NAME)

+ 2 - 2
plugins/notifications/splunk/Makefile

@@ -7,8 +7,8 @@ endif
 PLUGIN=splunk
 BINARY_NAME = notification-$(PLUGIN)$(EXT)
 
-GOCMD = go
-GOBUILD = $(GOCMD) build
+GO = go
+GOBUILD = $(GO) build
 
 build: clean
 	$(GOBUILD) $(LD_OPTS) $(BUILD_VENDOR_FLAGS) -o $(BINARY_NAME)