Merge pull request #1409 from balena-io/bugfix-safeappclone

common: Fix bug where aliases might be undefined
This commit is contained in:
bulldozer-balena[bot] 2020-07-23 16:17:49 +00:00 committed by GitHub
commit 0b445f4d77
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -154,10 +154,13 @@ export function safeAppClone(app) {
// TODO: Make the process of moving from a current state to a target state
// well-defined (and implemented in a seperate module)
const svcCopy = _.cloneDeep(svc);
_.each(svcCopy.config.networks, (net) => {
net.aliases = net.aliases.filter(
(alias) => alias !== containerIdForService[svcCopy.serviceName],
);
if (Array.isArray(net.aliases)) {
net.aliases = net.aliases.filter(
(alias) => alias !== containerIdForService[svcCopy.serviceName],
);
}
});
return svcCopy;
}),