Skip to content

Commit

Permalink
Add commit version into the file
Browse files Browse the repository at this point in the history
  • Loading branch information
Victor Morales committed Jan 23, 2025
1 parent 18208ce commit 5adf666
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions cmd/kar/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,45 @@ import (
"log"
"os"
"os/signal"
"runtime/debug"

"github.com/electrocucaracha/kubevirt-actions-runner/cmd/kar/app"
runner "github.com/electrocucaracha/kubevirt-actions-runner/internal"
"github.com/pkg/errors"
)

type buildInfo struct {
gitCommit string
gitTreeModified string
buildDate string
goVersion string
}

func getBuildInfo() buildInfo {
b := buildInfo{}
if info, ok := debug.ReadBuildInfo(); ok {
b.goVersion = info.GoVersion
for _, kv := range info.Settings {
switch kv.Key {
case "vcs.revision":
b.gitCommit = kv.Value
case "vcs.time":
b.buildDate = kv.Value
case "vcs.modified":
b.gitTreeModified = kv.Value
}
}
}

return b
}

func main() {
var opts app.Opts

b := getBuildInfo()
log.Printf("starting kubevirt action runner\ncommit: %v\tmodified:%v\n", b.gitCommit, b.gitTreeModified)

runner := runner.NewRunner()

ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt)
Expand Down

0 comments on commit 5adf666

Please sign in to comment.