Skip to content

Commit 16923f6

Browse files
This change respects developers' environments and preferences by prioritizing the globally installed kind binary for managing Kubernetes clusters. It reduces potential conflicts and debugging issues, ensuring better compatibility with existing setups.
1. **Image Loading Issues**: - Using a BINGO-installed `kind` binary caused images to load into the wrong cluster, leading to debugging delays. 2. **Hidden Clusters**: - Clusters created with the BINGO-managed `kind` were not visible in the global `kind` context, causing resource leaks and confusion. - Check for a globally installed `kind` binary and use it if available. - Fallback to the BINGO-managed `kind` binary only when no global version is detected. - Provide clear messaging about the binary being used. - Respects developers' preferences and existing environments. - Prevents unnecessary debugging and resource leaks. - Aligns with standard workflows while maintaining BINGO compatibility.
1 parent e5820ae commit 16923f6

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

.bingo/Variables.mk

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ BINGO_DIR := $(dir $(lastword $(MAKEFILE_LIST)))
44
GOPATH ?= $(shell go env GOPATH)
55
GOBIN ?= $(firstword $(subst :, ,${GOPATH}))/bin
66
GO ?= $(shell which go)
7+
LOCAL_KIND := $(shell command -v kind || echo "")
78

89
# Below generated variables ensure that every time a tool under each variable is invoked, the correct version
910
# will be used; reinstalling only if needed.
@@ -47,11 +48,18 @@ $(GORELEASER): $(BINGO_DIR)/goreleaser.mod
4748
@echo "(re)installing $(GOBIN)/goreleaser-v1.26.2"
4849
@cd $(BINGO_DIR) && GOWORK=off $(GO) build -mod=mod -modfile=goreleaser.mod -o=$(GOBIN)/goreleaser-v1.26.2 "github.com/goreleaser/goreleaser"
4950

50-
KIND := $(GOBIN)/kind-v0.24.0
51-
$(KIND): $(BINGO_DIR)/kind.mod
52-
@# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies.
53-
@echo "(re)installing $(GOBIN)/kind-v0.24.0"
54-
@cd $(BINGO_DIR) && GOWORK=off $(GO) build -mod=mod -modfile=kind.mod -o=$(GOBIN)/kind-v0.24.0 "sigs.k8s.io/kind"
51+
GLOBAL_KIND := $(shell command -v kind || echo "")
52+
# Use global kind if available; otherwise, fall back to BINGO-managed kind.
53+
KIND := $(if $(GLOBAL_KIND),$(GLOBAL_KIND),$(GOBIN)/kind-v0.24.0)
54+
55+
# Define the BINGO-managed kind target only if no global kind is found.
56+
$(GOBIN)/kind-v0.24.0: $(BINGO_DIR)/kind.mod
57+
@if [ -z "$(GLOBAL_KIND)" ]; then \
58+
echo "(re)installing $(GOBIN)/kind-v0.24.0 via BINGO..."; \
59+
cd $(BINGO_DIR) && GOWORK=off $(GO) build -mod=mod -modfile=kind.mod -o=$(GOBIN)/kind-v0.24.0 "sigs.k8s.io/kind"; \
60+
else \
61+
echo "Global kind found at $(GLOBAL_KIND). Skipping BINGO installation."; \
62+
fi
5563

5664
KUSTOMIZE := $(GOBIN)/kustomize-v4.5.7
5765
$(KUSTOMIZE): $(BINGO_DIR)/kustomize.mod

0 commit comments

Comments
 (0)