|
3 | 3 |
|
4 | 4 | {{ $files := readDir $currentDir }} |
5 | 5 |
|
| 6 | +<!-- Fetch latest version per function using git matching-refs API (one call per function) --> |
| 7 | +{{ $latestVersions := dict }} |
| 8 | +{{ $releaseTags := dict }} |
| 9 | +{{ $token := getenv "KRM_CATALOG_API_TOKEN" }} |
| 10 | +{{ range $files }} |
| 11 | + {{ if .IsDir }} |
| 12 | + {{ if ne .Name "examples" }} |
| 13 | + {{ $fnName := .Name }} |
| 14 | + {{ $apiURL := printf "https://api.github.com/repos/kptdev/krm-functions-catalog/git/matching-refs/tags/functions/go/%s/v" $fnName }} |
| 15 | + {{ $opts := cond (ne $token "") (dict "headers" (dict "Authorization" (printf "token %s" $token))) (dict) }} |
| 16 | + {{ with resources.GetRemote $apiURL $opts }} |
| 17 | + {{ $refs := . | transform.Unmarshal }} |
| 18 | + {{ if gt (len $refs) 0 }} |
| 19 | + {{ $bestRef := "" }} |
| 20 | + {{ $bestMajor := 0 }} |
| 21 | + {{ $bestMinor := 0 }} |
| 22 | + {{ $bestPatch := 0 }} |
| 23 | + {{ range $refs }} |
| 24 | + {{ $v := .ref | replaceRE "^.*/v" "" }} |
| 25 | + {{ $parts := split $v "." }} |
| 26 | + {{ if ge (len $parts) 3 }} |
| 27 | + {{ $maj := index $parts 0 | int }} |
| 28 | + {{ $min := index $parts 1 | int }} |
| 29 | + {{ $pat := index $parts 2 | int }} |
| 30 | + {{ if or (gt $maj $bestMajor) (and (eq $maj $bestMajor) (gt $min $bestMinor)) (and (eq $maj $bestMajor) (eq $min $bestMinor) (gt $pat $bestPatch)) }} |
| 31 | + {{ $bestRef = .ref }} |
| 32 | + {{ $bestMajor = $maj }} |
| 33 | + {{ $bestMinor = $min }} |
| 34 | + {{ $bestPatch = $pat }} |
| 35 | + {{ end }} |
| 36 | + {{ end }} |
| 37 | + {{ end }} |
| 38 | + {{ if $bestRef }} |
| 39 | + {{ $tag := $bestRef | replaceRE "^refs/tags/" "" }} |
| 40 | + {{ $version := $tag | replaceRE "^.*/v" "v" }} |
| 41 | + {{ $latestVersions = merge $latestVersions (dict $fnName $version) }} |
| 42 | + {{ $releaseTags = merge $releaseTags (dict $fnName $tag) }} |
| 43 | + {{ end }} |
| 44 | + {{ end }} |
| 45 | + {{ end }} |
| 46 | + {{ end }} |
| 47 | + {{ end }} |
| 48 | +{{ end }} |
| 49 | + |
6 | 50 | <table class="table table-striped"> |
7 | 51 | <thead> |
8 | 52 | <tr> |
9 | 53 | <th>Function</th> |
| 54 | + <th>Latest Version</th> |
10 | 55 | <th>Description</th> |
11 | 56 | <th>Tags</th> |
12 | 57 | </tr> |
|
65 | 110 | <a href="{{ printf "%s/%s/" $functionName $highestVersion }}">{{ .Title }}</a> |
66 | 111 | {{ end }} |
67 | 112 | </td> |
| 113 | + <td> |
| 114 | + {{ $ver := index $latestVersions $functionName }} |
| 115 | + {{ $tag := index $releaseTags $functionName }} |
| 116 | + {{ if $ver }} |
| 117 | + <a href="https://github.com/kptdev/krm-functions-catalog/releases/tag/{{ $tag }}">{{ $ver }}</a> |
| 118 | + {{ else }}—{{ end }} |
| 119 | + </td> |
68 | 120 | <td>{{ .Params.description | markdownify }}</td> |
69 | 121 | <td> |
70 | 122 | {{ if .Params.tags }} |
|
79 | 131 | {{ $title := .Name | replaceRE "\\.[^.]+$" "" }} |
80 | 132 | <tr> |
81 | 133 | <td><a href="{{ printf "%s" .Name }}">{{ $title }}</a></td> |
| 134 | + <td> |
| 135 | + {{ $ver := index $latestVersions .Name }} |
| 136 | + {{ $tag := index $releaseTags .Name }} |
| 137 | + {{ if $ver }} |
| 138 | + <a href="https://github.com/kptdev/krm-functions-catalog/releases/tag/{{ $tag }}">{{ $ver }}</a> |
| 139 | + {{ else }}—{{ end }} |
| 140 | + </td> |
82 | 141 | <td>No description available</td> |
83 | 142 | <td></td> |
84 | 143 | </tr> |
|
0 commit comments