1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-25 08:19:40 +02:00

feat(k8s): Allow mix services for k8s app EE-1791 (#6198)

allow a mix of services for k8s in ui
This commit is contained in:
Richard Wei 2022-01-17 08:37:46 +13:00 committed by GitHub
parent edf048570b
commit c47e840b37
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
26 changed files with 2336 additions and 1863 deletions

View file

@ -76,6 +76,69 @@ export class KubernetesIngressConverter {
return ingresses;
}
static applicationFormValuesToDeleteIngresses(formValues, application) {
const ingresses = angular.copy(formValues.OriginalIngresses);
application.Services.forEach((service) => {
ingresses.forEach((ingress) => {
const path = _.find(ingress.Paths, { ServiceName: service.metadata.name });
if (path) {
_.remove(ingress.Paths, path);
}
});
});
return ingresses;
}
static deleteIngressByServiceName(formValues, service) {
const ingresses = angular.copy(formValues.OriginalIngresses);
ingresses.forEach((ingress) => {
const path = _.find(ingress.Paths, { ServiceName: service.Name });
if (path) {
_.remove(ingress.Paths, path);
}
});
return ingresses;
}
static newApplicationFormValuesToIngresses(formValues, serviceName, servicePorts) {
const ingresses = angular.copy(formValues.OriginalIngresses);
servicePorts.forEach((port) => {
const ingress = _.find(ingresses, { Name: port.ingress.IngressName });
if (ingress) {
const rule = new KubernetesIngressRule();
rule.ServiceName = serviceName;
rule.IngressName = port.ingress.IngressName;
rule.Host = port.ingress.Host;
rule.Path = _.startsWith(port.ingress.Path, '/') ? port.ingress.Path : '/' + port.ingress.Path;
rule.Port = port.port;
ingress.Paths.push(rule);
}
});
return ingresses;
}
static editingFormValuesToIngresses(formValues, serviceName, servicePorts) {
const ingresses = angular.copy(formValues.OriginalIngresses);
servicePorts.forEach((port) => {
const ingressMatched = _.find(ingresses, { Name: port.ingress.IngressName });
if (ingressMatched) {
const pathMatched = _.find(ingressMatched.Paths, { ServiceName: serviceName });
_.remove(ingressMatched.Paths, pathMatched);
const rule = new KubernetesIngressRule();
rule.ServiceName = serviceName;
rule.IngressName = port.ingress.IngressName;
rule.Host = port.ingress.Host;
rule.Path = _.startsWith(port.ingress.Path, '/') ? port.ingress.Path : '/' + port.ingress.Path;
rule.Port = port.port;
ingressMatched.Paths.push(rule);
}
});
return ingresses;
}
/**
*
* @param {KubernetesResourcePoolIngressClassFormValue[]} formValues