Skip to content

Commit

Permalink
version: fix parsing user-agent version
Browse files Browse the repository at this point in the history
Signed-off-by: Tonis Tiigi <[email protected]>
(cherry picked from commit 5fa4359)
Signed-off-by: Tonis Tiigi <[email protected]>
  • Loading branch information
tonistiigi committed Apr 6, 2022
1 parent beaba19 commit 91dcf6e
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,18 @@ var (
)

func UserAgent() string {
version := defaultVersion
uaVersion := defaultVersion

reOnce.Do(func() {
reRelease = regexp.MustCompile(`^(v[0-9]+\.[0-9]+)\.[0-9]+$`)
reDev = regexp.MustCompile(`^(v[0-9]+\.[0-9]+)\.[0-9]+`)
})

if matches := reRelease.FindAllStringSubmatch(version, 1); len(matches) > 0 {
version = matches[0][1]
} else if matches := reDev.FindAllStringSubmatch(version, 1); len(matches) > 0 {
version = matches[0][1] + "-dev"
if matches := reRelease.FindAllStringSubmatch(Version, 1); len(matches) > 0 {
uaVersion = matches[0][1]
} else if matches := reDev.FindAllStringSubmatch(Version, 1); len(matches) > 0 {
uaVersion = matches[0][1] + "-dev"
}

return "buildkit/" + version
return "buildkit/" + uaVersion
}

0 comments on commit 91dcf6e

Please sign in to comment.