mirror of
https://github.com/portainer/portainer.git
synced 2025-07-23 07:19:41 +02:00
fix(kubernetes): deprecate old configurations api EE-5571 (#10837)
* fix(kubernetes): deprecate old configurations api EE-5571 * fix doc variable type
This commit is contained in:
parent
0b9407f0a6
commit
0ddf84638f
3 changed files with 26 additions and 59 deletions
|
@ -8,6 +8,22 @@ import (
|
||||||
"github.com/portainer/portainer/pkg/libhttp/response"
|
"github.com/portainer/portainer/pkg/libhttp/response"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// @id getKubernetesConfigMapsAndSecrets
|
||||||
|
// @summary Get ConfigMaps and Secrets
|
||||||
|
// @description Get all ConfigMaps and Secrets for a given namespace
|
||||||
|
// @description **Access policy**: authenticated
|
||||||
|
// @tags kubernetes
|
||||||
|
// @security ApiKeyAuth
|
||||||
|
// @security jwt
|
||||||
|
// @accept json
|
||||||
|
// @produce json
|
||||||
|
// @param id path int true "Environment (Endpoint) identifier"
|
||||||
|
// @param namespace path string true "Namespace name"
|
||||||
|
// @success 200 {array} []kubernetes.K8sConfigMapOrSecret "Success"
|
||||||
|
// @failure 400 "Invalid request"
|
||||||
|
// @failure 500 "Server error"
|
||||||
|
// @deprecated
|
||||||
|
// @router /kubernetes/{id}/namespaces/{namespace}/configuration [get]
|
||||||
func (handler *Handler) getKubernetesConfigMapsAndSecrets(w http.ResponseWriter, r *http.Request) *httperror.HandlerError {
|
func (handler *Handler) getKubernetesConfigMapsAndSecrets(w http.ResponseWriter, r *http.Request) *httperror.HandlerError {
|
||||||
namespace, err := request.RetrieveRouteVariableValue(r, "namespace")
|
namespace, err := request.RetrieveRouteVariableValue(r, "namespace")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -1,49 +0,0 @@
|
||||||
import { useQuery } from 'react-query';
|
|
||||||
|
|
||||||
import { EnvironmentId } from '@/react/portainer/environments/types';
|
|
||||||
import { error as notifyError } from '@/portainer/services/notifications';
|
|
||||||
import { withError } from '@/react-tools/react-query';
|
|
||||||
|
|
||||||
import { getConfigurations, getConfigMapsForCluster } from './service';
|
|
||||||
|
|
||||||
// returns a usequery hook for the formatted list of configmaps and secrets
|
|
||||||
export function useConfigurations(
|
|
||||||
environmentId: EnvironmentId,
|
|
||||||
namespace?: string
|
|
||||||
) {
|
|
||||||
return useQuery(
|
|
||||||
[
|
|
||||||
'environments',
|
|
||||||
environmentId,
|
|
||||||
'kubernetes',
|
|
||||||
'namespaces',
|
|
||||||
namespace,
|
|
||||||
'configurations',
|
|
||||||
],
|
|
||||||
() => (namespace ? getConfigurations(environmentId, namespace) : []),
|
|
||||||
{
|
|
||||||
onError: (err) => {
|
|
||||||
notifyError(
|
|
||||||
'Failure',
|
|
||||||
err as Error,
|
|
||||||
`Unable to get configurations for namespace ${namespace}`
|
|
||||||
);
|
|
||||||
},
|
|
||||||
enabled: !!namespace,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function useConfigurationsForCluster(
|
|
||||||
environemtId: EnvironmentId,
|
|
||||||
namespaces?: string[]
|
|
||||||
) {
|
|
||||||
return useQuery(
|
|
||||||
['environments', environemtId, 'kubernetes', 'configurations'],
|
|
||||||
() => namespaces && getConfigMapsForCluster(environemtId, namespaces),
|
|
||||||
{
|
|
||||||
...withError('Unable to retrieve configurations for cluster'),
|
|
||||||
enabled: !!namespaces,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
|
@ -4,7 +4,7 @@ import { v4 as uuidv4 } from 'uuid';
|
||||||
import { debounce } from 'lodash';
|
import { debounce } from 'lodash';
|
||||||
|
|
||||||
import { useEnvironmentId } from '@/react/hooks/useEnvironmentId';
|
import { useEnvironmentId } from '@/react/hooks/useEnvironmentId';
|
||||||
import { useConfigurations } from '@/react/kubernetes/configs/queries';
|
import { useSecrets } from '@/react/kubernetes/configs/secret.service';
|
||||||
import { useNamespaceServices } from '@/react/kubernetes/networks/services/queries';
|
import { useNamespaceServices } from '@/react/kubernetes/networks/services/queries';
|
||||||
import { notifyError, notifySuccess } from '@/portainer/services/notifications';
|
import { notifyError, notifySuccess } from '@/portainer/services/notifications';
|
||||||
import { useAuthorizations } from '@/react/hooks/useUser';
|
import { useAuthorizations } from '@/react/hooks/useUser';
|
||||||
|
@ -68,7 +68,7 @@ export function CreateIngressView() {
|
||||||
useNamespacesQuery(environmentId);
|
useNamespacesQuery(environmentId);
|
||||||
|
|
||||||
const { data: allServices } = useNamespaceServices(environmentId, namespace);
|
const { data: allServices } = useNamespaceServices(environmentId, namespace);
|
||||||
const configResults = useConfigurations(environmentId, namespace);
|
const secretsResults = useSecrets(environmentId, namespace);
|
||||||
const ingressesResults = useIngresses(
|
const ingressesResults = useIngresses(
|
||||||
environmentId,
|
environmentId,
|
||||||
namespaces ? Object.keys(namespaces || {}) : []
|
namespaces ? Object.keys(namespaces || {}) : []
|
||||||
|
@ -266,20 +266,20 @@ export function CreateIngressView() {
|
||||||
ingressRule.IngressClassName,
|
ingressRule.IngressClassName,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const matchedConfigs = configResults?.data?.filter(
|
const secrets = secretsResults?.data?.filter(
|
||||||
(config) =>
|
(config) =>
|
||||||
config.SecretType === 'kubernetes.io/tls' &&
|
config.type === 'kubernetes.io/tls' &&
|
||||||
config.Namespace === namespace
|
config.metadata?.namespace === namespace
|
||||||
);
|
);
|
||||||
const tlsOptions: Option<string>[] = useMemo(
|
const tlsOptions: Option<string>[] = useMemo(
|
||||||
() => [
|
() => [
|
||||||
{ label: 'No TLS', value: '' },
|
{ label: 'No TLS', value: '' },
|
||||||
...(matchedConfigs?.map((config) => ({
|
...(secrets?.map((config) => ({
|
||||||
label: config.Name,
|
label: config.metadata?.name as string,
|
||||||
value: config.Name,
|
value: config.metadata?.name as string,
|
||||||
})) || []),
|
})) || []),
|
||||||
],
|
],
|
||||||
[matchedConfigs]
|
[secrets]
|
||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -811,7 +811,7 @@ export function CreateIngressView() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function reloadTLSCerts() {
|
function reloadTLSCerts() {
|
||||||
configResults.refetch();
|
secretsResults.refetch();
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleCreateIngressRules() {
|
function handleCreateIngressRules() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue