2
2
IMG ?= fluxcd/source-controller
3
3
TAG ?= latest
4
4
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
-
9
5
# Allows for defining additional Go test args, e.g. '-tags integration'.
10
6
GO_TEST_ARGS ?= -race
11
7
@@ -39,14 +35,6 @@ ENVTEST_BIN_VERSION ?= 1.24.0
39
35
# each fuzzer should run for.
40
36
FUZZ_TIME ?= 1m
41
37
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)
50
38
GO_STATIC_FLAGS =-ldflags "-s -w" -tags 'netgo,osusergo,static_build$(addprefix ,,$(GO_TAGS ) ) '
51
39
52
40
# API (doc) generation utilities
@@ -75,11 +63,11 @@ endif
75
63
76
64
all : build
77
65
78
- build : check-deps $( LIBGIT2 ) # # Build manager binary
66
+ build : check-deps # # Build manager binary
79
67
go build $(GO_STATIC_FLAGS ) -o $(BUILD_DIR ) /bin/manager main.go
80
68
81
69
KUBEBUILDER_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
83
71
HTTPS_PROXY=" " HTTP_PROXY=" " \
84
72
KUBEBUILDER_ASSETS=$(KUBEBUILDER_ASSETS ) \
85
73
GIT_CONFIG_GLOBAL=/dev/null \
@@ -88,7 +76,7 @@ test: $(LIBGIT2) install-envtest test-api check-deps ## Run all tests
88
76
$(GO_TEST_ARGS ) \
89
77
-coverprofile cover.out
90
78
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
92
80
HTTPS_PROXY=" " HTTP_PROXY=" " \
93
81
KUBEBUILDER_ASSETS=$(KUBEBUILDER_ASSETS ) \
94
82
GIT_CONFIG_GLOBAL=/dev/null \
105
93
test-api : # # Run api tests
106
94
cd api; go test $(GO_TEST_ARGS ) ./... -coverprofile cover.out
107
95
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
109
97
go run $(GO_STATIC_FLAGS ) ./main.go
110
98
111
99
install : manifests # # Install CRDs into a cluster
@@ -139,7 +127,7 @@ fmt: ## Run go fmt against code
139
127
go fmt ./...
140
128
cd api; go fmt ./...
141
129
142
- vet : $( LIBGIT2 ) # # Run go vet against code
130
+ vet : # # Run go vet against code
143
131
go vet ./...
144
132
cd api; go vet ./...
145
133
@@ -148,8 +136,6 @@ generate: controller-gen ## Generate API code
148
136
149
137
docker-build : # # Build the Docker image
150
138
docker buildx build \
151
- --build-arg LIBGIT2_IMG=$(LIBGIT2_IMG ) \
152
- --build-arg LIBGIT2_TAG=$(LIBGIT2_TAG ) \
153
139
--platform=$(BUILD_PLATFORMS ) \
154
140
-t $(IMG ) :$(TAG ) \
155
141
$(BUILD_ARGS ) .
@@ -182,40 +168,14 @@ install-envtest: setup-envtest ## Download envtest binaries locally.
182
168
# setup-envtest sets anything below k8s to 0555
183
169
chmod -R u+w $(BUILD_DIR)/testbin
184
170
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
-
194
171
.PHONY : help
195
172
help : # # Display this help menu
196
173
@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 )
197
174
198
- update-attributions :
199
- ./hack/update-attributions.sh
200
-
201
175
e2e :
202
176
./hack/ci/e2e.sh
203
177
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
219
179
@if [ ! " $$ (git status --porcelain --untracked-files=no)" = " " ]; then \
220
180
echo " working directory is dirty:" ; \
221
181
git --no-pager diff; \
@@ -236,7 +196,7 @@ rm -rf $$TMP_DIR ;\
236
196
endef
237
197
238
198
# Build fuzzers used by oss-fuzz.
239
- fuzz-build : $( LIBGIT2 )
199
+ fuzz-build :
240
200
rm -rf $(shell pwd) /build/fuzz/
241
201
mkdir -p $(shell pwd) /build/fuzz/out/
242
202
@@ -260,15 +220,3 @@ fuzz-native:
260
220
KUBEBUILDER_ASSETS=$(KUBEBUILDER_ASSETS ) \
261
221
FUZZ_TIME=$(FUZZ_TIME ) \
262
222
./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