From cec8f34ae9c9ed2b79a836eed1c89124e86fd50f Mon Sep 17 00:00:00 2001 From: Matt Hook Date: Fri, 29 Oct 2021 11:46:55 +1300 Subject: [PATCH] fix(helm): allow clearing global helm repo EE-1965 (#5991) * fix(helm): allow clearing global helm repo EE-1965 * fix(helm): show hint if global helm repo is blank EE-1965 * fix(helm): skip loading charts if repo is blank EE-1965 Co-authored-by: Simon Meng --- api/http/handler/settings/settings_update.go | 2 ++ .../helm/helm-templates/helm-templates.controller.js | 5 ++++- .../components/helm/helm-templates/helm-templates.html | 5 +++++ app/kubernetes/helm/service.js | 2 +- 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/api/http/handler/settings/settings_update.go b/api/http/handler/settings/settings_update.go index 0a64e7d33..1e52fccfb 100644 --- a/api/http/handler/settings/settings_update.go +++ b/api/http/handler/settings/settings_update.go @@ -121,6 +121,8 @@ func (handler *Handler) settingsUpdate(w http.ResponseWriter, r *http.Request) * } settings.HelmRepositoryURL = newHelmRepo + } else { + settings.HelmRepositoryURL = "" } if payload.BlackListedLabels != nil { diff --git a/app/kubernetes/components/helm/helm-templates/helm-templates.controller.js b/app/kubernetes/components/helm/helm-templates/helm-templates.controller.js index bbd1c6504..abfed0c44 100644 --- a/app/kubernetes/components/helm/helm-templates/helm-templates.controller.js +++ b/app/kubernetes/components/helm/helm-templates/helm-templates.controller.js @@ -98,8 +98,9 @@ export default class HelmTemplatesController { try { // fetch globally set helm repo and user helm repos (parallel) const { GlobalRepository, UserRepositories } = await this.HelmService.getHelmRepositories(this.endpoint.Id); + this.state.globalRepository = GlobalRepository; const userHelmReposUrls = UserRepositories.map((repo) => repo.URL); - const uniqueHelmRepos = [...new Set([GlobalRepository, ...userHelmReposUrls])].map((url) => url.toLowerCase()); // remove duplicates, to lowercase + const uniqueHelmRepos = [...new Set([GlobalRepository, ...userHelmReposUrls])].map((url) => url.toLowerCase()).filter((url) => url); // remove duplicates and blank, to lowercase this.state.repos = uniqueHelmRepos; return uniqueHelmRepos; } catch (err) { @@ -169,6 +170,8 @@ export default class HelmTemplatesController { chartsLoading: false, resourcePoolsLoading: false, viewReady: false, + isAdmin: this.Authentication.isAdmin(), + globalRepository: undefined, }; const helmRepos = await this.getHelmRepoURLs(); diff --git a/app/kubernetes/components/helm/helm-templates/helm-templates.html b/app/kubernetes/components/helm/helm-templates/helm-templates.html index 360d3ec05..8d1c9ad0d 100644 --- a/app/kubernetes/components/helm/helm-templates/helm-templates.html +++ b/app/kubernetes/components/helm/helm-templates/helm-templates.html @@ -8,6 +8,11 @@ This is a first version for Helm charts, for more information see this blog post.

+

+ + The Global Helm Repository is not configured. + Configure Global Helm Repository in Settings +

diff --git a/app/kubernetes/helm/service.js b/app/kubernetes/helm/service.js index c8f993d4f..2d9b31379 100644 --- a/app/kubernetes/helm/service.js +++ b/app/kubernetes/helm/service.js @@ -45,7 +45,7 @@ export function HelmService(HelmFactory) { } /** - * @description: Show values helm of a helm chart, this basically runs `helm show values` + * @description: Get a list of all the helm repositories available for the current user * @returns {Promise} - Resolves with an object containing list of user helm repos and default/global settings helm repo * @throws {PortainerError} - Rejects with error if helm show fails */