mirror of
https://github.com/portainer/portainer.git
synced 2025-08-04 21:35:23 +02:00
feat(app): add ingress to app service form [EE-5569] (#9106)
This commit is contained in:
parent
8c16fbb8aa
commit
89c1d0e337
47 changed files with 1929 additions and 1181 deletions
|
@ -11,7 +11,7 @@ import { columnHelper } from './helper';
|
|||
export const ingressRules = columnHelper.accessor(
|
||||
({ Paths, TLS }) =>
|
||||
// return an accessor function with all the useful text to search for
|
||||
Paths.map((path) => {
|
||||
Paths?.map((path) => {
|
||||
const isHttp = isHTTP(TLS || [], path.Host);
|
||||
return `${isHttp ? 'http' : 'https'}://${path.Host}${path.Path}${
|
||||
path.ServiceName
|
||||
|
|
|
@ -92,25 +92,27 @@ export function useIngresses(
|
|||
.flat();
|
||||
|
||||
// check if each ingress path service has a service that still exists
|
||||
filteredIngresses.forEach((ing, iIndex) => {
|
||||
const servicesInNamespace = services?.filter(
|
||||
(service) => service?.Namespace === ing?.Namespace
|
||||
);
|
||||
const serviceNamesInNamespace = servicesInNamespace?.map(
|
||||
(service) => service.Name
|
||||
);
|
||||
ing.Paths?.forEach((path, pIndex) => {
|
||||
if (
|
||||
!serviceNamesInNamespace?.includes(path.ServiceName) &&
|
||||
filteredIngresses[iIndex].Paths
|
||||
) {
|
||||
filteredIngresses[iIndex].Paths[pIndex].HasService = false;
|
||||
} else {
|
||||
filteredIngresses[iIndex].Paths[pIndex].HasService = true;
|
||||
}
|
||||
});
|
||||
});
|
||||
return filteredIngresses;
|
||||
const updatedFilteredIngresses: Ingress[] = filteredIngresses.map(
|
||||
(ing) => {
|
||||
const servicesInNamespace = services?.filter(
|
||||
(service) => service?.Namespace === ing?.Namespace
|
||||
);
|
||||
const serviceNamesInNamespace = servicesInNamespace?.map(
|
||||
(service) => service.Name
|
||||
);
|
||||
|
||||
const updatedPaths =
|
||||
ing.Paths?.map((path) => {
|
||||
const hasService = serviceNamesInNamespace?.includes(
|
||||
path.ServiceName
|
||||
);
|
||||
return { ...path, HasService: hasService };
|
||||
}) || null;
|
||||
|
||||
return { ...ing, Paths: updatedPaths };
|
||||
}
|
||||
);
|
||||
return updatedFilteredIngresses;
|
||||
},
|
||||
{
|
||||
enabled: !!namespaces?.length,
|
||||
|
@ -175,7 +177,7 @@ export function useDeleteIngresses() {
|
|||
*/
|
||||
export function useIngressControllers(
|
||||
environmentId: EnvironmentId,
|
||||
namespace: string
|
||||
namespace?: string
|
||||
) {
|
||||
return useQuery(
|
||||
[
|
||||
|
@ -186,10 +188,8 @@ export function useIngressControllers(
|
|||
namespace,
|
||||
'ingresscontrollers',
|
||||
],
|
||||
async () => {
|
||||
const ing = await getIngressControllers(environmentId, namespace);
|
||||
return ing;
|
||||
},
|
||||
async () =>
|
||||
namespace ? getIngressControllers(environmentId, namespace) : [],
|
||||
{
|
||||
enabled: !!namespace,
|
||||
cacheTime: 0,
|
||||
|
|
|
@ -30,7 +30,7 @@ export type Ingress = {
|
|||
ClassName: string;
|
||||
Annotations?: Record<string, string>;
|
||||
Hosts?: string[];
|
||||
Paths: Path[];
|
||||
Paths: Path[] | null;
|
||||
TLS?: TLS[];
|
||||
Type?: string;
|
||||
Labels?: Record<string, string>;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue