Skip to content

Commit cd22809

Browse files
authored
Merge pull request #6815 from schrej/fix-make-generate-gopath
🐛 fix running make generate outside of GOPATH
2 parents eba218f + f96311c commit cd22809

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,7 @@ _releasenotes
8080

8181
# Helm
8282
.helm
83+
84+
# Used during parts of the build process. Files _should_ get cleaned up automatically.
85+
# This is also a good location for any temporary manfiests used during development
86+
tmp

Makefile

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ export PATH := $(abspath $(TOOLS_BIN_DIR)):$(PATH)
6565
# Set --output-base for conversion-gen if we are not within GOPATH
6666
ifneq ($(abspath $(ROOT_DIR)),$(shell go env GOPATH)/src/sigs.k8s.io/cluster-api)
6767
CONVERSION_GEN_OUTPUT_BASE := --output-base=$(ROOT_DIR)
68+
CONVERSION_GEN_OUTPUT_BASE_CAPD := --output-base=$(ROOT_DIR)/$(CAPD_DIR)
6869
else
6970
export GOPATH := $(shell go env GOPATH)
7071
endif
@@ -403,20 +404,23 @@ generate-go-conversions-capd: $(CONVERSION_GEN) ## Generate conversions go code
403404
--build-tag=ignore_autogenerated_capd \
404405
--extra-peer-dirs=sigs.k8s.io/cluster-api/api/v1alpha3 \
405406
--extra-peer-dirs=sigs.k8s.io/cluster-api/api/v1alpha4 \
406-
--output-file-base=zz_generated.conversion $(CONVERSION_GEN_OUTPUT_BASE) \
407+
--output-file-base=zz_generated.conversion $(CONVERSION_GEN_OUTPUT_BASE_CAPD) \
407408
--go-header-file=../../../hack/boilerplate/boilerplate.generatego.txt
408409

410+
# The tmp/sigs.k8s.io/cluster-api symlink is a workaround to make this target run outside of GOPATH
409411
.PHONY: generate-go-openapi
410412
generate-go-openapi: $(OPENAPI_GEN) $(CONTROLLER_GEN) ## Generate openapi go code for runtime SDK
411-
@for pkg in "api/v1beta1" "$(EXP_DIR)/runtime/hooks/api/v1alpha1"; do \
413+
@mkdir -p ./tmp/sigs.k8s.io; ln -s $(ROOT_DIR) ./tmp/sigs.k8s.io/; cd ./tmp; \
414+
for pkg in "api/v1beta1" "$(EXP_DIR)/runtime/hooks/api/v1alpha1"; do \
412415
$(MAKE) clean-generated-openapi-definitions SRC_DIRS="./$${pkg}"; \
413416
echo "** Generating openapi schema for types in ./$${pkg} **"; \
414417
$(OPENAPI_GEN) \
415-
--input-dirs=./$${pkg} \
418+
--input-dirs=sigs.k8s.io/cluster-api/$${pkg} \
416419
--output-file-base=zz_generated.openapi \
417420
--output-package=sigs.k8s.io/cluster-api/$${pkg} \
418-
--go-header-file=./hack/boilerplate/boilerplate.generatego.txt; \
419-
done
421+
--go-header-file=../hack/boilerplate/boilerplate.generatego.txt; \
422+
done; \
423+
rm sigs.k8s.io/cluster-api
420424

421425
.PHONY: generate-modules
422426
generate-modules: ## Run go mod tidy to ensure modules are up to date

0 commit comments

Comments
 (0)