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 <simon.meng@portainer.io>
pull/6007/head
Matt Hook 2021-10-29 11:46:55 +13:00 committed by GitHub
parent 71de07bbea
commit cec8f34ae9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 2 deletions

View File

@ -121,6 +121,8 @@ func (handler *Handler) settingsUpdate(w http.ResponseWriter, r *http.Request) *
} }
settings.HelmRepositoryURL = newHelmRepo settings.HelmRepositoryURL = newHelmRepo
} else {
settings.HelmRepositoryURL = ""
} }
if payload.BlackListedLabels != nil { if payload.BlackListedLabels != nil {

View File

@ -98,8 +98,9 @@ export default class HelmTemplatesController {
try { try {
// fetch globally set helm repo and user helm repos (parallel) // fetch globally set helm repo and user helm repos (parallel)
const { GlobalRepository, UserRepositories } = await this.HelmService.getHelmRepositories(this.endpoint.Id); const { GlobalRepository, UserRepositories } = await this.HelmService.getHelmRepositories(this.endpoint.Id);
this.state.globalRepository = GlobalRepository;
const userHelmReposUrls = UserRepositories.map((repo) => repo.URL); 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; this.state.repos = uniqueHelmRepos;
return uniqueHelmRepos; return uniqueHelmRepos;
} catch (err) { } catch (err) {
@ -169,6 +170,8 @@ export default class HelmTemplatesController {
chartsLoading: false, chartsLoading: false,
resourcePoolsLoading: false, resourcePoolsLoading: false,
viewReady: false, viewReady: false,
isAdmin: this.Authentication.isAdmin(),
globalRepository: undefined,
}; };
const helmRepos = await this.getHelmRepoURLs(); const helmRepos = await this.getHelmRepoURLs();

View File

@ -8,6 +8,11 @@
<i class="fa fa-exclamation-circle orange-icon" aria-hidden="true" style="margin-right: 2px;"></i> <i class="fa fa-exclamation-circle orange-icon" aria-hidden="true" style="margin-right: 2px;"></i>
This is a first version for Helm charts, for more information see this <a href="https://www.portainer.io/blog/portainer-now-with-helm-support" target="_blank">blog post</a>. This is a first version for Helm charts, for more information see this <a href="https://www.portainer.io/blog/portainer-now-with-helm-support" target="_blank">blog post</a>.
</p> </p>
<p ng-if="$ctrl.state.globalRepository === ''">
<i class="fa fa-exclamation-circle blue-icon" aria-hidden="true" style="margin-right: 2px;"></i>
<span>The Global Helm Repository is not configured.</span>
<a ng-if="$ctrl.state.isAdmin" ui-sref="portainer.settings">Configure Global Helm Repository in Settings</a>
</p>
</span> </span>
</information-panel> </information-panel>

View File

@ -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 * @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 * @throws {PortainerError} - Rejects with error if helm show fails
*/ */