mirror of https://github.com/portainer/portainer
refactor(k8s): remove repeats
parent
2d85961695
commit
f4b795bbbb
|
@ -63,11 +63,7 @@ func (kcl *KubeClient) fetchNamespacesForNonAdmin() (map[string]portainer.K8sNam
|
|||
return nil, fmt.Errorf("an error occurred during the fetchNamespacesForNonAdmin operation, unable to list namespaces for the non-admin user: %w", err)
|
||||
}
|
||||
|
||||
nonAdminNamespaceSet := make(map[string]struct{}, len(kcl.NonAdminNamespaces))
|
||||
for _, ns := range kcl.NonAdminNamespaces {
|
||||
nonAdminNamespaceSet[ns] = struct{}{}
|
||||
}
|
||||
|
||||
nonAdminNamespaceSet := kcl.BuildNonAdminNamespacesMap()
|
||||
results := make(map[string]portainer.K8sNamespaceInfo)
|
||||
for _, namespace := range namespaces {
|
||||
if _, exists := nonAdminNamespaceSet[namespace.Name]; exists {
|
||||
|
@ -286,3 +282,12 @@ func (kcl *KubeClient) CombineNamespaceWithResourceQuota(namespace portaineree.K
|
|||
|
||||
return response.JSON(w, namespace)
|
||||
}
|
||||
|
||||
func (kcl *KubeClient) BuildNonAdminNamespacesMap() map[string]struct{} {
|
||||
nonAdminNamespaceSet := make(map[string]struct{}, len(kcl.NonAdminNamespaces))
|
||||
for _, namespace := range kcl.NonAdminNamespaces {
|
||||
nonAdminNamespaceSet[namespace] = struct{}{}
|
||||
}
|
||||
|
||||
return nonAdminNamespaceSet
|
||||
}
|
||||
|
|
|
@ -39,11 +39,7 @@ func (kcl *KubeClient) fetchResourceQuotasForNonAdmin(namespace string) (*[]core
|
|||
return nil, err
|
||||
}
|
||||
|
||||
nonAdminNamespaceSet := make(map[string]struct{}, len(kcl.NonAdminNamespaces))
|
||||
for _, ns := range kcl.NonAdminNamespaces {
|
||||
nonAdminNamespaceSet[ns] = struct{}{}
|
||||
}
|
||||
|
||||
nonAdminNamespaceSet := kcl.BuildNonAdminNamespacesMap()
|
||||
results := []corev1.ResourceQuota{}
|
||||
for _, resourceQuota := range *resourceQuotas {
|
||||
if _, exists := nonAdminNamespaceSet[resourceQuota.Namespace]; exists {
|
||||
|
|
Loading…
Reference in New Issue