diff --git a/lib/shared/addon/components/form-ingress-backends/component.js b/lib/shared/addon/components/form-ingress-backends/component.js index 17b34dc35..bac56c95c 100644 --- a/lib/shared/addon/components/form-ingress-backends/component.js +++ b/lib/shared/addon/components/form-ingress-backends/component.js @@ -44,7 +44,7 @@ export default Component.extend({ if (get(this, 'isDefault')) { this.setDefaultBackend(); } else { - this.setPaths(); + set(this, 'rule.paths', get(this, 'pathArray')); } }), @@ -69,18 +69,16 @@ export default Component.extend({ initPathArray() { const pathArray = []; - const paths = get(this, 'rule.paths'); - - Object.keys(paths).forEach((p) => { - const path = paths[p]; + const paths = get(this, 'rule.paths') || []; + paths.forEach((path) => { if (get(path, 'serviceId')) { pathArray.pushObject(get(this, 'store').createRecord({ type: 'httpingresspath', backendType: 'service', targetPort: `${ get(path, 'targetPort') || '' }`, serviceId: get(path, 'serviceId').replace('/', ':'), - path: p, + path: get(path, 'path'), })); } else if (get(path, 'workloadIds')) { get(path, 'workloadIds').forEach((workload) => { @@ -88,7 +86,7 @@ export default Component.extend({ backendType: 'workload', targetPort: get(path, 'targetPort'), serviceId: workload, - path: p, + path: get(path, 'path'), }); }); } @@ -114,43 +112,4 @@ export default Component.extend({ }); set(this, 'ingress.defaultBackend', defaultBackend); }, - - setPaths() { - const pathArray = get(this, 'pathArray'); - const paths = {}; - - pathArray.forEach((path) => { - const backendType = get(path, 'backendType'); - const pathValue = get(path, 'path'); - const serviceId = get(path, 'serviceId'); - const targetPort = get(path, 'targetPort'); - - if (backendType === 'service') { - const found = paths[pathValue]; - - if (found) { - found.serviceId = serviceId; - found.targetPort = targetPort; - } else { - paths[pathValue] = { - serviceId, - targetPort, - }; - } - } else if (backendType === 'workload') { - const found = paths[pathValue]; - - if (found && found.workloadIds) { - found.workloadIds.pushObject(serviceId); - found.targetPort = targetPort; - } else { - paths[pathValue] = { - workloadIds: [serviceId], - targetPort, - }; - } - } - }) - set(this, 'rule.paths', paths); - } });