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

defaults: Move Version and HelmRepository from const to var #2441

Merged
merged 2 commits into from
Mar 22, 2024

Conversation

michi-covalent
Copy link
Contributor

Make Version and HelmRepository variables instead of consts so that they can be overridden using build tags or go build -X ldflag.

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 <michi@isovalent.com>
- 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 <michi@isovalent.com>
@michi-covalent
Copy link
Contributor Author

added another commit to improve makefile. manually tested the cli version is working ✅

% make
CGO_ENABLED=0 go build  \
		-ldflags "-w -s -X 'github.com/cilium/cilium-cli/defaults.CLIVersion=v0.16.3-5-g3bb2e218'" \
		-o cilium \
		./cmd/cilium
% ./cilium version
cilium-cli: v0.16.3-5-g3bb2e218 compiled with go1.22.1 on darwin/arm64

with local-release:

% make local-release
...
			env GOOS=$OS GOARCH=$ARCH CGO_ENABLED=0 go build  \
				-ldflags "-w -s -X 'github.com/cilium/cilium-cli/defaults.CLIVersion=v0.16.3-5-g3bb2e218'" \
				-o release/$OS/$ARCH/cilium$EXT ./cmd/cilium; \
...
% cd release
% tar xf cilium-darwin-arm64.tar.gz
% ./cilium version
cilium-cli: v0.16.3-5-g3bb2e218 compiled with go1.22.1 on darwin/arm64

@maintainer-s-little-helper maintainer-s-little-helper bot added the ready-to-merge This PR has passed all tests and received consensus from code owners to merge. label Mar 22, 2024
@tklauser tklauser merged commit 039bec3 into main Mar 22, 2024
13 checks passed
@tklauser tklauser deleted the pr/michi/var-please branch March 22, 2024 14:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-to-merge This PR has passed all tests and received consensus from code owners to merge.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants