-
Notifications
You must be signed in to change notification settings - Fork 82
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,7 @@ import ( | |
"fmt" | ||
|
||
"github.com/kro-run/kro/api/v1alpha1" | ||
"github.com/kro-run/kro/pkg" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
|
@@ -29,9 +30,8 @@ const ( | |
const ( | ||
NodeIDLabel = LabelKroPrefix + "node-id" | ||
|
||
OwnedLabel = LabelKroPrefix + "owned" | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more. I'm being a super pedant here but:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This applies elsewhere in this file too. |
||
|
||
InstanceIDLabel = LabelKroPrefix + "instance-id" | ||
InstanceLabel = LabelKroPrefix + "instance-name" | ||
|
@@ -115,8 +115,8 @@ func (gl GenericLabeler) Copy() map[string]string { | |
// ResourceGraphDefinitionLabel and ResourceGraphDefinitionIDLabel labels on a resource. | ||
func NewResourceGraphDefinitionLabeler(rgMeta metav1.Object) GenericLabeler { | ||
return map[string]string{ | ||
ResourceGraphDefinitionIDLabel: string(rgMeta.GetUID()), | ||
ResourceGraphDefinitionNameLabel: rgMeta.GetName(), | ||
ResourceGraphDefinitionIDLabel: string(rgMeta.GetUID()), | ||
ResourceGraphDefinitionNameLabel: rgMeta.GetName(), | ||
} | ||
} | ||
|
||
|
@@ -133,14 +133,10 @@ func NewInstanceLabeler(instanceMeta metav1.Object) GenericLabeler { | |
|
||
// NewKroMetaLabeler returns a new labeler that sets the OwnedLabel, | ||
// KroVersion, and ControllerPodID labels on a resource. | ||
func NewKroMetaLabeler( | ||
kroVersion string, | ||
controllerPodID string, | ||
) GenericLabeler { | ||
func NewKroMetaLabeler() GenericLabeler { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? 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? |
||
return map[string]string{ | ||
OwnedLabel: "true", | ||
KroVersionLabel: kroVersion, | ||
ControllerPodIDLabel: controllerPodID, | ||
OwnedLabel: "true", | ||
KroVersionLabel: pkg.Version, | ||
} | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Copyright 2025 The Kube Resource Orchestrator Authors. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"). You may | ||
// not use this file except in compliance with the License. A copy of the | ||
// License is located at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// or in the "license" file accompanying this file. This file is distributed | ||
// on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
// express or implied. See the License for the specific language governing | ||
// permissions and limitations under the License. | ||
|
||
package pkg | ||
|
||
// These variables are populated by the go compiler using -ldflags | ||
var ( | ||
// Version is the version of the kro binary. | ||
Version string // -X github.com/your/repo/pkg.Version=$(VERSION) | ||
// GitCommit is the git commit that was compiled. | ||
GitCommit string // -X github.com/your/repo/pkg.GitCommit=$(GIT_COMMIT) | ||
// BuildDate is the date that the kro binary was built. | ||
BuildDate string // -X github.com/your/repo/pkg.BuildDate=$(BUILD_DATE) | ||
) |
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?