Skip to content

Commit

Permalink
Clone with yanked version
Browse files Browse the repository at this point in the history
Signed-off-by: lucklove <gnu.crazier@gmail.com>
  • Loading branch information
lucklove committed Jul 14, 2020
1 parent c147d3e commit 4457eec
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 8 deletions.
3 changes: 3 additions & 0 deletions cmd/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,9 @@ func showComponentVersions(env *environment.Environment, component string, opt l

for plat, versions := range comp.Platforms {
for ver, verinfo := range versions {
if verinfo.Yanked {
continue
}
if v0manifest.Version(ver).IsNightly() && ver == comp.Nightly {
platforms[version.NightlyVersion] = append(platforms[version.NightlyVersion], plat)
released[version.NightlyVersion] = verinfo.Released
Expand Down
13 changes: 9 additions & 4 deletions pkg/repository/clone_mirror.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,16 +281,18 @@ func cloneComponents(repo *V1Repository,
fmt.Printf("The component '%s' donesn't have %s/%s, skipped\n", name, goos, goarch)
}
for v, versionItem := range versions {
if !checkVersion(options, vs, v) {
continue
}
if !options.Full {
newVersions, found := newManifest.Platforms[platform]
if !found {
newVersions = map[string]v1manifest.VersionItem{}
newManifest.Platforms[platform] = newVersions
}
newVersions[v] = versionItem
if !checkVersion(options, vs, v) {
versionItem.Yanked = true
newVersions[v] = versionItem
continue
}
}
if err := download(targetDir, tmpDir, repo, &versionItem); err != nil {
return nil, errors.Annotatef(err, "download resource: %s", name)
Expand Down Expand Up @@ -424,7 +426,10 @@ func combineVersions(versions *[]string, manifest *v1manifest.Component, oss, ar
if !found && !coreSuites.Exist(manifest.ID) {
// Use the latest stable versionS if the selected version doesn't exist in specific platform
var latest string
for v := range versions {
for v, vi := range versions {
if vi.Yanked {
continue
}
if v0manifest.Version(v).IsNightly() {
continue
}
Expand Down
10 changes: 8 additions & 2 deletions pkg/repository/v1_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,9 @@ func (r *V1Repository) selectVersion(id string, versions map[string]v1manifest.V
var latest string
var latestItem v1manifest.VersionItem
for version, item := range versions {
if item.Yanked {
continue
}
if v0manifest.Version(version).IsNightly() {
continue
}
Expand All @@ -230,7 +233,7 @@ func (r *V1Repository) selectVersion(id string, versions map[string]v1manifest.V
}

item, ok := versions[target]
if !ok {
if !ok || item.Yanked {
// TODO we should return a semver-compatible version if one exists.
return "", nil, fmt.Errorf("version %s not supported by component %s", target, id)
}
Expand Down Expand Up @@ -692,7 +695,10 @@ func (r *V1Repository) LatestStableVersion(id string) (v0manifest.Version, *v1ma
}

var last string
for v := range versions {
for v, vi := range versions {
if vi.Yanked {
continue
}
if v0manifest.Version(v).IsNightly() {
continue
}
Expand Down
8 changes: 6 additions & 2 deletions pkg/repository/v1manifest/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,10 @@ func (manifest *Component) HasNightly(platform string) bool {
return false
}

_, ok := manifest.Platforms[platform][manifest.Nightly]
return ok
v, ok := manifest.Platforms[platform][manifest.Nightly]
if !ok {
return false
}

return !v.Yanked
}

0 comments on commit 4457eec

Please sign in to comment.