Skip to content

Commit 1601809

Browse files
committed
[FIX] 提前过滤版本的执行顺序
1 parent baebcf0 commit 1601809

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

pkg/syncer/index.go

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,23 @@ func (s *Syncer) loadCharts(charts ...string) error {
102102
continue
103103
}
104104

105-
versions, err := s.cli.src.ListChartVersions(name)
105+
versionsTmp, err := s.cli.src.ListChartVersions(name)
106106
if err != nil {
107107
errs = multierror.Append(errs, errors.Trace(err))
108108
continue
109109
}
110110

111+
// 先过滤满足条件的版本
112+
var versions []string
113+
matchVersionRe := regexp.MustCompile(s.matchVersion)
114+
for _, v := range versionsTmp {
115+
if matchVersionRe.MatchString(v) {
116+
versions = append(versions, v)
117+
} else {
118+
klog.V(3).Infof("Skip the version %s that does not match", v)
119+
}
120+
}
121+
111122
klog.V(5).Infof("Found %d versions for %q chart: %v", len(versions), name, versions)
112123
klog.V(3).Infof("Indexing %q charts...", name)
113124
// TODO 在这里添加版本的正则过滤
@@ -129,17 +140,13 @@ func (s *Syncer) loadCharts(charts ...string) error {
129140
continue
130141
}
131142
} else {
132-
matchVersionRe := regexp.MustCompile(s.matchVersion)
133143
for _, version := range versions {
134-
if matchVersionRe.MatchString(version) {
135-
if err := s.processVersion(name, version, publishingThreshold); err != nil {
136-
klog.Warningf("Failed processing %s:%s chart. The index will remain incomplete.", name, version)
137-
errs = multierror.Append(errs, errors.Trace(err))
138-
continue
139-
}
140-
} else {
141-
klog.V(3).Infof("Skip the version %s that does not match", version)
144+
if err := s.processVersion(name, version, publishingThreshold); err != nil {
145+
klog.Warningf("Failed processing %s:%s chart. The index will remain incomplete.", name, version)
146+
errs = multierror.Append(errs, errors.Trace(err))
147+
continue
142148
}
149+
143150
}
144151
}
145152
}

0 commit comments

Comments
 (0)