Skip to content

Commit 293a70b

Browse files
committed
chore(make): install kubebuilder as a unit test prereq
1 parent 01c0452 commit 293a70b

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

Makefile

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
SHELL := /bin/bash
66
PKG := github.com/operator-framework/operator-lifecycle-manager
7+
OS := $(shell go env GOOS)
8+
ARCH := $(shell go env GOARCH)
79
MOD_FLAGS := $(shell (go version | grep -q -E "1\.1[1-9]") && echo -mod=vendor)
810
CMDS := $(shell go list $(MOD_FLAGS) ./cmd/...)
911
TCMDS := $(shell go list $(MOD_FLAGS) ./test/e2e/...)
@@ -33,14 +35,23 @@ endif
3335
GIT_COMMIT := $(if $(SOURCE_GIT_COMMIT),$(SOURCE_GIT_COMMIT),$(shell git rev-parse HEAD))
3436

3537
.PHONY: build test run clean vendor schema-check \
36-
vendor-update coverage coverage-html e2e manifests controller-gen .FORCE
38+
vendor-update coverage coverage-html e2e manifests \
39+
controller-gen kubebuilder .FORCE
3740

3841
all: test build
3942

4043
test: clean cover.out
4144

42-
unit:
43-
go test $(MOD_FLAGS) $(SPECIFIC_UNIT_TEST) -v -race -tags=json1 -count=1 ./pkg/...
45+
unit: kubebuilder
46+
echo $(KUBEBUILDER_ENV)
47+
$(KUBEBUILDER_ENV) go test $(MOD_FLAGS) $(SPECIFIC_UNIT_TEST) -v -race -tags=json1 -count=1 ./pkg/...
48+
49+
# Install kubebuilder if not found
50+
kubebuilder:
51+
ifeq (, $(shell which kubebuilder))
52+
curl -sL https://go.kubebuilder.io/dl/2.0.1/$(OS)/$(ARCH) | tar -xz -C /tmp/
53+
KUBEBUILDER_ENV := KUBEBUILDER_ASSETS=/tmp/kubebuilder_2.0.1_$(OS)_$(ARCH)/bin
54+
endif
4455

4556
schema-check:
4657

0 commit comments

Comments
 (0)