wet-soccer-72485
02/09/2022, 2:45 AMtype PlainIngressRule = Omit<networking.v1.IngressRule, 'http'> & {
http: networking.v1.HTTPIngressRuleValue & {
paths: (Omit<networking.v1.HTTPIngressPath, 'pathType' | 'backend'> & {
pathType: string;
backend: Omit<networking.v1.IngressBackend, 'service'> & {
service: networking.v1.IngressServiceBackend;
};
})[];
};
};
const createAndValidateIngressRule = (
rule: PlainIngressRule
): PlainIngressRule => {
if (!rule.host) {
throw new Error(
'Ingress rule must have a host. For example: *.<http://test.foobar.com|test.foobar.com> or <http://test.foobar.com|test.foobar.com>'
);
}
if (!rule.http) {
throw new Error('Ingress rule is missing HTTP configuration');
}
if (!rule.http.paths) {
throw new Error('Ingress rule is missing HTTP configuration');
}
for (const path of rule.http.paths) {
if (!path.pathType) {
throw new Error(`Ingress rule path type is missing`);
}
if (!['ImplementationSpecific'].includes(path.pathType)) {
throw new Error(`Ingress rule path type is not valid: ${path.pathType}`);
}
if (!path.backend) {
throw new Error(`Ingress rule path is missing backend`);
}
if (!path.backend.service) {
throw new Error(`Ingress rule path is missing backend service`);
}
if (!path.backend.service.name) {
throw new Error(`Ingress rule path is missing backend service name`);
}
if (!path.backend.service.port) {
throw new Error(`Ingress rule path is missing backend service port`);
}
}
return rule;
};
all()
is doingUnwrap
was what I was looking for those coming across this thread later.