Skip to content

Commit 79be52b

Browse files
committed
chore: add index yaml fake
1 parent 1fe5ee5 commit 79be52b

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

main.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,27 @@ func main() {
221221
}
222222

223223
router := defaultRouter(nil)
224+
225+
router.Get("/index.yaml", func(w http.ResponseWriter, r *http.Request) {
226+
w.Header().Set("Content-Type", "text/plain; charset=utf-8")
227+
w.WriteHeader(http.StatusOK)
228+
fmt.Fprintln(w, "apiVersion: v2")
229+
fmt.Fprintln(w, "entries:")
230+
for _, asset := range RepositoryDB.Assets {
231+
if len(asset.Tags) > 0 {
232+
fmt.Fprintf(w, " %s:\n", asset.Name)
233+
fmt.Fprintf(w, " - created: %s\n", time.Now().Format(time.RFC3339))
234+
fmt.Fprintf(w, " description: A Helm chart for Kubernetes\n")
235+
fmt.Fprintf(w, " digest: %s\n", strings.Split(asset.SHA, ":")[1])
236+
fmt.Fprintf(w, " name: %s\n", asset.Name)
237+
fmt.Fprintf(w, " type: application\n")
238+
fmt.Fprintf(w, " urls:\n")
239+
fmt.Fprintf(w, " - %s\n", asset.URI)
240+
fmt.Fprintf(w, " version: %s\n", *asset.Tags[0])
241+
}
242+
}
243+
})
244+
224245
router.Get("/{assetName}@{assetSHA}", func(w http.ResponseWriter, r *http.Request) {
225246
var assetName = chi.URLParam(r, "assetName")
226247
var assetSHA = chi.URLParam(r, "assetSHA")

0 commit comments

Comments
 (0)