Skip to content

Commit

Permalink
mirror clone: Improve handling of latest versions
Browse files Browse the repository at this point in the history
1. If a version is specified and we fall back on the latest version
   then print a message about this.
2. Allow specifying "latest" as version to download the latest version
   of all components.
  • Loading branch information
dveeden committed Apr 15, 2021
1 parent 3a1296b commit b347b15
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/repository/clone_mirror.go
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,9 @@ func combineVersions(versions *[]string,
if latest == "" {
continue
}
if selectedVersion != "latest" {
fmt.Printf("%s %s/%s %s not found, using %s instead.\n", manifest.ID, os, arch, selectedVersion, latest)
}
selectedVersion = latest
}
if !result.Exist(selectedVersion) {
Expand Down
6 changes: 6 additions & 0 deletions pkg/utils/semver.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (

// NightlyVersionAlias represents latest build of master branch.
const NightlyVersionAlias = "nightly"
const LatestVersionAlias = "latest"

// FmtVer converts a version string to SemVer format, if the string is not a valid
// SemVer and fails to parse and convert it, an error is raised.
Expand All @@ -33,6 +34,11 @@ func FmtVer(ver string) (string, error) {
return v, nil
}

// latest version is an alias
if strings.ToLower(v) == LatestVersionAlias {
return v, nil
}

if !strings.HasPrefix(ver, "v") {
v = fmt.Sprintf("v%s", ver)
}
Expand Down

0 comments on commit b347b15

Please sign in to comment.