Skip to content

Commit

Permalink
Merge pull request #198 from wuxs/feat/issue-195
Browse files Browse the repository at this point in the history
feat: add "latest" version
  • Loading branch information
tkeel-bot[bot] authored May 12, 2022
2 parents cf576c7 + f9c7227 commit 43246ed
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions pkg/repository/helm/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ import (

var _getter getter.Getter

const LatestVersion = "latest"

func init() {
g, err := getter.NewHTTPGetter()
if err != nil {
Expand Down Expand Up @@ -111,12 +113,15 @@ func NewIndex(url, repoName string) (*Index, error) {
if len(ref) == 0 {
continue
}
versionMap, ok := index.charts[name]
if !ok {
versionMap = make(map[string]*repo.ChartVersion)
index.charts[name] = versionMap
}
if len(ref) > 0 {
versionMap[LatestVersion] = ref[0]
}
for _, rr := range ref {
versionMap, ok := index.charts[name]
if !ok {
versionMap = make(map[string]*repo.ChartVersion)
index.charts[name] = versionMap
}
versionMap[rr.Version] = rr
}
}
Expand Down Expand Up @@ -157,8 +162,8 @@ func (r *Index) Search(word string, version string) (PluginResList, error) {
if match != nil &&
match.Capture.Index == 0 &&
match.Capture.Length == len(chartName) {
for _, ch := range vMap {
if version == "" || version == ch.Version {
for v, ch := range vMap {
if version == "" && v != LatestVersion || version == v {
if _, ok := ch.Metadata.Annotations[tKeelPluginEnableKey]; ok {
res := PluginRes{
Name: ch.Name,
Expand Down

0 comments on commit 43246ed

Please sign in to comment.