mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Add helper method to Ingress
Signed-off-by: Panu Horsmalahti <phorsmalahti@mirantis.com>
This commit is contained in:
parent
3ca2706e5b
commit
59a71a78cf
@ -119,6 +119,17 @@ export class Ingress extends KubeObject {
|
|||||||
return routes;
|
return routes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getServiceNamePort() {
|
||||||
|
const { spec } = this;
|
||||||
|
const serviceName = spec?.defaultBackend?.service.name ?? spec?.backend?.serviceName;
|
||||||
|
const servicePort = spec?.defaultBackend?.service.port.number ?? spec?.defaultBackend?.service.port.name ?? spec?.backend?.servicePort;
|
||||||
|
|
||||||
|
return {
|
||||||
|
serviceName,
|
||||||
|
servicePort
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
getHosts() {
|
getHosts() {
|
||||||
const { spec: { rules } } = this;
|
const { spec: { rules } } = this;
|
||||||
if (!rules) return [];
|
if (!rules) return [];
|
||||||
@ -130,7 +141,10 @@ export class Ingress extends KubeObject {
|
|||||||
const { spec: { tls, rules, backend, defaultBackend } } = this;
|
const { spec: { tls, rules, backend, defaultBackend } } = this;
|
||||||
const httpPort = 80;
|
const httpPort = 80;
|
||||||
const tlsPort = 443;
|
const tlsPort = 443;
|
||||||
const servicePort = defaultBackend?.service.port.number ?? defaultBackend?.service.port.name ?? backend?.servicePort;
|
|
||||||
|
// Note: not using the port name (string)
|
||||||
|
const servicePort = defaultBackend?.service.port.number ?? backend?.servicePort;
|
||||||
|
|
||||||
if (rules && rules.length > 0) {
|
if (rules && rules.length > 0) {
|
||||||
if (rules.some(rule => rule.hasOwnProperty("http"))) {
|
if (rules.some(rule => rule.hasOwnProperty("http"))) {
|
||||||
ports.push(httpPort);
|
ports.push(httpPort);
|
||||||
|
|||||||
@ -104,8 +104,7 @@ export class IngressDetails extends React.Component<Props> {
|
|||||||
<Trans>Duration</Trans>,
|
<Trans>Duration</Trans>,
|
||||||
];
|
];
|
||||||
|
|
||||||
const serviceName = spec?.defaultBackend?.service.name ?? spec?.backend?.serviceName;
|
const { serviceName, servicePort } = ingress.getServiceNamePort();
|
||||||
const servicePort = spec?.defaultBackend?.service.port.number ?? spec?.defaultBackend?.service.port.name ?? spec?.backend?.servicePort;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="IngressDetails">
|
<div className="IngressDetails">
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user