Skip to content

Commit 2a70a37

Browse files
authored
Merge pull request #3525 from sniok/fix-ingress-rules-type
frontend: Ingress: Mark rules field as optional
2 parents 209be4f + b810be9 commit 2a70a37

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

frontend/src/components/ingress/Details.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export function LinkStringFormat({ url, item, urlPath }: LinkStringFormatProps)
7979
/*
8080
* Since we cannot access the prefix from the ingress object, we have to access it from the rules array
8181
*/
82-
const rules: any[] = item.spec.rules;
82+
const rules: any[] | undefined = item.spec.rules;
8383
let currentPathType;
8484
if (rules) {
8585
for (let i = 0; i < rules.length; i++) {

frontend/src/components/resourceMap/sources/definitions/relations.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ const endpointsToServices = makeRelation(
155155
);
156156

157157
const ingressToService = makeRelation(Ingress, Service, (ingress, service) =>
158-
ingress.spec.rules.find((rule: any) =>
158+
ingress.spec.rules?.find((rule: any) =>
159159
rule.http?.paths?.find((path: any) => service.metadata.name === path?.backend?.service?.name)
160160
)
161161
);

frontend/src/lib/k8s/ingress.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export interface IngressBackend {
6060
export interface KubeIngress extends KubeObjectInterface {
6161
spec: {
6262
ingressClassName?: string;
63-
rules: IngressRule[] | LegacyIngressRule[];
63+
rules?: IngressRule[] | LegacyIngressRule[];
6464
tls?: {
6565
hosts: string[];
6666
secretName: string;
@@ -130,7 +130,7 @@ class Ingress extends KubeObject<KubeIngress> {
130130
}
131131

132132
getHosts() {
133-
return this.spec!.rules.map(({ host }) => host).join(' | ');
133+
return this.spec.rules?.map(({ host }) => host).join(' | ');
134134
}
135135

136136
getRules(): IngressRule[] {

0 commit comments

Comments
 (0)