@@ -102,12 +102,23 @@ func (s *Syncer) loadCharts(charts ...string) error {
102
102
continue
103
103
}
104
104
105
- versions , err := s .cli .src .ListChartVersions (name )
105
+ versionsTmp , err := s .cli .src .ListChartVersions (name )
106
106
if err != nil {
107
107
errs = multierror .Append (errs , errors .Trace (err ))
108
108
continue
109
109
}
110
110
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
+
111
122
klog .V (5 ).Infof ("Found %d versions for %q chart: %v" , len (versions ), name , versions )
112
123
klog .V (3 ).Infof ("Indexing %q charts..." , name )
113
124
// TODO 在这里添加版本的正则过滤
@@ -129,17 +140,13 @@ func (s *Syncer) loadCharts(charts ...string) error {
129
140
continue
130
141
}
131
142
} else {
132
- matchVersionRe := regexp .MustCompile (s .matchVersion )
133
143
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
142
148
}
149
+
143
150
}
144
151
}
145
152
}
0 commit comments