Über Open CoDE Software Wiki Diskussionen GitLab

Skip to content

🌱 add version info to the binary via ldflags.

Kurt Garloff requested to merge tg/add-version-info-via-ldflags2 into main

Created by: guettli

What this PR does / why we need it:

Add version info to the binary via ldflags.

Fixes #21 (closed)

Special notes for your reviewer:

Please confirm that if this PR changes any image versions, then that's the sole change this PR makes.

TODOs:

  • squash commits
  • include documentation
  • add unit tests

Manually tested:

diff --git cmd/main.go cmd/main.go
index 211f7c53..7c5db420 100644
--- cmd/main.go
+++ cmd/main.go
@@ -55,6 +55,8 @@ func init() {
 }
 
 func main() {
+       fmt.Println(csoversion.Get().GitCommit)
+       os.Exit(1)
        var metricsAddr string
        var probeAddr string
        var enableLeaderElection bool

then:

❯ make manager-core ; bin/manager

go build -mod=vendor -trimpath -ldflags "-X 'github.com/SovereignCloudStack/cluster-stack-operator/pkg/csoversion.buildDate=2023-10-12T08:54:37Z' -X 'github.com/SovereignCloudStack/cluster-stack-operator/pkg/csoversion.gitCommit=11f31f5232f18fb1b33be139fcb112d4fa453989' -X 'github.com/SovereignCloudStack/cluster-stack-operator/pkg/csoversion.gitTreeState=dirty' -X 'github.com/SovereignCloudStack/cluster-stack-operator/pkg/csoversion.gitMajor=0' -X 'github.com/SovereignCloudStack/cluster-stack-operator/pkg/csoversion.gitMinor=1' -X 'github.com/SovereignCloudStack/cluster-stack-operator/pkg/csoversion.gitVersion=v0.1.0-alpha.1.6-11f31f5232f18f-dirty'" -o bin/manager cmd/main.go

11f31f5232f18fb1b33be139fcb112d4fa453989

Merge request reports

Loading