Added ability to disable query to ArtifactHub via env (#515)

It is now possible to disable the query through environment variable HD_NO_ARTIFACT_HUB_QUERY
This commit is contained in:
Alessandro Detta
2024-02-23 21:37:43 +01:00
committed by GitHub
parent b5bed10571
commit 274f1cd6cc

View File

@@ -241,6 +241,11 @@ func (h *HelmHandler) RepoLatestVer(c *gin.Context) {
if len(res) > 0 { if len(res) > 0 {
c.IndentedJSON(http.StatusOK, res[:1]) c.IndentedJSON(http.StatusOK, res[:1])
} else { } else {
if utils.EnvAsBool("HD_NO_ARTIFACT_HUB_QUERY", false) {
c.Status(http.StatusNoContent)
return
}
// caching it to avoid too many requests // caching it to avoid too many requests
found, err := h.Data.Cache.String("chart-artifacthub-query/"+qp.Name, nil, func() (string, error) { found, err := h.Data.Cache.String("chart-artifacthub-query/"+qp.Name, nil, func() (string, error) {
return h.repoFromArtifactHub(qp.Name) return h.repoFromArtifactHub(qp.Name)