You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
portainer/app/kubernetes/helpers/stackHelper.js

27 lines
715 B

import _ from 'lodash-es';
import { KubernetesStack } from 'Kubernetes/models/stack/models';
class KubernetesStackHelper {
static stacksFromApplications(applications) {
const res = _.reduce(
applications,
(acc, app) => {
if (app.StackName) {
let stack = _.find(acc, { Name: app.StackName, ResourcePool: app.ResourcePool });
if (!stack) {
stack = new KubernetesStack();
stack.Name = app.StackName;
stack.ResourcePool = app.ResourcePool;
acc.push(stack);
}
stack.Applications.push(app);
}
return acc;
},
[]
);
return res;
}
}
export default KubernetesStackHelper;