mirror of https://github.com/portainer/portainer
fix error when edit pod application (#6418)
parent
50b2f789a3
commit
a79aa221d3
|
@ -279,56 +279,60 @@ class KubernetesApplicationHelper {
|
||||||
/* #region SERVICES -> SERVICES FORM VALUES */
|
/* #region SERVICES -> SERVICES FORM VALUES */
|
||||||
static generateServicesFormValuesFromServices(app) {
|
static generateServicesFormValuesFromServices(app) {
|
||||||
let services = [];
|
let services = [];
|
||||||
app.Services.forEach(function (service) {
|
if (app.Services) {
|
||||||
const svc = new KubernetesService();
|
app.Services.forEach(function (service) {
|
||||||
svc.Namespace = service.metadata.namespace;
|
const svc = new KubernetesService();
|
||||||
svc.Name = service.metadata.name;
|
svc.Namespace = service.metadata.namespace;
|
||||||
svc.StackName = service.StackName;
|
svc.Name = service.metadata.name;
|
||||||
svc.ApplicationOwner = app.ApplicationOwner;
|
svc.StackName = service.StackName;
|
||||||
svc.ApplicationName = app.ApplicationName;
|
svc.ApplicationOwner = app.ApplicationOwner;
|
||||||
svc.Type = service.spec.type;
|
svc.ApplicationName = app.ApplicationName;
|
||||||
if (service.spec.type === KubernetesServiceTypes.CLUSTER_IP) {
|
svc.Type = service.spec.type;
|
||||||
svc.Type = 1;
|
if (service.spec.type === KubernetesServiceTypes.CLUSTER_IP) {
|
||||||
} else if (service.spec.type === KubernetesServiceTypes.NODE_PORT) {
|
svc.Type = 1;
|
||||||
svc.Type = 2;
|
} else if (service.spec.type === KubernetesServiceTypes.NODE_PORT) {
|
||||||
} else if (service.spec.type === KubernetesServiceTypes.LOAD_BALANCER) {
|
svc.Type = 2;
|
||||||
svc.Type = 3;
|
} else if (service.spec.type === KubernetesServiceTypes.LOAD_BALANCER) {
|
||||||
}
|
svc.Type = 3;
|
||||||
|
}
|
||||||
|
|
||||||
let ports = [];
|
let ports = [];
|
||||||
service.spec.ports.forEach(function (port) {
|
service.spec.ports.forEach(function (port) {
|
||||||
const svcport = new KubernetesServicePort();
|
const svcport = new KubernetesServicePort();
|
||||||
svcport.name = port.name;
|
svcport.name = port.name;
|
||||||
svcport.port = port.port;
|
svcport.port = port.port;
|
||||||
svcport.nodePort = port.nodePort;
|
svcport.nodePort = port.nodePort;
|
||||||
svcport.protocol = port.protocol;
|
svcport.protocol = port.protocol;
|
||||||
svcport.targetPort = port.targetPort;
|
svcport.targetPort = port.targetPort;
|
||||||
|
|
||||||
app.Ingresses.value.forEach((ingress) => {
|
app.Ingresses.value.forEach((ingress) => {
|
||||||
const ingressMatched = _.find(ingress.Paths, { ServiceName: service.metadata.name });
|
const ingressMatched = _.find(ingress.Paths, { ServiceName: service.metadata.name });
|
||||||
if (ingressMatched) {
|
if (ingressMatched) {
|
||||||
svcport.ingress = {
|
svcport.ingress = {
|
||||||
IngressName: ingressMatched.IngressName,
|
IngressName: ingressMatched.IngressName,
|
||||||
Host: ingressMatched.Host,
|
Host: ingressMatched.Host,
|
||||||
Path: ingressMatched.Path,
|
Path: ingressMatched.Path,
|
||||||
};
|
};
|
||||||
svc.Ingress = true;
|
svc.Ingress = true;
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
ports.push(svcport);
|
||||||
});
|
});
|
||||||
|
svc.Ports = ports;
|
||||||
ports.push(svcport);
|
svc.Selector = app.Raw.spec.selector.matchLabels;
|
||||||
|
services.push(svc);
|
||||||
});
|
});
|
||||||
svc.Ports = ports;
|
|
||||||
svc.Selector = app.Raw.spec.selector.matchLabels;
|
|
||||||
services.push(svc);
|
|
||||||
});
|
|
||||||
|
|
||||||
return services;
|
return services;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/* #endregion */
|
/* #endregion */
|
||||||
static generateSelectorFromService(app) {
|
static generateSelectorFromService(app) {
|
||||||
const selector = app.Raw.spec.selector.matchLabels;
|
if (app.Raw.kind !== 'Pod') {
|
||||||
return selector;
|
const selector = app.Raw.spec.selector.matchLabels;
|
||||||
|
return selector;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* #region PUBLISHED PORTS FV <> PUBLISHED PORTS */
|
/* #region PUBLISHED PORTS FV <> PUBLISHED PORTS */
|
||||||
|
|
Loading…
Reference in New Issue