From 316273c74918b8232588379f5a219a599423b4a2 Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Tue, 23 Apr 2024 20:49:00 +0200 Subject: [PATCH] fix: fix filelist in template (#83) Reviewed-on: https://gitea.rknet.org/infra/crds-catalog/pulls/83 Co-authored-by: Robert Kaussow Co-committed-by: Robert Kaussow --- templates/all.json.tmpl | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/templates/all.json.tmpl b/templates/all.json.tmpl index 5829359..919273e 100644 --- a/templates/all.json.tmpl +++ b/templates/all.json.tmpl @@ -1,14 +1,17 @@ { "{{ ds "type" }}": [ {{- $path := ds "source" }} - {{- $filelist := file.ReadDir $path }} - {{- $length := len $filelist}} - {{- range $i, $item := $filelist }} + {{- $filelist := coll.Slice }} + {{- range $item := file.ReadDir $path }} + {{- if $item | strings.HasPrefix "all-" }}{{ continue }}{{ end }} + {{- $filelist = $filelist | coll.Append $item }} + {{- end }} + {{- $last := sub (len $filelist) 1 }} + {{- range $i, $item := $filelist | coll.Sort }} {{- if $item | strings.HasPrefix "all-" }}{{ continue }}{{ end }} - {{- if $i }},{{ end }} { "$ref": "https://gitea.rknet.org/infra/crds-catalog/raw/branch/catalog/{{ $path | path.Base }}/{{ $item }}" - } + }{{ if ne $i $last }},{{ end }} {{- end }} ] }