From 2c2ee74403c50a0dcdb069eda721d1e3ec4376fe Mon Sep 17 00:00:00 2001 From: Michi Mutsuzaki Date: Thu, 21 Mar 2024 02:25:59 +0000 Subject: [PATCH 1/2] defaults: Move Version and HelmRepository from const to var Make Version and HelmRepository variables instead of consts so that they can be overridden using build tags or go build -X ldflag. Signed-off-by: Michi Mutsuzaki --- defaults/defaults.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/defaults/defaults.go b/defaults/defaults.go index a5da90a7bb..a7850f6b12 100644 --- a/defaults/defaults.go +++ b/defaults/defaults.go @@ -8,9 +8,6 @@ import ( ) const ( - // renovate: datasource=github-releases depName=cilium/cilium - Version = "v1.15.2" - CiliumPodSelector = "app.kubernetes.io/part-of=cilium" AgentContainerName = "cilium-agent" @@ -99,9 +96,6 @@ const ( CiliumNoScheduleLabel = "cilium.io/no-schedule" - // HelmRepository specifies Helm repository to download Cilium charts from. - HelmRepository = "https://helm.cilium.io" - // ClustermeshMaxConnectedClusters is the default number of the maximum // number of clusters that should be allowed to connect to the Clustermesh. ClustermeshMaxConnectedClusters = 255 @@ -111,6 +105,12 @@ const ( ) var ( + // renovate: datasource=github-releases depName=cilium/cilium + Version = "v1.15.2" + + // HelmRepository specifies Helm repository to download Cilium charts from. + HelmRepository = "https://helm.cilium.io" + // CiliumScheduleAffinity is the node affinity to prevent Cilium from being schedule on // nodes labeled with CiliumNoScheduleLabel. CiliumScheduleAffinity = []string{ From 3bb2e218161e3353bff9fa55a958902881943331 Mon Sep 17 00:00:00 2001 From: Michi Mutsuzaki Date: Wed, 20 Mar 2024 23:05:18 +0000 Subject: [PATCH 2/2] Improve Makefile - Include Makefile.override if the file exists to allow overriding Make variables without modifying Makefile. Copied from cilium/cilium#26159. - Define GO_BUILD_LDFLAGS to use with default and local-release targets so that these targets consistently use the same ldflags without having to update multiple places. It also makes it easier to override ldflags with Makefile.override. Signed-off-by: Michi Mutsuzaki --- Makefile | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index b2f1868cff..3a7d99113c 100644 --- a/Makefile +++ b/Makefile @@ -12,6 +12,7 @@ STRIP_DEBUG=-w -s ifdef DEBUG STRIP_DEBUG= endif +GO_BUILD_LDFLAGS ?= $(STRIP_DEBUG) -X 'github.com/cilium/cilium-cli/defaults.CLIVersion=$(VERSION)' TEST_TIMEOUT ?= 5s RELEASE_UID ?= $(shell id -u) @@ -28,8 +29,7 @@ GOLANGCILINT_VERSION = $(shell golangci-lint version --format short 2>/dev/null) $(TARGET): $(GO_BUILD) $(if $(GO_TAGS),-tags $(GO_TAGS)) \ - -ldflags "$(STRIP_DEBUG) \ - -X 'github.com/cilium/cilium-cli/defaults.CLIVersion=${VERSION}'" \ + -ldflags "$(GO_BUILD_LDFLAGS)" \ -o $(TARGET) \ ./cmd/cilium @@ -62,7 +62,7 @@ local-release: clean echo Building release binary for $$OS/$$ARCH...; \ test -d release/$$OS/$$ARCH|| mkdir -p release/$$OS/$$ARCH; \ env GOOS=$$OS GOARCH=$$ARCH $(GO_BUILD) $(if $(GO_TAGS),-tags $(GO_TAGS)) \ - -ldflags "-w -s -X 'github.com/cilium/cilium-cli/defaults.CLIVersion=${VERSION}'" \ + -ldflags "$(GO_BUILD_LDFLAGS)" \ -o release/$$OS/$$ARCH/$(TARGET)$$EXT ./cmd/cilium; \ tar -czf release/$(TARGET)-$$OS-$$ARCH.tar.gz -C release/$$OS/$$ARCH $(TARGET)$$EXT; \ (cd release && sha256sum $(TARGET)-$$OS-$$ARCH.tar.gz > $(TARGET)-$$OS-$$ARCH.tar.gz.sha256sum); \ @@ -100,3 +100,5 @@ check: endif .PHONY: $(TARGET) release local-release install clean test bench check clean-tags tags + +-include Makefile.override