diff --git a/Makefile b/Makefile index e905fff..32a6e43 100644 --- a/Makefile +++ b/Makefile @@ -18,7 +18,7 @@ TMPDIR ?= /tmp # Setup default go-make installation flags. INSTALL_FLAGS ?= -mod=readonly -buildvcs=auto # Setup go-make version to use desired build and config scripts. -GOMAKE_DEP ?= github.com/tkrop/go-make@v0.0.169 +GOMAKE_DEP ?= github.com/tkrop/go-make@v0.0.170 # Request targets from go-make show-targets target. TARGETS := $(shell command -v $(GOBIN)/go-make >/dev/null || \ $(GO) install $(INSTALL_FLAGS) $(GOMAKE_DEP) >&2 && \ diff --git a/VERSION b/VERSION index 2f86a4f..e649778 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.0.169 +0.0.170 diff --git a/config/Makefile b/config/Makefile index e905fff..32a6e43 100644 --- a/config/Makefile +++ b/config/Makefile @@ -18,7 +18,7 @@ TMPDIR ?= /tmp # Setup default go-make installation flags. INSTALL_FLAGS ?= -mod=readonly -buildvcs=auto # Setup go-make version to use desired build and config scripts. -GOMAKE_DEP ?= github.com/tkrop/go-make@v0.0.169 +GOMAKE_DEP ?= github.com/tkrop/go-make@v0.0.170 # Request targets from go-make show-targets target. TARGETS := $(shell command -v $(GOBIN)/go-make >/dev/null || \ $(GO) install $(INSTALL_FLAGS) $(GOMAKE_DEP) >&2 && \ diff --git a/config/Makefile.base b/config/Makefile.base index f04331c..17588d7 100644 --- a/config/Makefile.base +++ b/config/Makefile.base @@ -73,9 +73,9 @@ LD_FLAGS_LINUX ?= $(strip -s -w $(LDFLAGS)) TESTFLAGS ?= TEST_FLAGS ?= $(strip $(mod-readonly) -count=1 -race $(TESTFLAGS)) BUILDFLAGS ?= # -linkmode 'external' -extldflags '-static' -BUILD_FLAGS ?= $(strip $(mod-readonly) -buildvcs=auto -trimpath $(BUILDFLAGS)) +BUILD_FLAGS ?= $(strip $(mod-readonly) -trimpath $(BUILDFLAGS)) INSTALLFLAGS ?= -INSTALL_FLAGS ?= $(strip $(mod-readonly) -buildvcs=auto $(INSTALLFLAGS)) +INSTALL_FLAGS ?= $(strip $(mod-readonly) $(INSTALLFLAGS)) # Find container image command (docker, podman, or colima). find-cmd-image := $(shell command -v docker || \ @@ -177,7 +177,7 @@ DIR_CACHE := $(abspath $(TMPDIR))/go-make-$(USER)$(DIR_REAL) $(call cdebug,using DIR_CACHE [$(DIR_CACHE)]) # Setup go-make to use desired build and config scripts. -GOMAKE_DEP := github.com/tkrop/go-make@v0.0.169 +GOMAKE_DEP := github.com/tkrop/go-make@v0.0.170 GOMAKE_PATH := $(GOPATH)/pkg/mod/$(GOMAKE_DEP)/config GOMAKE_MAKEFILE := $(realpath $(firstword $(MAKEFILE_LIST))) GOMAKE_CONFIG := $(patsubst %/,%,$(dir $(GOMAKE_MAKEFILE))) @@ -393,10 +393,23 @@ GOLANGCI_VERSION ?= v2.5.0 # https://github.com/codacy/codacy-gorevive/blob/master/.tool_version REVIVE_VERSION ?= v1.12.0 +# Setup default variables for kubernetes code generation. +KUBE_APIS ?= $(shell FILES=($$($(call find-go,.,-path "*/apis/*/*/*.go"))); \ + if [ -n "$${FILES}" ]; then grep -E "\+(kubebuilder|k8s)" "$${FILES[@]}" | \ + sed "s|apis/[^/]*/[^/]*/[^/]*.go:.*|apis|" | sort --unique; \ + fi) +KUBE_DIRS += $(strip $(KUBE_APIS:%/apis=%/clients) $(KUBE_APIS:%/apis=%/manifests)) +$(call cdebug,using KUBE_DIRS [$(KUBE_DIRS)]) +KUBE_SOURCES += $(strip $(shell $(call find-go,.,-name "mock_*_test.go" -o \ + -name "mock_*.go" -o -name "$(FILE_DEEPCOPY)")) \ + $(shell if [ -n "$(KUBE_DIRS)" ]; then $(call find-go,$(KUBE_DIRS),); fi)) +SOURCES := $(filter-out $(KUBE_SOURCES),$(shell $(call find-go,.,))) +MODULES := $(shell echo $(SOURCES) | xargs -r dirname | sort --unique) + # Setup default tool command versions to be installed. -TOOL_MOCK ?= $(or $(shell awk '($$1 ~ "/mock$$") && ($$3 != "//") \ - { print $$1 }' go.mod 2>/dev/null),go.uber.org/mock)/mockgen -TOOLS_GO += $(TOOL_MOCK) \ +TOOL_MOCKGEN ?= $(or $(shell awk '($$1 ~ "/mock$$") { print $$1 }' \ + go.mod 2>/dev/null | head --line=1),go.uber.org/mock)/mockgen +TOOLS_GO += $(TOOL_MOCKGEN) \ github.com/golangci/golangci-lint/v2/cmd/golangci-lint@$(GOLANGCI_VERSION) \ github.com/zalando/zally/cli/zally \ golang.org/x/vuln/cmd/govulncheck \ @@ -569,10 +582,6 @@ $(call cdebug,using CODACY_PROJECT_TOKEN [$(CODACY_PROJECT_TOKEN)]) $(call cdebug,using CODACY_API_BASE_URL [$(CODACY_API_BASE_URL)]) $(call cdebug,using CODACY_REPORTER_VERSION [$(CODACY_REPORTER_VERSION)]) -KUBE_APIS ?= $(shell FILES=($$($(call find-go,.,-path "*/apis/*/*/*.go"))); \ - if [ -n "$${FILES}" ]; then grep -E "\+(kubebuilder|k8s)" "$${FILES[@]}" | \ - sed "s|apis/[^/]*/[^/]*/[^/]*.go:.*|apis|" | sort --unique; \ - fi) UPDATE_KUBE_APIS ?= $(KUBE_APIS:%=update-kube/%) $(call cdebug,using UPDATE_KUBE_APIS [$(UPDATE_KUBE_APIS)]) UPDATE_KUBE_TARGETS := install-deepcopy-gen install-client-gen \ @@ -623,13 +632,6 @@ run-token-link = \ # Setup default environment variables. -KUBE_DIRS += $(strip $(KUBE_APIS:%/apis=%/clients) $(KUBE_APIS:%/apis=%/manifests)) -$(call cdebug,using KUBE_DIRS [$(KUBE_DIRS)]) -KUBE_SOURCES += $(strip $(shell $(call find-go,.,-name "mock_*_test.go" -o \ - -name "mock_*.go" -o -name "$(FILE_DEEPCOPY)")) \ - $(shell if [ -n "$(KUBE_DIRS)" ]; then $(call find-go,$(KUBE_DIRS),); fi)) -SOURCES := $(filter-out $(KUBE_SOURCES),$(shell $(call find-go,.,))) -MODULES := $(shell echo $(SOURCES) | xargs -r dirname | sort --unique) COMMANDS := $(shell $(call find-go,.,-name "main.go") | xargs -r readlink -f | \ awk -F '/' '{ for ( field = NF-1; field > 0; field--) { \ if ($$field != "cmd") { print $$field; break; } \ @@ -2345,6 +2347,12 @@ debug-kube:: echo 'KUBE_SOURCES $(KUBE_SOURCES)'; \ echo 'KUBE_TARGETS $(KUBE_TARGETS)'; +#@ debug the command environment variables. +debug-tools:: + @echo 'TOOLS_GO $(TOOLS_GO)'; \ + echo 'TOOLS_SH $(TOOLS_SH)'; \ + echo 'TOOLS_NPM $(TOOLS_NPM)'; + #@ debug the command environment variables. debug-commands:: @echo 'COMMANDS $(COMMANDS)'; \ diff --git a/go.mod b/go.mod index bf66415..687c6f9 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/tkrop/go-make -go 1.25.6 +go 1.25.7 require ( github.com/stretchr/testify v1.11.1 diff --git a/internal/make/fixtures/targets/go-make-std.out b/internal/make/fixtures/targets/go-make-std.out index ff669f3..417f1e3 100644 --- a/internal/make/fixtures/targets/go-make-std.out +++ b/internal/make/fixtures/targets/go-make-std.out @@ -81,6 +81,7 @@ debug-targets-run debug-targets-test debug-targets-uninstall debug-targets-update +debug-tools format format-go git-clean diff --git a/internal/make/fixtures/targets/go-make-trace.out b/internal/make/fixtures/targets/go-make-trace.out index 282b3bd..0d7c806 100644 --- a/internal/make/fixtures/targets/go-make-trace.out +++ b/internal/make/fixtures/targets/go-make-trace.out @@ -92,6 +92,7 @@ debug-targets-run debug-targets-test debug-targets-uninstall debug-targets-update +debug-tools format format-go git-clean diff --git a/internal/make/fixtures/targets/std.out b/internal/make/fixtures/targets/std.out index ff669f3..417f1e3 100644 --- a/internal/make/fixtures/targets/std.out +++ b/internal/make/fixtures/targets/std.out @@ -81,6 +81,7 @@ debug-targets-run debug-targets-test debug-targets-uninstall debug-targets-update +debug-tools format format-go git-clean diff --git a/internal/make/fixtures/targets/trace.out b/internal/make/fixtures/targets/trace.out index 9e2f21a..d9b889b 100644 --- a/internal/make/fixtures/targets/trace.out +++ b/internal/make/fixtures/targets/trace.out @@ -92,6 +92,7 @@ debug-targets-run debug-targets-test debug-targets-uninstall debug-targets-update +debug-tools format format-go git-clean