|
1 | 1 | BIN_NAME = "cloud-provider-ironcore" |
2 | 2 | IMG ?= controller:latest |
3 | 3 |
|
4 | | -# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary. |
5 | | -ENVTEST_K8S_VERSION = 1.32 |
6 | | - |
| 4 | +# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set) |
7 | 5 | ifeq (,$(shell go env GOBIN)) |
8 | 6 | GOBIN=$(shell go env GOPATH)/bin |
9 | 7 | else |
10 | 8 | GOBIN=$(shell go env GOBIN) |
11 | 9 | endif |
12 | 10 |
|
| 11 | +# CONTAINER_TOOL defines the container tool to be used for building images. |
| 12 | +# Be aware that the target commands are only tested with Docker which is |
| 13 | +# scaffolded by default. However, you might want to replace it to use other |
| 14 | +# tools. (i.e. podman) |
| 15 | +CONTAINER_TOOL ?= docker |
| 16 | + |
| 17 | +# Setting SHELL to bash allows bash commands to be executed by recipes. |
| 18 | +# Options are set to exit when a recipe line exits non-zero or a piped command fails. |
13 | 19 | SHELL = /usr/bin/env bash -o pipefail |
14 | 20 | .SHELLFLAGS = -ec |
15 | 21 |
|
@@ -62,14 +68,14 @@ vet: ## Run go vet against code. |
62 | 68 | test: fmt vet envtest ## Run tests. |
63 | 69 | KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" go test $$(go list ./... | grep -v /e2e) -coverprofile cover.out |
64 | 70 |
|
65 | | -.PHONY: docker-build |
66 | 71 | # Build the docker image |
67 | | -docker-build: |
68 | | - docker build . -t $(IMG) |
| 72 | +.PHONY: docker-build |
| 73 | +docker-build: ## Build docker image with the manager. |
| 74 | + $(CONTAINER_TOOL) build -t ${IMG} . |
69 | 75 |
|
70 | 76 | .PHONY: docker-push |
71 | | -docker-push: |
72 | | - docker push $(IMG) |
| 77 | +docker-push: ## Push docker image with the manager. |
| 78 | + $(CONTAINER_TOOL) push ${IMG} |
73 | 79 |
|
74 | 80 | .PHONY: clean-local-bin |
75 | 81 | clean-local-bin: |
@@ -130,13 +136,13 @@ $(GOLANGCI_LINT): $(LOCALBIN) |
130 | 136 | # $2 - package url which can be installed |
131 | 137 | # $3 - specific version of package |
132 | 138 | define go-install-tool |
133 | | -@[ -f "$(1)-$(3)" ] || { \ |
| 139 | +@[ -f "$(1)-$(3)" ] && [ "$$(readlink -- "$(1)" 2>/dev/null)" = "$(1)-$(3)" ] || { \ |
134 | 140 | set -e; \ |
135 | 141 | package=$(2)@$(3) ;\ |
136 | 142 | echo "Downloading $${package}" ;\ |
137 | | -rm -f $(1) || true ;\ |
| 143 | +rm -f $(1) ;\ |
138 | 144 | GOBIN=$(LOCALBIN) go install $${package} ;\ |
139 | 145 | mv $(1) $(1)-$(3) ;\ |
140 | 146 | } ;\ |
141 | | -ln -sf $(1)-$(3) $(1) |
| 147 | +ln -sf $$(realpath $(1)-$(3)) $(1) |
142 | 148 | endef |
0 commit comments