mirror of
https://github.com/yldio/copilot.git
synced 2024-12-29 05:10:05 +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
|
||||
|
||||
@ -571,7 +579,7 @@ class Data extends EventEmitter {
|
||||
this._listMachines(deploymentGroupName, handleMachinesList);
|
||||
}
|
||||
|
||||
scale ({ serviceId, environment, replicas }, cb) {
|
||||
scale ({ serviceId, replicas }, cb) {
|
||||
Hoek.assert(serviceId, 'service id is required');
|
||||
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({
|
||||
projectName: ctx.deploymentGroup.name,
|
||||
environment,
|
||||
environment: ctx.manifest.environment,
|
||||
files: this.fromKeyValueToDict(ctx.manifest.files),
|
||||
manifest: ctx.manifest.raw,
|
||||
services: {
|
||||
[ctx.service.name]: replicas
|
||||
},
|
||||
manifest: ctx.manifest.raw
|
||||
}
|
||||
}, handleTriggeredScale);
|
||||
});
|
||||
};
|
||||
@ -1154,6 +1163,7 @@ class Data extends EventEmitter {
|
||||
this._dockerCompose.provision({
|
||||
projectName: ctx.currentDeploymentGroup.name,
|
||||
environment: clientManifest.environment,
|
||||
files: this.fromKeyValueToDict(clientManifest.files),
|
||||
manifest: ctx.newManifest.raw
|
||||
}, 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') {
|
||||
return cb(new Error('"COMPOSE" is the only `type` supported'));
|
||||
}
|
||||
@ -2021,6 +2031,7 @@ class Data extends EventEmitter {
|
||||
this._dockerCompose.config({
|
||||
projectName: deploymentGroupName,
|
||||
environment,
|
||||
files: this.fromKeyValueToDict(files),
|
||||
manifest: raw
|
||||
}, (err, config = {}) => {
|
||||
if (err) {
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
const Yamljs = require('yamljs');
|
||||
const ParamCase = require('param-case');
|
||||
const Uuid = require('uuid/v4');
|
||||
|
||||
const clean = (v) => {
|
||||
return JSON.parse(JSON.stringify(v));
|
||||
@ -124,16 +125,21 @@ exports.fromVersion = function (version) {
|
||||
|
||||
|
||||
exports.toManifest = function (clientManifest) {
|
||||
return {
|
||||
return clean({
|
||||
id: clientManifest.id,
|
||||
deployment_group_id: clientManifest.deploymentGroupId,
|
||||
created: clientManifest.created || Date.now(),
|
||||
type: clientManifest.type,
|
||||
format: clientManifest.format,
|
||||
environment: clientManifest.environment,
|
||||
files: clientManifest.files ? clientManifest.files.map((m) => {
|
||||
return Object.assign({}, m, {
|
||||
id: m.id || Uuid()
|
||||
});
|
||||
}) : undefined,
|
||||
raw: clientManifest.raw,
|
||||
json: clientManifest.json || Yamljs.parse(clientManifest.raw)
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
exports.fromManifest = function (manifest) {
|
||||
@ -144,6 +150,7 @@ exports.fromManifest = function (manifest) {
|
||||
type: manifest.type,
|
||||
format: manifest.format,
|
||||
environment: manifest.environment,
|
||||
files: manifest.files,
|
||||
raw: manifest.raw,
|
||||
json: manifest.json
|
||||
};
|
||||
|
@ -383,7 +383,7 @@ module.exports = class ContainerPilotWatcher extends Events {
|
||||
}));
|
||||
})));
|
||||
|
||||
if (!deviantJobNames) {
|
||||
if (!deviantJobNames || !deviantJobNames.length) {
|
||||
return [];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user