Skip to content

Commit 64453a3

Browse files
committed
Wire HTTPRoute defaults through web context
1 parent 49ba0c8 commit 64453a3

6 files changed

Lines changed: 93 additions & 0 deletions

File tree

web/src/core/adapters/onyxiaApi/ApiTypes.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,15 @@ export type ApiTypes = {
2121
ingressClassName: string;
2222
ingress?: boolean;
2323
route?: boolean;
24+
httpRoute?: {
25+
enabled: boolean;
26+
parentRefs: {
27+
name: string;
28+
namespace?: string;
29+
sectionName?: string;
30+
port?: number;
31+
}[];
32+
};
2433
istio?: {
2534
enabled: boolean;
2635
gateways: string[];

web/src/core/adapters/onyxiaApi/onyxiaApi.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ export function createOnyxiaApi(params: {
214214
ingressClassName: apiRegion.services.expose.ingressClassName,
215215
ingress: apiRegion.services.expose.ingress,
216216
route: apiRegion.services.expose.route,
217+
httpRoute: apiRegion.services.expose.httpRoute,
217218
customValues: apiRegion.services.customValues,
218219
istio: apiRegion.services.expose.istio,
219220
initScriptUrl: apiRegion.services.initScript,

web/src/core/ports/OnyxiaApi/DeploymentRegion.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,17 @@ export type DeploymentRegion = {
1111
ingressClassName: string | undefined;
1212
ingress: boolean | undefined;
1313
route: boolean | undefined;
14+
httpRoute:
15+
| {
16+
enabled: boolean;
17+
parentRefs: {
18+
name: string;
19+
namespace?: string;
20+
sectionName?: string;
21+
port?: number;
22+
}[];
23+
}
24+
| undefined;
1425
customValues: Record<string, unknown> | undefined;
1526
istio:
1627
| {

web/src/core/ports/OnyxiaApi/XOnyxia.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,17 @@ export type XOnyxiaContext = {
182182
ingressClassName: string | undefined;
183183
ingress: boolean | undefined;
184184
route: boolean | undefined;
185+
httpRoute:
186+
| {
187+
enabled: boolean;
188+
parentRefs: {
189+
name: string;
190+
namespace?: string;
191+
sectionName?: string;
192+
port?: number;
193+
}[];
194+
}
195+
| undefined;
185196
istio:
186197
| {
187198
enabled: boolean;

web/src/core/usecases/launcher/decoupledLogic/computeHelmValues.test.ts

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -851,6 +851,66 @@ describe(symToStr({ computeHelmValues }), () => {
851851
expect(got).toStrictEqual(expected);
852852
});
853853

854+
it("supports httpRoute parentRefs from x-onyxia context", () => {
855+
const xOnyxiaContext = {
856+
s3: {},
857+
k8s: {
858+
httpRoute: {
859+
enabled: true,
860+
parentRefs: [
861+
{
862+
name: "shared-gateway",
863+
namespace: "gateway-system",
864+
sectionName: "web"
865+
}
866+
]
867+
}
868+
}
869+
};
870+
871+
const got = computeHelmValues({
872+
helmValuesSchema: {
873+
type: "object",
874+
properties: {
875+
httpRoute: {
876+
type: "object",
877+
properties: {
878+
parentRefs: {
879+
type: "array",
880+
"x-onyxia": {
881+
overwriteDefaultWith: "k8s.httpRoute.parentRefs"
882+
},
883+
items: {
884+
type: "object",
885+
properties: {
886+
name: { type: "string" },
887+
namespace: { type: "string" },
888+
sectionName: { type: "string" }
889+
}
890+
}
891+
}
892+
}
893+
}
894+
}
895+
},
896+
helmValuesYaml: YAML.stringify({}),
897+
xOnyxiaContext,
898+
infoAmountInHelmValues: "user provided"
899+
});
900+
901+
expect(got.helmValues).toStrictEqual({
902+
httpRoute: {
903+
parentRefs: [
904+
{
905+
name: "shared-gateway",
906+
namespace: "gateway-system",
907+
sectionName: "web"
908+
}
909+
]
910+
}
911+
});
912+
});
913+
854914
it("default array work even when extra properties in objects", () => {
855915
const xOnyxiaContext = {
856916
s3: {},

web/src/core/usecases/launcher/thunks.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -767,6 +767,7 @@ export const protectedThunks = {
767767
ingressClassName: region.ingressClassName,
768768
ingress: region.ingress,
769769
route: region.route,
770+
httpRoute: region.httpRoute,
770771
istio: region.istio,
771772
randomSubdomain: `${Math.floor(Math.random() * 1000000)}`,
772773
initScriptUrl: region.initScriptUrl,

0 commit comments

Comments
 (0)