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

cmd/skipper: fix version and commit for go install #2954

Merged
merged 1 commit into from
Feb 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 16 additions & 0 deletions cmd/skipper/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package main
import (
"fmt"
"runtime"
"runtime/debug"

log "github.com/sirupsen/logrus"
"github.com/zalando/skipper"
Expand All @@ -28,6 +29,21 @@ var (
commit string
)

func init() {
if info, ok := debug.ReadBuildInfo(); ok {
if version == "" {
version = info.Main.Version
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

go install should populate this from the package version that matches git tag.

}
if commit == "" {
for _, setting := range info.Settings {
if setting.Key == "vcs.revision" {
commit = setting.Value[:min(8, len(setting.Value))]
}
}
}
}
}

func main() {
cfg := config.NewConfig()
if err := cfg.Parse(); err != nil {
Expand Down