mirror of
https://github.com/yldio/copilot.git
synced 2024-12-29 05:10:05 +02:00
feat(portal-data): add config() mutation
This commit is contained in:
parent
5fe14a7c5a
commit
53cd13b561
@ -8,7 +8,7 @@ const Hoek = require('hoek');
|
||||
const Penseur = require('penseur');
|
||||
const VAsync = require('vasync');
|
||||
const Transform = require('./transform');
|
||||
|
||||
const Uuid = require('uuid/v4');
|
||||
|
||||
const internals = {
|
||||
defaults: {
|
||||
@ -1284,4 +1284,50 @@ module.exports = class Data extends EventEmitter {
|
||||
cb(null, dbPackages ? dbPackages.map(Transform.fromPackage) : []);
|
||||
});
|
||||
}
|
||||
|
||||
config ({deploymentGroupName = '', type = '', format = '', raw = '' }, cb) {
|
||||
if (type.toUpperCase() !== 'COMPOSE') {
|
||||
return cb(new Error('"COMPOSE" is the only `type` supported'));
|
||||
}
|
||||
|
||||
if (format.toUpperCase() !== 'YAML') {
|
||||
return cb(new Error('"YAML" is the only `format` supported'));
|
||||
}
|
||||
|
||||
let isFinished = false;
|
||||
|
||||
this._dockerCompose.config({
|
||||
projectName: deploymentGroupName,
|
||||
manifest: raw
|
||||
}, (err, config = {}) => {
|
||||
if (err) {
|
||||
return cb(err);
|
||||
}
|
||||
|
||||
if (isFinished) {
|
||||
return;
|
||||
}
|
||||
|
||||
isFinished = true;
|
||||
|
||||
const { services } = config;
|
||||
|
||||
if (!services || !Object.keys(services).length) {
|
||||
return cb(null, []);
|
||||
}
|
||||
|
||||
cb(null, Object.keys(services).reduce((acc, serviceName) => {
|
||||
return acc.concat([{
|
||||
id: Uuid(),
|
||||
hash: Uuid(),
|
||||
name: serviceName,
|
||||
slug: ParamCase(serviceName),
|
||||
instances: [],
|
||||
package: {},
|
||||
active: true,
|
||||
image: services[serviceName].image
|
||||
}]);
|
||||
}, []));
|
||||
});
|
||||
}
|
||||
};
|
||||
|
@ -21,6 +21,7 @@
|
||||
"hoek": "^4.1.1",
|
||||
"param-case": "^2.1.1",
|
||||
"penseur": "^7.12.3",
|
||||
"uuid": "^3.1.0",
|
||||
"vasync": "^1.6.4",
|
||||
"yamljs": "^0.2.10"
|
||||
},
|
||||
|
26
yarn.lock
26
yarn.lock
@ -216,8 +216,8 @@ anymatch@^1.3.0:
|
||||
micromatch "^2.1.5"
|
||||
|
||||
apollo-client@^1.4.0:
|
||||
version "1.4.2"
|
||||
resolved "https://registry.yarnpkg.com/apollo-client/-/apollo-client-1.4.2.tgz#3d49d19aefa0baf90edee5401a358e433a6e624f"
|
||||
version "1.5.0"
|
||||
resolved "https://registry.yarnpkg.com/apollo-client/-/apollo-client-1.5.0.tgz#c0ce752f2fe1945dca2eaaa62c7907fdde384563"
|
||||
dependencies:
|
||||
graphql "^0.10.0"
|
||||
graphql-anywhere "^3.0.1"
|
||||
@ -2019,8 +2019,8 @@ code@4.1.x, code@^4.1.0:
|
||||
hoek "4.x.x"
|
||||
|
||||
codemirror@^5.18.2:
|
||||
version "5.27.0"
|
||||
resolved "https://registry.yarnpkg.com/codemirror/-/codemirror-5.27.0.tgz#0c72f70c321a7d494fd8db1976698c249c985eb3"
|
||||
version "5.27.2"
|
||||
resolved "https://registry.yarnpkg.com/codemirror/-/codemirror-5.27.2.tgz#a292d42f079d5b98c68c3146fab99844f3d8776c"
|
||||
|
||||
coleman-liau@^1.0.0:
|
||||
version "1.0.0"
|
||||
@ -5196,8 +5196,8 @@ jest-snapshot@^20.0.3:
|
||||
pretty-format "^20.0.3"
|
||||
|
||||
jest-styled-components@^3.0.2:
|
||||
version "3.1.2"
|
||||
resolved "https://registry.yarnpkg.com/jest-styled-components/-/jest-styled-components-3.1.2.tgz#4e1a1da604824c7f31507e80c43e88a2d8d8c4c9"
|
||||
version "3.1.3"
|
||||
resolved "https://registry.yarnpkg.com/jest-styled-components/-/jest-styled-components-3.1.3.tgz#eba50074b426e36fd2be99187dffa4b5569eab00"
|
||||
dependencies:
|
||||
css "^2.2.1"
|
||||
|
||||
@ -8075,17 +8075,13 @@ safe-buffer@^5.0.1, safe-buffer@^5.1.0, safe-buffer@~5.1.0:
|
||||
version "5.1.1"
|
||||
resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.1.tgz#893312af69b2123def71f57889001671eeb2c853"
|
||||
|
||||
safe-buffer@~5.0.1:
|
||||
version "5.0.1"
|
||||
resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.0.1.tgz#d263ca54696cd8a306b5ca6551e92de57918fbe7"
|
||||
|
||||
safe-json-stringify@~1:
|
||||
version "1.0.4"
|
||||
resolved "https://registry.yarnpkg.com/safe-json-stringify/-/safe-json-stringify-1.0.4.tgz#81a098f447e4bbc3ff3312a243521bc060ef5911"
|
||||
|
||||
sax@~1.2.1:
|
||||
version "1.2.2"
|
||||
resolved "https://registry.yarnpkg.com/sax/-/sax-1.2.2.tgz#fd8631a23bc7826bef5d871bdb87378c95647828"
|
||||
version "1.2.4"
|
||||
resolved "https://registry.yarnpkg.com/sax/-/sax-1.2.4.tgz#2816234e2378bddc4e5354fab5caa895df7100d9"
|
||||
|
||||
seedrandom@2.4.x:
|
||||
version "2.4.3"
|
||||
@ -8516,10 +8512,10 @@ string_decoder@^0.10.25, string_decoder@~0.10.x:
|
||||
resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-0.10.31.tgz#62e203bc41766c6c28c9fc84301dab1c5310fa94"
|
||||
|
||||
string_decoder@~1.0.0:
|
||||
version "1.0.2"
|
||||
resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.0.2.tgz#b29e1f4e1125fa97a10382b8a533737b7491e179"
|
||||
version "1.0.3"
|
||||
resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.0.3.tgz#0fc67d7c141825de94282dd536bec6b9bce860ab"
|
||||
dependencies:
|
||||
safe-buffer "~5.0.1"
|
||||
safe-buffer "~5.1.0"
|
||||
|
||||
stringify-entities@^1.0.1:
|
||||
version "1.3.1"
|
||||
|
Loading…
Reference in New Issue
Block a user