Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Solving make run errors under Go vendor mode. #1807

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions Makefile
Expand Up @@ -219,7 +219,7 @@ build:

.PHONY: run
run: manifests generate fmt vet ## Run a controller from your host.
$(GO_CMD) run cmd/kueue/main.go
$(GO_CMD) run cmd/kueue/main.go $(ARGS)

# Build the multiplatform container image locally.
.PHONY: image-local-build
Expand Down Expand Up @@ -327,7 +327,7 @@ golangci-lint: ## Download golangci-lint locally if necessary.
CONTROLLER_GEN = $(PROJECT_DIR)/bin/controller-gen
.PHONY: controller-gen
controller-gen: ## Download controller-gen locally if necessary.
@GOBIN=$(PROJECT_DIR)/bin GO111MODULE=on $(GO_CMD) install sigs.k8s.io/controller-tools/cmd/controller-gen
@GOBIN=$(PROJECT_DIR)/bin GO111MODULE=on $(GO_CMD) install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.14.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

controller-gen should use the version set in go.mod

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed. Please revert this line, as the version is locked in go.mod #1720

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed. Please revert this line, as the version is locked in go.mod #1720
I am a novice in Go and Kubernetes development. I wanted to address the following issue, which is why I changed that line of code.

image


KUSTOMIZE = $(PROJECT_DIR)/bin/kustomize
.PHONY: kustomize
Expand Down
13 changes: 8 additions & 5 deletions hack/update-codegen.sh
Expand Up @@ -19,11 +19,14 @@ set -o nounset
set -o pipefail

GO_CMD=${1:-go}
KUEUE_ROOT=$(realpath $(dirname ${BASH_SOURCE[0]})/..)
CODEGEN_PKG=$($GO_CMD list -m -f "{{.Dir}}" k8s.io/code-generator)

cd $(dirname ${BASH_SOURCE[0]})/..

KUEUE_ROOT=$(realpath $(dirname "${BASH_SOURCE[0]})"/..))
if [ -d "vendor" ]; then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do you have a vendor folder?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do you have a vendor folder?

"The 'go mod vendor' command automatically generates the 'vendor' directory. If this command is not used to copy dependencies to the project space, the GoLang editor cannot automatically locate dependencies such as 'sigs.k8s.io/controller-runtime', resulting in red error indicators indicating that the dependencies cannot be found."

CODEGEN_PKG=$($GO_CMD list -m -f "vendor/k8s.io/code-generator" k8s.io/code-generator)
else
CODEGEN_PKG=$($GO_CMD list -m -f "{{.Dir}}" k8s.io/code-generator)
fi

cd $(dirname "${BASH_SOURCE[0]}")/..
source "${CODEGEN_PKG}/kube_codegen.sh"

# TODO: remove the workaround when the issue is solved in the code-generator
Expand Down