Skip to content

Commit f7de948

Browse files
fixing bug where hosts and destination were not added to rules (#186)
1 parent 2fd652b commit f7de948

File tree

1 file changed

+21
-25
lines changed

1 file changed

+21
-25
lines changed

webui/src/js/utils/vz-application-resource-generator.js

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,12 @@ define(['models/wkt-project', 'utils/vz-helper', 'js-yaml', 'utils/i18n', 'utils
135135
for (const ingressTraitRule of component.ingressTraitRules) {
136136
const rule = { };
137137

138-
if (Array.isArray(ingressTraitRule.hosts) && ingressTraitRule.hosts.length > 0) {
138+
if (typeof ingressTraitRule.hosts === 'string' && ingressTraitRule.hosts.length > 0) {
139+
rule.hosts = ingressTraitRule.hosts.split(',').map(host => host.trim());
140+
} else if (Array.isArray(ingressTraitRule.hosts) && ingressTraitRule.hosts.length > 0) {
139141
rule.hosts = ingressTraitRule.hosts;
140142
}
143+
141144
if (Array.isArray(ingressTraitRule.paths) && ingressTraitRule.paths.length > 0) {
142145
rule.paths = ingressTraitRule.paths.map(path => {
143146
const newPath = Object.assign({}, path);
@@ -222,38 +225,31 @@ define(['models/wkt-project', 'utils/vz-helper', 'js-yaml', 'utils/i18n', 'utils
222225
}
223226

224227
_getIngressTraitRuleDestination(ingressTraitRule) {
225-
let destination = ingressTraitRule.destination ? { } : undefined;
228+
const destination = { };
226229

227-
if (!destination) {
228-
return destination;
230+
if (ingressTraitRule.destinationHost) {
231+
destination.host = ingressTraitRule.destinationHost;
232+
}
233+
if (ingressTraitRule.destinationPort) {
234+
destination.port = ingressTraitRule.destinationPort;
229235
}
230236

231-
if (ingressTraitRule.destination.host) {
232-
destination.host = ingressTraitRule.destination.host;
237+
const httpCookie = { };
238+
if (ingressTraitRule.destinationHttpCookieName) {
239+
httpCookie.name = ingressTraitRule.destinationHttpCookieName;
233240
}
234-
if (ingressTraitRule.destination.port) {
235-
destination.port = ingressTraitRule.destination.port;
241+
if (ingressTraitRule.destinationHttpCookiePath) {
242+
httpCookie.path = ingressTraitRule.destinationHttpCookiePath;
236243
}
237-
if (ingressTraitRule.destination.httpCookie) {
238-
let httpCookie = { };
239-
240-
if (ingressTraitRule.destination.httpCookie.name) {
241-
httpCookie.name = ingressTraitRule.destination.httpCookie.name;
242-
}
243-
if (ingressTraitRule.destination.httpCookie.path) {
244-
httpCookie.path = ingressTraitRule.destination.httpCookie.path;
245-
}
246-
if (ingressTraitRule.destination.httpCookie.ttl) {
247-
httpCookie.ttl = ingressTraitRule.destination.httpCookie.ttl;
248-
}
249-
250-
if (Object.keys(httpCookie).length > 0) {
251-
destination.httpCookie = httpCookie;
252-
}
244+
if (ingressTraitRule.destinationHttpCookieTTL) {
245+
httpCookie.ttl = ingressTraitRule.destinationHttpCookieTTL;
246+
}
247+
if (Object.keys(httpCookie).length > 0) {
248+
destination.httpCookie = httpCookie;
253249
}
254250

255251
if (Object.keys(destination).length === 0) {
256-
destination = undefined;
252+
return undefined;
257253
}
258254
return destination;
259255
}

0 commit comments

Comments
 (0)