From 4457eec432958191baf2bccfef6c770e23c4f4cb Mon Sep 17 00:00:00 2001 From: lucklove Date: Tue, 14 Jul 2020 18:15:37 +0800 Subject: [PATCH] Clone with yanked version Signed-off-by: lucklove --- cmd/list.go | 3 +++ pkg/repository/clone_mirror.go | 13 +++++++++---- pkg/repository/v1_repository.go | 10 ++++++++-- pkg/repository/v1manifest/types.go | 8 ++++++-- 4 files changed, 26 insertions(+), 8 deletions(-) diff --git a/cmd/list.go b/cmd/list.go index 3934e2b6a7..f199d819d9 100644 --- a/cmd/list.go +++ b/cmd/list.go @@ -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 diff --git a/pkg/repository/clone_mirror.go b/pkg/repository/clone_mirror.go index 34c76e948b..0932603fe5 100644 --- a/pkg/repository/clone_mirror.go +++ b/pkg/repository/clone_mirror.go @@ -281,9 +281,6 @@ 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 { @@ -291,6 +288,11 @@ func cloneComponents(repo *V1Repository, 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) @@ -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 } diff --git a/pkg/repository/v1_repository.go b/pkg/repository/v1_repository.go index 3680df7924..4267d0dc15 100644 --- a/pkg/repository/v1_repository.go +++ b/pkg/repository/v1_repository.go @@ -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 } @@ -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) } @@ -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 } diff --git a/pkg/repository/v1manifest/types.go b/pkg/repository/v1manifest/types.go index 24c73b28db..4df9fc82eb 100644 --- a/pkg/repository/v1manifest/types.go +++ b/pkg/repository/v1manifest/types.go @@ -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 }