Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ benchmark:
coverage:
go tool cover -html coverage.out -o coverage.html

verify: toolchain tidy download ## Verify code. Includes dependencies, linting, formatting, etc
verify: tidy download ## Verify code. Includes dependencies, linting, formatting, etc
SKIP_INSTALLED=true make toolchain
make az-swagger-generate-clients-raw
go generate ./...
hack/boilerplate.sh
Expand Down
70 changes: 55 additions & 15 deletions hack/toolchain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,76 @@ set -euo pipefail
K8S_VERSION="${K8S_VERSION:="1.29.x"}"
KUBEBUILDER_ASSETS="/usr/local/kubebuilder/bin"

# Default SKIP_INSTALLED to false if not set
SKIP_INSTALLED="${SKIP_INSTALLED:=false}"

if [ "$SKIP_INSTALLED" == true ]; then
Copy link

Copilot AI Jan 26, 2026

Choose a reason for hiding this comment

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

Inconsistent use of single brackets with double equals operator. The codebase convention uses double brackets [[ with == for string comparisons (see hack/codegen.sh:81, hack/codegen.sh:103, hack/release/common.sh:98, etc.). Consider changing to: if [[ "$SKIP_INSTALLED" == true ]]; then

Copilot uses AI. Check for mistakes.
echo "[INF] Skipping tools already installed."
fi

# This is where go install will put things
TOOL_DEST="$(go env GOPATH)/bin"

main() {
tools
kubebuilder
gettrivy
}

# should-skip is a helper function to determine if installation of a tool should be skipped
# $1 is the expected command
should-skip() {
if [ "$SKIP_INSTALLED" == true ] && [ -f "$TOOL_DEST/$1" ]; then
Copy link

Copilot AI Jan 26, 2026

Choose a reason for hiding this comment

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

Inconsistent use of single brackets with double equals operator. The codebase convention uses double brackets [[ with == for string comparisons (see hack/codegen.sh:81, hack/codegen.sh:103, hack/release/common.sh:98, etc.). Consider changing to: if [[ "$SKIP_INSTALLED" == true ]] && [ -f "$TOOL_DEST/$1" ]; then

Copilot uses AI. Check for mistakes.
# We can skip installation
return 0
fi

# Installation is needed
return 1
}

# go-install is a helper function to install go tools
# $1 is the expected command
# $2 is the go install path
go-install() {
# Check to see if we need to install
if should-skip "$1"; then
# Silently skip, to avoid console debris
# echo "[INF] $1 is already installed, skipping."
return
fi

echo "[INF] Installing $1"
go install "$2"
}

tools() {
go install github.com/google/go-licenses@v1.6.0
go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.8.0
go install github.com/google/ko@v0.17.1
go install github.com/mikefarah/yq/v4@v4.45.1
go install github.com/norwoodj/helm-docs/cmd/helm-docs@v1.14.2
go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.19.0
go install github.com/sigstore/cosign/v2/cmd/cosign@v2.4.1
go-install go-licenses github.com/google/go-licenses@v1.6.0
go-install ko github.com/google/ko@v0.17.1
go-install yq github.com/mikefarah/yq/v4@v4.45.1
go-install helm-docs github.com/norwoodj/helm-docs/cmd/helm-docs@v1.14.2
go-install controller-gen sigs.k8s.io/controller-tools/cmd/controller-gen@v0.19.0
go-install cosign github.com/sigstore/cosign/v2/cmd/cosign@v2.4.1
# go install -tags extended github.com/gohugoio/hugo@v0.110.0
go install golang.org/x/vuln/cmd/govulncheck@v1.1.4
go install github.com/onsi/ginkgo/v2/ginkgo@latest
go install github.com/rhysd/actionlint/cmd/actionlint@v1.7.7
go install github.com/mattn/goveralls@v0.0.12
go install github.com/google/go-containerregistry/cmd/crane@v0.20.2
go install github.com/go-swagger/go-swagger/cmd/swagger@v0.33.1
go install github.com/Azure/aks-node-viewer/cmd/aks-node-viewer@latest
go install github.com/google/pprof@latest
go-install govulncheck golang.org/x/vuln/cmd/govulncheck@v1.1.4
go-install ginkgo github.com/onsi/ginkgo/v2/ginkgo@latest
go-install actionlint github.com/rhysd/actionlint/cmd/actionlint@v1.7.7
go-install goveralls github.com/mattn/goveralls@v0.0.12
go-install crane github.com/google/go-containerregistry/cmd/crane@v0.20.2
go-install swagger github.com/go-swagger/go-swagger/cmd/swagger@v0.33.1
go-install aks-node-viewer github.com/Azure/aks-node-viewer/cmd/aks-node-viewer@latest
go-install pprof github.com/google/pprof@latest

if ! echo "$PATH" | grep -q "${GOPATH:-undefined}/bin\|$HOME/go/bin"; then
echo "Go workspace's \"bin\" directory is not in PATH. Run 'export PATH=\"\$PATH:\${GOPATH:-\$HOME/go}/bin\"'."
fi

go-install golangci-lint github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.8.0

}

kubebuilder() {
echo "[INF] Setting up kubebuilder binaries for Kubernetes ${K8S_VERSION}"
sudo mkdir -p "${KUBEBUILDER_ASSETS}"
sudo chown "${USER}" "${KUBEBUILDER_ASSETS}"
arch=$(go env GOARCH)
Expand Down