Skip to content

Commit

Permalink
support random ports on defined range for marketplace apps
Browse files Browse the repository at this point in the history
  • Loading branch information
Cabecinha84 committed Dec 21, 2023
1 parent f7c5386 commit 5ff529b
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion HomeUI/src/views/apps/marketplace/AppView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -975,11 +975,25 @@ export default {
showToast('success', 'Successful upload of Environment Parameters to Flux Storage');
envParams = [`F_S_ENV=https://storage.runonflux.io/v1/env/${envid}`];
}
let { ports } = component;
if (component.portSpecs) {
ports = [];
for (let y = 0; y < component.portSpecs.length; y += 1) {
const portInterval = component.portSpecs[y];
if (typeof portInterval === 'string') { // '0-10'
const minPort = Number(portInterval.split('-')[0]);
const maxPort = Number(portInterval.split('-')[1]);
ports.push(Math.floor(Math.random() * (maxPort - minPort + 1) + minPort));
} else {
throw new Error('Port Specs Range for the application on Marketplace is not properly configured');
}
}
}
const appComponent = {
name: component.name,
description: component.description,
repotag: component.repotag,
ports: component.ports,
ports,
containerPorts: component.containerPorts,
environmentParameters: envParams,
commands: component.commands,
Expand Down

0 comments on commit 5ff529b

Please sign in to comment.