-
Notifications
You must be signed in to change notification settings - Fork 83
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
feat: add go ldflags for version info injection #313
base: main
Are you sure you want to change the base?
Conversation
This label is not really useful since pod IDs change in HA setups, making the label meaningless.
Add support for injecting version information at build time via ldflags. This includes: - Version, git commit hash, and build date injection in `.ko.yaml` - Updated metadata labeler to use dynamic version - Makefile updates to support version info injection
$(KO) build --bare github.com/kro-run/kro/cmd/controller \ | ||
--local\ | ||
--push=false --tags ${RELEASE_VERSION} --sbom=none | ||
|
||
.PHONY: publish | ||
publish-image: ko ## Publish the kro controller images to ghcr.io | ||
$(WITH_GOFLAGS) KOCACHE=$(KOCACHE) \ | ||
$(WITH_GOFLAGS) KOCACHE=$(KOCACHE) KO_DOCKER_REPO=$(KO_DOCKER_REPO) \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the fact the KO_DOCKER_REPO
wasn't here before a bug?
KroVersionLabel = LabelKroPrefix + "kro-version" | ||
ControllerPodIDLabel = LabelKroPrefix + "controller-pod-id" | ||
OwnedLabel = LabelKroPrefix + "owned" | ||
KroVersionLabel = LabelKroPrefix + "kro-version" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm being a super pedant here but:
https://google.github.io/styleguide/go/decisions#initialisms
KRO
vs Kro
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This applies elsewhere in this file too.
kroVersion string, | ||
controllerPodID string, | ||
) GenericLabeler { | ||
func NewKroMetaLabeler() GenericLabeler { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the experience when running tests locally (in a KIND cluster, for example).
Are the labels set correctly? I looked at the makefile and I think they will be?
What about in envtest (less sure they will be there)?
Does it make sense to have this still be settable on the labeller and then have the envtest context specifically pass "something"? Or maybe we need envtest contexts to just set pkg.Version/etc correctly?
Add support for injecting version information at build time via ldflags. This includes:
.ko.yaml