@@ -6,10 +6,6 @@ TAG ?= latest
66# Produce CRDs that work back to Kubernetes 1.16
77CRD_OPTIONS ?= crd:crdVersions=v1
88
9- # Base image used to build the Go binary
10- LIBGIT2_IMG ?= ghcr.io/fluxcd/golang-with-libgit2-only
11- LIBGIT2_TAG ?= v0.4.0
12-
139# Allows for defining additional Docker buildx arguments,
1410# e.g. '--push'.
1511BUILD_ARGS ?=
@@ -44,19 +40,6 @@ ENVTEST_BIN_VERSION ?= 1.19.2
4440# each fuzzer should run for.
4541FUZZ_TIME ?= 1m
4642
47- # Caches libgit2 versions per tag, "forcing" rebuild only when needed.
48- LIBGIT2_PATH := $(BUILD_DIR ) /libgit2/$(LIBGIT2_TAG )
49- LIBGIT2_LIB_PATH := $(LIBGIT2_PATH ) /lib
50- LIBGIT2_LIB64_PATH := $(LIBGIT2_PATH ) /lib64
51- LIBGIT2 := $(LIBGIT2_LIB_PATH ) /libgit2.a
52-
53- export CGO_ENABLED =1
54- export PKG_CONFIG_PATH =$(LIBGIT2_LIB_PATH ) /pkgconfig
55- export LIBRARY_PATH =$(LIBGIT2_LIB_PATH )
56- export CGO_CFLAGS =-I$(LIBGIT2_PATH ) /include -I$(LIBGIT2_PATH ) /include/openssl
57- export CGO_LDFLAGS =$(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH ) pkg-config --libs --static --cflags libgit2 2>/dev/null)
58-
59- # The pkg-config command will yield warning messages until libgit2 is downloaded.
6043ifeq ($(shell uname -s) ,Darwin)
6144GO_STATIC_FLAGS =-ldflags "-s -w" -tags 'netgo,osusergo,static_build'
6245endif
@@ -129,17 +112,17 @@ ifeq ($(shell uname -s),Darwin)
129112endif
130113
131114KUBEBUILDER_ASSETS? ="$(shell $(ENVTEST ) --arch=$(ENVTEST_ARCH ) use -i $(ENVTEST_KUBERNETES_VERSION ) --bin-dir=$(ENVTEST_ASSETS_DIR ) -p path) "
132- test : $( LIBGIT2 ) tidy test-api test_deps generate fmt vet manifests api-docs install-envtest # # Run tests
115+ test : tidy test-api test_deps generate fmt vet manifests api-docs install-envtest # # Run tests
133116 KUBEBUILDER_ASSETS=$(KUBEBUILDER_ASSETS ) \
134117 go test $(GO_STATIC_FLAGS ) $(GO_TEST_ARGS ) ./... -coverprofile cover.out
135118
136119test-api : # # Run api tests
137120 cd api; go test $(GO_TEST_ARGS ) ./... -coverprofile cover.out
138121
139- manager : $( LIBGIT2 ) generate fmt vet # # Build manager binary
122+ manager : generate fmt vet # # Build manager binary
140123 go build -o $(BUILD_DIR ) /bin/manager ./main.go
141124
142- run : $( LIBGIT2 ) generate fmt vet manifests # Run against the configured Kubernetes cluster in ~/.kube/config
125+ run : generate fmt vet manifests # Run against the configured Kubernetes cluster in ~/.kube/config
143126 go run $(GO_STATIC_FLAGS ) ./main.go --log-level=${LOG_LEVEL} --log-encoding=console
144127
145128install : manifests # # Install CRDs into a cluster
@@ -172,7 +155,7 @@ fmt: ## Run go fmt against code
172155 go fmt ./...
173156 cd api; go fmt ./...
174157
175- vet : $( LIBGIT2 ) # # Run go vet against code
158+ vet : # # Run go vet against code
176159 go vet ./...
177160 cd api; go vet ./...
178161
@@ -182,8 +165,6 @@ generate: controller-gen ## Generate code
182165
183166docker-build : # # Build the Docker image
184167 docker buildx build \
185- --build-arg LIBGIT2_IMG=$(LIBGIT2_IMG ) \
186- --build-arg LIBGIT2_TAG=$(LIBGIT2_TAG ) \
187168 --platform=$(BUILD_PLATFORMS ) \
188169 -t $(IMG ) :$(TAG ) \
189170 $(BUILD_ARGS ) .
@@ -200,14 +181,6 @@ CONTROLLER_GEN = $(GOBIN)/controller-gen
200181controller-gen : # # Download controller-gen locally if necessary.
201182 $(call go-install-tool,$(CONTROLLER_GEN ) ,sigs.k8s.io/controller-tools/cmd/[email protected] ) 202183
203- libgit2 : $(LIBGIT2 ) # # Detect or download libgit2 library
204-
205- COSIGN = $(GOBIN ) /cosign
206- $(LIBGIT2 ) :
207- $(call go-install-tool,$(COSIGN ) ,github.com/sigstore/cosign/cmd/cosign@latest)
208-
209- IMG=$(LIBGIT2_IMG) TAG=$(LIBGIT2_TAG) PATH=$(PATH):$(GOBIN) ./hack/install-libraries.sh
210-
211184# Find or download gen-crd-api-reference-docs
212185GEN_CRD_API_REFERENCE_DOCS = $(GOBIN ) /gen-crd-api-reference-docs
213186.PHONY : gen-crd-api-reference-docs
@@ -227,7 +200,7 @@ setup-envtest: ## Download envtest-setup locally if necessary.
227200 $(call go-install-tool,$(ENVTEST ) ,sigs.k8s.io/controller-runtime/tools/setup-envtest@latest)
228201
229202# Build fuzzers used by oss-fuzz.
230- fuzz-build : $( LIBGIT2 )
203+ fuzz-build :
231204 rm -rf $(shell pwd) /build/fuzz/
232205 mkdir -p $(shell pwd) /build/fuzz/out/
233206
@@ -268,20 +241,7 @@ endef
268241update-attributions :
269242 ./hack/update-attributions.sh
270243
271- verify : update-attributions fmt
272- ifneq ($(shell grep -o 'LIBGIT2_IMG ?= \w.* ' Makefile | cut -d ' ' -f 3) :$(shell grep -o 'LIBGIT2_TAG ?= \w.* ' Makefile | cut -d ' ' -f 3) , \
273- $(shell grep -o "LIBGIT2_IMG=\w.* " Dockerfile | cut -d'=' -f2) :$(shell grep -o "LIBGIT2_TAG=\w.* " Dockerfile | cut -d'=' -f2) )
274- @{ \
275- echo " LIBGIT2_IMG and LIBGIT2_TAG must match in both Makefile and Dockerfile" ; \
276- exit 1; \
277- }
278- endif
279- 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'))
280- @{ \
281- echo " LIBGIT2_TAG must match in both Makefile and tests/fuzz/oss_fuzz_prebuild.sh" ; \
282- exit 1; \
283- }
284- endif
244+ verify :
285245ifneq (, $(shell git status --porcelain --untracked-files=no) )
286246 @{ \
287247 echo "working directory is dirty:"; \
@@ -293,15 +253,3 @@ endif
293253.PHONY : help
294254help : # # Display this help menu
295255 @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 )
296-
297- # Creates an env file that can be used to load all image-automation-controller's
298- # dependencies this is handy when you want to run adhoc debug sessions on tests or
299- # start the controller in a new debug session.
300- env : $(LIBGIT2 )
301- echo ' GO_ENABLED="1"' > $(BUILD_DIR ) /.env
302- echo ' PKG_CONFIG_PATH="$(PKG_CONFIG_PATH)"' >> $(BUILD_DIR ) /.env
303- echo ' LIBRARY_PATH="$(LIBRARY_PATH)"' >> $(BUILD_DIR ) /.env
304- echo ' CGO_CFLAGS="$(CGO_CFLAGS)"' >> $(BUILD_DIR ) /.env
305- echo ' CGO_LDFLAGS="$(CGO_LDFLAGS)"' >> $(BUILD_DIR ) /.env
306- echo ' KUBEBUILDER_ASSETS=$(KUBEBUILDER_ASSETS)' >> $(BUILD_DIR ) /.env
307- echo ' GIT_CONFIG_GLOBAL=/dev/null' >> $(BUILD_DIR ) /.env
0 commit comments