Skip to content

Commit 0167640

Browse files
committed
chore(make): use existing kubebuilder installation
- Make kubebuilder assets configurable using the KUBEBUILDER_ASSETS environment variable - Remove automatic kubebuilder installation - Throw make error if any kubebuilder assets are missing
1 parent f21dd11 commit 0167640

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

Makefile

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ endif
1111
SHELL := /bin/bash
1212
ORG := github.com/operator-framework
1313
PKG := $(ORG)/operator-lifecycle-manager
14-
OS := $(shell go env GOOS)
15-
ARCH := $(shell go env GOARCH)
1614
MOD_FLAGS := $(shell (go version | grep -q -E "1\.1[1-9]") && echo -mod=vendor)
1715
CMDS := $(shell go list $(MOD_FLAGS) ./cmd/...)
1816
TCMDS := $(shell go list $(MOD_FLAGS) ./test/e2e/...)
@@ -25,6 +23,7 @@ LOCAL_NAMESPACE := "olm"
2523
export GO111MODULE=on
2624
CONTROLLER_GEN := go run $(MOD_FLAGS) ./vendor/sigs.k8s.io/controller-tools/cmd/controller-gen
2725
YQ_INTERNAL := go run $(MOD_FLAGS) ./vendor/github.com/mikefarah/yq/v2/
26+
KUBEBUILDER_ASSETS ?= /usr/local/kubebuilder/bin
2827

2928
# ART builds are performed in dist-git, with content (but not commits) copied
3029
# from the source repo. Thus at build time if your code is inspecting the local
@@ -36,21 +35,27 @@ YQ_INTERNAL := go run $(MOD_FLAGS) ./vendor/github.com/mikefarah/yq/v2/
3635
GIT_COMMIT := $(if $(SOURCE_GIT_COMMIT),$(SOURCE_GIT_COMMIT),$(shell git rev-parse HEAD))
3736

3837
.PHONY: build test run clean vendor schema-check \
39-
vendor-update coverage coverage-html e2e .FORCE
38+
vendor-update coverage coverage-html e2e \
39+
kubebuilder .FORCE
4040

4141
all: test build
4242

4343
test: clean cover.out
4444

4545
unit: kubebuilder
46-
$(KUBEBUILDER_ENV) go test $(MOD_FLAGS) $(SPECIFIC_UNIT_TEST) -v -race -count=1 ./pkg/...
46+
KUBEBUILDER_ASSETS=$(KUBEBUILDER_ASSETS) go test $(MOD_FLAGS) $(SPECIFIC_UNIT_TEST) -v -race -count=1 ./pkg/...
4747

48-
# Install kubebuilder if not found
49-
KUBEBUILDER_DIR := /tmp/kubebuilder_2.3.1_$(OS)_$(ARCH)/bin
48+
# Ensure kubebuilder is installed before continuing
49+
KUBEBUILDER_ASSETS_ERR := not detected in $(KUBEBUILDER_ASSETS), to override the assets path set the KUBEBUILDER_ASSETS environment variable, for install instructions see https://book.kubebuilder.io/quick-start.html
5050
kubebuilder:
51-
ifeq (, $(shell which kubebuilder))
52-
[ ! -d "$(KUBEBUILDER_DIR)" ] && (curl -sL https://go.kubebuilder.io/dl/2.3.1/$(OS)/$(ARCH) | tar -xz -C /tmp/)
53-
KUBEBUILDER_ENV := KUBEBUILDER_ASSETS=$(KUBEBUILDER_DIR)
51+
ifeq (, $(wildcard $(KUBEBUILDER_ASSETS)/kubebuilder))
52+
$(error kubebuilder $(KUBEBUILDER_ASSETS_ERR))
53+
endif
54+
ifeq (, $(wildcard $(KUBEBUILDER_ASSETS)/etcd))
55+
$(error etcd $(KUBEBUILDER_ASSETS_ERR))
56+
endif
57+
ifeq (, $(wildcard $(KUBEBUILDER_ASSETS)/kube-apiserver))
58+
$(error kube-apiserver $(KUBEBUILDER_ASSETS_ERR))
5459
endif
5560

5661
schema-check:

0 commit comments

Comments
 (0)