Skip to content

fixing bug where hosts and destination were not added to rules #186

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 1, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 21 additions & 25 deletions webui/src/js/utils/vz-application-resource-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,12 @@ define(['models/wkt-project', 'utils/vz-helper', 'js-yaml', 'utils/i18n', 'utils
for (const ingressTraitRule of component.ingressTraitRules) {
const rule = { };

if (Array.isArray(ingressTraitRule.hosts) && ingressTraitRule.hosts.length > 0) {
if (typeof ingressTraitRule.hosts === 'string' && ingressTraitRule.hosts.length > 0) {
rule.hosts = ingressTraitRule.hosts.split(',').map(host => host.trim());
} else if (Array.isArray(ingressTraitRule.hosts) && ingressTraitRule.hosts.length > 0) {
rule.hosts = ingressTraitRule.hosts;
}

if (Array.isArray(ingressTraitRule.paths) && ingressTraitRule.paths.length > 0) {
rule.paths = ingressTraitRule.paths.map(path => {
const newPath = Object.assign({}, path);
Expand Down Expand Up @@ -222,38 +225,31 @@ define(['models/wkt-project', 'utils/vz-helper', 'js-yaml', 'utils/i18n', 'utils
}

_getIngressTraitRuleDestination(ingressTraitRule) {
let destination = ingressTraitRule.destination ? { } : undefined;
const destination = { };

if (!destination) {
return destination;
if (ingressTraitRule.destinationHost) {
destination.host = ingressTraitRule.destinationHost;
}
if (ingressTraitRule.destinationPort) {
destination.port = ingressTraitRule.destinationPort;
}

if (ingressTraitRule.destination.host) {
destination.host = ingressTraitRule.destination.host;
const httpCookie = { };
if (ingressTraitRule.destinationHttpCookieName) {
httpCookie.name = ingressTraitRule.destinationHttpCookieName;
}
if (ingressTraitRule.destination.port) {
destination.port = ingressTraitRule.destination.port;
if (ingressTraitRule.destinationHttpCookiePath) {
httpCookie.path = ingressTraitRule.destinationHttpCookiePath;
}
if (ingressTraitRule.destination.httpCookie) {
let httpCookie = { };

if (ingressTraitRule.destination.httpCookie.name) {
httpCookie.name = ingressTraitRule.destination.httpCookie.name;
}
if (ingressTraitRule.destination.httpCookie.path) {
httpCookie.path = ingressTraitRule.destination.httpCookie.path;
}
if (ingressTraitRule.destination.httpCookie.ttl) {
httpCookie.ttl = ingressTraitRule.destination.httpCookie.ttl;
}

if (Object.keys(httpCookie).length > 0) {
destination.httpCookie = httpCookie;
}
if (ingressTraitRule.destinationHttpCookieTTL) {
httpCookie.ttl = ingressTraitRule.destinationHttpCookieTTL;
}
if (Object.keys(httpCookie).length > 0) {
destination.httpCookie = httpCookie;
}

if (Object.keys(destination).length === 0) {
destination = undefined;
return undefined;
}
return destination;
}
Expand Down