22IMG ?= fluxcd/source-controller
33TAG ?= latest
44
5- # Base image used to build the Go binary
6- LIBGIT2_IMG ?= ghcr.io/fluxcd/golang-with-libgit2-only
7- LIBGIT2_TAG ?= v0.4.0
8-
95# Allows for defining additional Go test args, e.g. '-tags integration'.
106GO_TEST_ARGS ?= -race
117
@@ -39,14 +35,6 @@ ENVTEST_BIN_VERSION ?= 1.24.0
3935# each fuzzer should run for.
4036FUZZ_TIME ?= 1m
4137
42- # Caches libgit2 versions per tag, "forcing" rebuild only when needed.
43- LIBGIT2_PATH := $(BUILD_DIR ) /libgit2/$(LIBGIT2_TAG )
44- LIBGIT2_LIB_PATH := $(LIBGIT2_PATH ) /lib
45- LIBGIT2 := $(LIBGIT2_LIB_PATH ) /libgit2.a
46-
47- export CGO_ENABLED =1
48- export PKG_CONFIG_PATH =$(LIBGIT2_LIB_PATH ) /pkgconfig
49- export CGO_LDFLAGS =$(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH ) pkg-config --libs --static --cflags libgit2 2>/dev/null)
5038GO_STATIC_FLAGS =-ldflags "-s -w" -tags 'netgo,osusergo,static_build$(addprefix ,,$(GO_TAGS ) ) '
5139
5240# API (doc) generation utilities
@@ -75,11 +63,11 @@ endif
7563
7664all : build
7765
78- build : check-deps $( LIBGIT2 ) # # Build manager binary
66+ build : check-deps # # Build manager binary
7967 go build $(GO_STATIC_FLAGS ) -o $(BUILD_DIR ) /bin/manager main.go
8068
8169KUBEBUILDER_ASSETS? ="$(shell $(ENVTEST ) --arch=$(ENVTEST_ARCH ) use -i $(ENVTEST_KUBERNETES_VERSION ) --bin-dir=$(ENVTEST_ASSETS_DIR ) -p path) "
82- test : $( LIBGIT2 ) install-envtest test-api check-deps # # Run all tests
70+ test : install-envtest test-api check-deps # # Run all tests
8371 HTTPS_PROXY=" " HTTP_PROXY=" " \
8472 KUBEBUILDER_ASSETS=$(KUBEBUILDER_ASSETS ) \
8573 GIT_CONFIG_GLOBAL=/dev/null \
@@ -88,7 +76,7 @@ test: $(LIBGIT2) install-envtest test-api check-deps ## Run all tests
8876 $(GO_TEST_ARGS ) \
8977 -coverprofile cover.out
9078
91- test-ctrl : $( LIBGIT2 ) install-envtest test-api check-deps # # Run controller tests
79+ test-ctrl : install-envtest test-api check-deps # # Run controller tests
9280 HTTPS_PROXY=" " HTTP_PROXY=" " \
9381 KUBEBUILDER_ASSETS=$(KUBEBUILDER_ASSETS ) \
9482 GIT_CONFIG_GLOBAL=/dev/null \
10593test-api : # # Run api tests
10694 cd api; go test $(GO_TEST_ARGS ) ./... -coverprofile cover.out
10795
108- run : $( LIBGIT2 ) generate fmt vet manifests # # Run against the configured Kubernetes cluster in ~/.kube/config
96+ run : generate fmt vet manifests # # Run against the configured Kubernetes cluster in ~/.kube/config
10997 go run $(GO_STATIC_FLAGS ) ./main.go
11098
11199install : manifests # # Install CRDs into a cluster
@@ -139,7 +127,7 @@ fmt: ## Run go fmt against code
139127 go fmt ./...
140128 cd api; go fmt ./...
141129
142- vet : $( LIBGIT2 ) # # Run go vet against code
130+ vet : # # Run go vet against code
143131 go vet ./...
144132 cd api; go vet ./...
145133
@@ -148,8 +136,6 @@ generate: controller-gen ## Generate API code
148136
149137docker-build : # # Build the Docker image
150138 docker buildx build \
151- --build-arg LIBGIT2_IMG=$(LIBGIT2_IMG ) \
152- --build-arg LIBGIT2_TAG=$(LIBGIT2_TAG ) \
153139 --platform=$(BUILD_PLATFORMS ) \
154140 -t $(IMG ) :$(TAG ) \
155141 $(BUILD_ARGS ) .
@@ -182,40 +168,14 @@ install-envtest: setup-envtest ## Download envtest binaries locally.
182168# setup-envtest sets anything below k8s to 0555
183169 chmod -R u+w $(BUILD_DIR)/testbin
184170
185- libgit2 : $(LIBGIT2 ) # # Detect or download libgit2 library
186-
187- COSIGN = $(GOBIN ) /cosign
188- $(LIBGIT2 ) :
189- $(call go-install-tool,$(COSIGN ) ,github.com/sigstore/cosign/cmd/cosign@latest)
190-
191- IMG=$(LIBGIT2_IMG) TAG=$(LIBGIT2_TAG) PATH=$(PATH):$(GOBIN) ./hack/install-libraries.sh
192-
193-
194171.PHONY : help
195172help : # # Display this help menu
196173 @awk ' BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-20s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST )
197174
198- update-attributions :
199- ./hack/update-attributions.sh
200-
201175e2e :
202176 ./hack/ci/e2e.sh
203177
204- verify : update-attributions fmt vet manifests api-docs tidy
205- ifneq ($(shell grep -o 'LIBGIT2_IMG ?= \w.* ' Makefile | cut -d ' ' -f 3) :$(shell grep -o 'LIBGIT2_TAG ?= \w.* ' Makefile | cut -d ' ' -f 3) , \
206- $(shell grep -o "LIBGIT2_IMG=\w.* " Dockerfile | cut -d'=' -f2) :$(shell grep -o "LIBGIT2_TAG=\w.* " Dockerfile | cut -d'=' -f2) )
207- @{ \
208- echo " LIBGIT2_IMG and LIBGIT2_TAG must match in both Makefile and Dockerfile" ; \
209- exit 1; \
210- }
211- endif
212- ifneq ($(shell grep -o 'LIBGIT2_TAG ?= \w.* ' Makefile | cut -d ' ' -f 3) , $(shell grep -o "LIBGIT2_TAG=.* " tests/fuzz/oss_fuzz_prebuild.sh | sed 's;LIBGIT2_TAG="$${LIBGIT2_TAG :-;;g' | sed 's;}";;g'))
213- @{ \
214- echo " LIBGIT2_TAG must match in both Makefile and tests/fuzz/oss_fuzz_prebuild.sh" ; \
215- exit 1; \
216- }
217- endif
218-
178+ verify : fmt vet manifests api-docs tidy
219179 @if [ ! " $$ (git status --porcelain --untracked-files=no)" = " " ]; then \
220180 echo " working directory is dirty:" ; \
221181 git --no-pager diff; \
@@ -236,7 +196,7 @@ rm -rf $$TMP_DIR ;\
236196endef
237197
238198# Build fuzzers used by oss-fuzz.
239- fuzz-build : $( LIBGIT2 )
199+ fuzz-build :
240200 rm -rf $(shell pwd) /build/fuzz/
241201 mkdir -p $(shell pwd) /build/fuzz/out/
242202
@@ -260,15 +220,3 @@ fuzz-native:
260220 KUBEBUILDER_ASSETS=$(KUBEBUILDER_ASSETS ) \
261221 FUZZ_TIME=$(FUZZ_TIME ) \
262222 ./tests/fuzz/native_go_run.sh
263-
264- # Creates an env file that can be used to load all source-controller's dependencies
265- # this is handy when you want to run adhoc debug sessions on tests or start the
266- # controller in a new debug session.
267- env : $(LIBGIT2 )
268- echo ' GO_ENABLED="1"' > $(BUILD_DIR ) /.env
269- echo ' PKG_CONFIG_PATH="$(PKG_CONFIG_PATH)"' >> $(BUILD_DIR ) /.env
270- echo ' LIBRARY_PATH="$(LIBRARY_PATH)"' >> $(BUILD_DIR ) /.env
271- echo ' CGO_CFLAGS="$(CGO_CFLAGS)"' >> $(BUILD_DIR ) /.env
272- echo ' CGO_LDFLAGS="$(CGO_LDFLAGS)"' >> $(BUILD_DIR ) /.env
273- echo ' KUBEBUILDER_ASSETS=$(KUBEBUILDER_ASSETS)' >> $(BUILD_DIR ) /.env
274- echo ' GIT_CONFIG_GLOBAL=/dev/null' >> $(BUILD_DIR ) /.env
0 commit comments