Skip to content

Commit

Permalink
fix: add path prop for route object (podman-desktop#4981)
Browse files Browse the repository at this point in the history
* fix: add path prop for route object

Signed-off-by: lstocchi <[email protected]>

* Update packages/renderer/src/lib/ingresses-routes/ingress-route-utils.spec.ts

Co-authored-by: Philippe Martin <[email protected]>
Signed-off-by: Luca Stocchi <[email protected]>

* fix: fix route in deployToKube

Signed-off-by: lstocchi <[email protected]>

---------

Signed-off-by: lstocchi <[email protected]>
Signed-off-by: Luca Stocchi <[email protected]>
Co-authored-by: Philippe Martin <[email protected]>
  • Loading branch information
lstocchi and feloy authored Nov 24, 2023
1 parent e9a83c2 commit a64d852
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 6 deletions.
3 changes: 2 additions & 1 deletion packages/main/src/plugin/api/openshift-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ export type V1Route = {
};
spec: {
host: string;
port: {
port?: {
targetPort: string;
};
path?: string;
tls: {
insecureEdgeTerminationPolicy: string;
termination: string;
Expand Down
3 changes: 2 additions & 1 deletion packages/renderer/src/lib/ingresses-routes/RouteUI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ export interface RouteUI {
name: string;
namespace: string;
host: string;
port: string;
port?: string;
path?: string;
to: RouteToReference;
selected: boolean;
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ test('expect basic UI conversion for ingress', async () => {
expect(ingressUI.rules).equal(ingress.spec?.rules);
});

test('expect basic UI conversion for route', async () => {
test('expect basic UI conversion for route with port', async () => {
const route = {
metadata: {
name: 'my-route',
Expand All @@ -84,7 +84,33 @@ test('expect basic UI conversion for route', async () => {
expect(routeUI.name).toEqual('my-route');
expect(routeUI.namespace).toEqual('test-namespace');
expect(routeUI.host).toEqual(route.spec.host);
expect(routeUI.port).toEqual(route.spec.port.targetPort);
expect(routeUI.port).toEqual(route.spec.port?.targetPort);
expect(routeUI.path).toBeUndefined();
expect(routeUI.to.kind).toEqual(route.spec.to.kind);
expect(routeUI.to.name).toEqual(route.spec.to.name);
});

test('expect basic UI conversion for route with path', async () => {
const route = {
metadata: {
name: 'my-route',
namespace: 'test-namespace',
},
spec: {
host: 'foo.bar.com',
path: '/test',
to: {
kind: 'Service',
name: 'service',
},
},
} as V1Route;
const routeUI = ingressRouteUtils.getRouteUI(route);
expect(routeUI.name).toEqual('my-route');
expect(routeUI.namespace).toEqual('test-namespace');
expect(routeUI.host).toEqual(route.spec.host);
expect(routeUI.port).toBeUndefined();
expect(routeUI.path).toEqual(route.spec.path);
expect(routeUI.to.kind).toEqual(route.spec.to.kind);
expect(routeUI.to.name).toEqual(route.spec.to.name);
});
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ export class IngressRouteUtils {
name: route.metadata?.name || '',
namespace: route.metadata?.namespace || '',
host: route.spec.host,
port: route.spec.port.targetPort,
port: route.spec.port?.targetPort,
path: route.spec.path,
to: {
kind: route.spec.to.kind,
name: route.spec.to.name,
Expand Down
2 changes: 1 addition & 1 deletion packages/renderer/src/lib/pod/DeployPodToKube.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ function updateKubeResult() {
<ul class="list-disc list-inside">
{#each createdRoutes as createdRoute}
<li class="pt-2">
Port {createdRoute.spec.port.targetPort} is reachable with route
Port {createdRoute.spec.port?.targetPort} is reachable with route
<Link on:click="{() => openRoute(createdRoute)}">{createdRoute.metadata.name}</Link>
</li>
{/each}
Expand Down

0 comments on commit a64d852

Please sign in to comment.