mirror of
https://github.com/yldio/copilot.git
synced 2024-11-28 06:00:06 +02:00
feat(portal-api): add support for env_file's
This commit is contained in:
parent
441d7398a8
commit
68084a257d
@ -113,6 +113,14 @@ class Data extends EventEmitter {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fromKeyValueToDict(kv) {
|
||||||
|
return kv.reduce((acc, { name, value }) => {
|
||||||
|
return Object.assign(acc, {
|
||||||
|
[name]: value
|
||||||
|
});
|
||||||
|
}, {});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// triton
|
// triton
|
||||||
|
|
||||||
@ -571,7 +579,7 @@ class Data extends EventEmitter {
|
|||||||
this._listMachines(deploymentGroupName, handleMachinesList);
|
this._listMachines(deploymentGroupName, handleMachinesList);
|
||||||
}
|
}
|
||||||
|
|
||||||
scale ({ serviceId, environment, replicas }, cb) {
|
scale ({ serviceId, replicas }, cb) {
|
||||||
Hoek.assert(serviceId, 'service id is required');
|
Hoek.assert(serviceId, 'service id is required');
|
||||||
Hoek.assert(typeof replicas === 'number' && replicas >= 0, 'replicas must be a number no less than 0');
|
Hoek.assert(typeof replicas === 'number' && replicas >= 0, 'replicas must be a number no less than 0');
|
||||||
|
|
||||||
@ -642,11 +650,12 @@ class Data extends EventEmitter {
|
|||||||
|
|
||||||
this._dockerCompose.scale({
|
this._dockerCompose.scale({
|
||||||
projectName: ctx.deploymentGroup.name,
|
projectName: ctx.deploymentGroup.name,
|
||||||
environment,
|
environment: ctx.manifest.environment,
|
||||||
|
files: this.fromKeyValueToDict(ctx.manifest.files),
|
||||||
|
manifest: ctx.manifest.raw,
|
||||||
services: {
|
services: {
|
||||||
[ctx.service.name]: replicas
|
[ctx.service.name]: replicas
|
||||||
},
|
}
|
||||||
manifest: ctx.manifest.raw
|
|
||||||
}, handleTriggeredScale);
|
}, handleTriggeredScale);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@ -1154,6 +1163,7 @@ class Data extends EventEmitter {
|
|||||||
this._dockerCompose.provision({
|
this._dockerCompose.provision({
|
||||||
projectName: ctx.currentDeploymentGroup.name,
|
projectName: ctx.currentDeploymentGroup.name,
|
||||||
environment: clientManifest.environment,
|
environment: clientManifest.environment,
|
||||||
|
files: this.fromKeyValueToDict(clientManifest.files),
|
||||||
manifest: ctx.newManifest.raw
|
manifest: ctx.newManifest.raw
|
||||||
}, handleProvisionResponse);
|
}, handleProvisionResponse);
|
||||||
});
|
});
|
||||||
@ -2007,7 +2017,7 @@ class Data extends EventEmitter {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
getConfig ({deploymentGroupName = '', type = '', format = '', environment = '', raw = '' }, cb) {
|
getConfig ({deploymentGroupName = '', type = '', format = '', environment = '', files = [], raw = '' }, cb) {
|
||||||
if (type.toUpperCase() !== 'COMPOSE') {
|
if (type.toUpperCase() !== 'COMPOSE') {
|
||||||
return cb(new Error('"COMPOSE" is the only `type` supported'));
|
return cb(new Error('"COMPOSE" is the only `type` supported'));
|
||||||
}
|
}
|
||||||
@ -2021,6 +2031,7 @@ class Data extends EventEmitter {
|
|||||||
this._dockerCompose.config({
|
this._dockerCompose.config({
|
||||||
projectName: deploymentGroupName,
|
projectName: deploymentGroupName,
|
||||||
environment,
|
environment,
|
||||||
|
files: this.fromKeyValueToDict(files),
|
||||||
manifest: raw
|
manifest: raw
|
||||||
}, (err, config = {}) => {
|
}, (err, config = {}) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
const Yamljs = require('yamljs');
|
const Yamljs = require('yamljs');
|
||||||
const ParamCase = require('param-case');
|
const ParamCase = require('param-case');
|
||||||
|
const Uuid = require('uuid/v4');
|
||||||
|
|
||||||
const clean = (v) => {
|
const clean = (v) => {
|
||||||
return JSON.parse(JSON.stringify(v));
|
return JSON.parse(JSON.stringify(v));
|
||||||
@ -124,16 +125,21 @@ exports.fromVersion = function (version) {
|
|||||||
|
|
||||||
|
|
||||||
exports.toManifest = function (clientManifest) {
|
exports.toManifest = function (clientManifest) {
|
||||||
return {
|
return clean({
|
||||||
id: clientManifest.id,
|
id: clientManifest.id,
|
||||||
deployment_group_id: clientManifest.deploymentGroupId,
|
deployment_group_id: clientManifest.deploymentGroupId,
|
||||||
created: clientManifest.created || Date.now(),
|
created: clientManifest.created || Date.now(),
|
||||||
type: clientManifest.type,
|
type: clientManifest.type,
|
||||||
format: clientManifest.format,
|
format: clientManifest.format,
|
||||||
environment: clientManifest.environment,
|
environment: clientManifest.environment,
|
||||||
|
files: clientManifest.files ? clientManifest.files.map((m) => {
|
||||||
|
return Object.assign({}, m, {
|
||||||
|
id: m.id || Uuid()
|
||||||
|
});
|
||||||
|
}) : undefined,
|
||||||
raw: clientManifest.raw,
|
raw: clientManifest.raw,
|
||||||
json: clientManifest.json || Yamljs.parse(clientManifest.raw)
|
json: clientManifest.json || Yamljs.parse(clientManifest.raw)
|
||||||
};
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.fromManifest = function (manifest) {
|
exports.fromManifest = function (manifest) {
|
||||||
@ -144,6 +150,7 @@ exports.fromManifest = function (manifest) {
|
|||||||
type: manifest.type,
|
type: manifest.type,
|
||||||
format: manifest.format,
|
format: manifest.format,
|
||||||
environment: manifest.environment,
|
environment: manifest.environment,
|
||||||
|
files: manifest.files,
|
||||||
raw: manifest.raw,
|
raw: manifest.raw,
|
||||||
json: manifest.json
|
json: manifest.json
|
||||||
};
|
};
|
||||||
|
@ -383,7 +383,7 @@ module.exports = class ContainerPilotWatcher extends Events {
|
|||||||
}));
|
}));
|
||||||
})));
|
})));
|
||||||
|
|
||||||
if (!deviantJobNames) {
|
if (!deviantJobNames || !deviantJobNames.length) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user