Skip to content

Commit c45feb3

Browse files
committed
Allow overriding binaries installed by hack/go-install.sh
Makefile targets for binary dependencies (i.e. code-generator, openshift-goimports and golangci-lint) now use version-less filepaths: `$(TOOLS_DIR)/<Binary>` instead of `$(TOOLS_DIR)/<Binary>-<Version>` `$(TOOLS_DIR)/<Binary>` may be a symlink to the versioned executable file. Secondly, hack/go-install.sh now adds a check for `$(TOOLS_DIR)/<Binary>` to be present and executable, in which case it skips `go install` invocation. This allows for making local changes to these dependencies (e.g. when working on kcp-dev/code-generator) and generating client code. On-behalf-of: SAP [email protected] Signed-off-by: Robert Vasek <[email protected]>
1 parent 6954af5 commit c45feb3

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

Makefile

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,39 +42,39 @@ endif
4242

4343
CONTROLLER_GEN_VER := v0.16.1
4444
CONTROLLER_GEN_BIN := controller-gen
45-
CONTROLLER_GEN := $(TOOLS_DIR)/$(CONTROLLER_GEN_BIN)-$(CONTROLLER_GEN_VER)
45+
CONTROLLER_GEN := $(TOOLS_DIR)/$(CONTROLLER_GEN_BIN)
4646
export CONTROLLER_GEN # so hack scripts can use it
4747

4848
YAML_PATCH_VER ?= v0.0.11
4949
YAML_PATCH_BIN := yaml-patch
50-
YAML_PATCH := $(TOOLS_DIR)/$(YAML_PATCH_BIN)-$(YAML_PATCH_VER)
50+
YAML_PATCH := $(TOOLS_DIR)/$(YAML_PATCH_BIN)
5151
export YAML_PATCH # so hack scripts can use it
5252

5353
OPENSHIFT_GOIMPORTS_VER := c72f1dc2e3aacfa00aece3391d938c9bc734e791
5454
OPENSHIFT_GOIMPORTS_BIN := openshift-goimports
55-
OPENSHIFT_GOIMPORTS := $(TOOLS_DIR)/$(OPENSHIFT_GOIMPORTS_BIN)-$(OPENSHIFT_GOIMPORTS_VER)
55+
OPENSHIFT_GOIMPORTS := $(TOOLS_DIR)/$(OPENSHIFT_GOIMPORTS_BIN)
5656
export OPENSHIFT_GOIMPORTS # so hack scripts can use it
5757

5858
GOLANGCI_LINT_VER := v1.62.2
5959
GOLANGCI_LINT_BIN := golangci-lint
60-
GOLANGCI_LINT := $(TOOLS_GOBIN_DIR)/$(GOLANGCI_LINT_BIN)-$(GOLANGCI_LINT_VER)
60+
GOLANGCI_LINT := $(TOOLS_GOBIN_DIR)/$(GOLANGCI_LINT_BIN)
6161

6262
HTTEST_VER := v0.3.2
6363
HTTEST_BIN := httest
6464
HTTEST := $(TOOLS_GOBIN_DIR)/$(HTTEST_BIN)-$(HTTEST_VER)
6565

6666
GOTESTSUM_VER := v1.8.1
6767
GOTESTSUM_BIN := gotestsum
68-
GOTESTSUM := $(abspath $(TOOLS_DIR))/$(GOTESTSUM_BIN)-$(GOTESTSUM_VER)
68+
GOTESTSUM := $(abspath $(TOOLS_DIR))/$(GOTESTSUM_BIN)
6969

7070
LOGCHECK_VER := v0.8.2
7171
LOGCHECK_BIN := logcheck
72-
LOGCHECK := $(TOOLS_GOBIN_DIR)/$(LOGCHECK_BIN)-$(LOGCHECK_VER)
72+
LOGCHECK := $(TOOLS_GOBIN_DIR)/$(LOGCHECK_BIN)
7373
export LOGCHECK # so hack scripts can use it
7474

7575
CODE_GENERATOR_VER := v2.3.0
7676
CODE_GENERATOR_BIN := code-generator
77-
CODE_GENERATOR := $(TOOLS_GOBIN_DIR)/$(CODE_GENERATOR_BIN)-$(CODE_GENERATOR_VER)
77+
CODE_GENERATOR := $(TOOLS_GOBIN_DIR)/$(CODE_GENERATOR_BIN)
7878
export CODE_GENERATOR # so hack scripts can use it
7979

8080
KCP_APIGEN_BIN := apigen

hack/go-install.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ function clean {
4949
}
5050
trap clean EXIT
5151

52+
# An executable already exists, exit early.
53+
[[ -f "${GOBIN}/${2}" && -x $(realpath "${GOBIN}/${2}") ]] && exit 0
54+
5255
rm "${GOBIN}/${2}"* > /dev/null 2>&1 || true
5356

5457
cd "${tmp_dir}"
@@ -59,4 +62,4 @@ go mod init fake/mod
5962
# install the golang module specified as the first argument
6063
go install -tags kcptools "${1}@${3}"
6164
mv "${GOBIN}/${2}" "${GOBIN}/${2}-${3}"
62-
ln -sf "${GOBIN}/${2}-${3}" "${GOBIN}/${2}"
65+
ln -sf "${GOBIN}/${2}-${3}" "${GOBIN}/${2}"

0 commit comments

Comments
 (0)