From 58317edb6dad965bcd5cc3e4952a73f29d310757 Mon Sep 17 00:00:00 2001 From: Ali <83188384+testA113@users.noreply.github.com> Date: Fri, 14 Mar 2025 07:57:06 +1300 Subject: [PATCH] fix(namespaces): only show namespaces with access [r8s-251] (#501) --- app/kubernetes/services/resourcePoolService.js | 13 ++++++++++--- app/kubernetes/views/deploy/deployController.js | 6 +++--- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/app/kubernetes/services/resourcePoolService.js b/app/kubernetes/services/resourcePoolService.js index 639c44db1..d829afa0b 100644 --- a/app/kubernetes/services/resourcePoolService.js +++ b/app/kubernetes/services/resourcePoolService.js @@ -3,6 +3,7 @@ import _ from 'lodash-es'; import angular from 'angular'; import KubernetesResourcePoolConverter from 'Kubernetes/converters/resourcePool'; import KubernetesResourceQuotaHelper from 'Kubernetes/helpers/resourceQuotaHelper'; +import { getNamespaces } from '@/react/kubernetes/namespaces/queries/useNamespacesQuery'; /* @ngInject */ export function KubernetesResourcePoolService( @@ -11,7 +12,8 @@ export function KubernetesResourcePoolService( KubernetesNamespaceService, KubernetesResourceQuotaService, KubernetesIngressService, - KubernetesPortainerNamespaces + KubernetesPortainerNamespaces, + EndpointProvider ) { return { get, @@ -37,9 +39,14 @@ export function KubernetesResourcePoolService( // getting the quota for all namespaces is costly by default, so disable getting it by default async function getAll({ getQuota = false }) { - const namespaces = await KubernetesNamespaceService.get(); + const namespaces = await getNamespaces(EndpointProvider.endpointID()); + // there is a lot of downstream logic using the angular namespace type with a '.Status' field (not '.Status.phase'), so format the status here to match this logic + const namespacesFormattedStatus = namespaces.map((namespace) => ({ + ...namespace, + Status: namespace.Status.phase, + })); const pools = await Promise.all( - _.map(namespaces, async (namespace) => { + _.map(namespacesFormattedStatus, async (namespace) => { const name = namespace.Name; const pool = KubernetesResourcePoolConverter.apiToResourcePool(namespace); if (getQuota) { diff --git a/app/kubernetes/views/deploy/deployController.js b/app/kubernetes/views/deploy/deployController.js index 50c923d58..79549084a 100644 --- a/app/kubernetes/views/deploy/deployController.js +++ b/app/kubernetes/views/deploy/deployController.js @@ -6,13 +6,13 @@ import PortainerError from '@/portainer/error'; import { KubernetesDeployManifestTypes, KubernetesDeployBuildMethods, KubernetesDeployRequestMethods, RepositoryMechanismTypes } from 'Kubernetes/models/deploy'; import { isTemplateVariablesEnabled, renderTemplate } from '@/react/portainer/custom-templates/components/utils'; import { getDeploymentOptions } from '@/react/portainer/environments/environment.service'; -import { kubernetes } from '@@/BoxSelector/common-options/deployment-methods'; -import { editor, git, customTemplate, url, helm } from '@@/BoxSelector/common-options/build-methods'; import { parseAutoUpdateResponse, transformAutoUpdateViewModel } from '@/react/portainer/gitops/AutoUpdateFieldset/utils'; import { baseStackWebhookUrl, createWebhookId } from '@/portainer/helpers/webhookHelper'; -import { confirmWebEditorDiscard } from '@@/modals/confirm'; import { getVariablesFieldDefaultValues } from '@/react/portainer/custom-templates/components/CustomTemplatesVariablesField'; import { KUBE_STACK_NAME_VALIDATION_REGEX } from '@/react/kubernetes/DeployView/StackName/constants'; +import { confirmWebEditorDiscard } from '@@/modals/confirm'; +import { editor, git, customTemplate, url, helm } from '@@/BoxSelector/common-options/build-methods'; +import { kubernetes } from '@@/BoxSelector/common-options/deployment-methods'; class KubernetesDeployController { /* @ngInject */