bug(portal-data): query by deployment slug works
This commit is contained in:
parent
1cc2330b22
commit
5220139fdb
@ -1430,6 +1430,10 @@ clap@^1.0.9:
|
|||||||
dependencies:
|
dependencies:
|
||||||
chalk "^1.1.3"
|
chalk "^1.1.3"
|
||||||
|
|
||||||
|
classnames@^2.2.5:
|
||||||
|
version "2.2.5"
|
||||||
|
resolved "https://registry.yarnpkg.com/classnames/-/classnames-2.2.5.tgz#fb3801d453467649ef3603c7d61a02bd129bde6d"
|
||||||
|
|
||||||
clean-css@4.1.x:
|
clean-css@4.1.x:
|
||||||
version "4.1.3"
|
version "4.1.3"
|
||||||
resolved "https://registry.yarnpkg.com/clean-css/-/clean-css-4.1.3.tgz#07cfe8980edb20d455ddc23aadcf1e04c6e509ce"
|
resolved "https://registry.yarnpkg.com/clean-css/-/clean-css-4.1.3.tgz#07cfe8980edb20d455ddc23aadcf1e04c6e509ce"
|
||||||
@ -1497,6 +1501,10 @@ code-point-at@^1.0.0:
|
|||||||
version "1.1.0"
|
version "1.1.0"
|
||||||
resolved "https://registry.yarnpkg.com/code-point-at/-/code-point-at-1.1.0.tgz#0d070b4d043a5bea33a2f1a40e2edb3d9a4ccf77"
|
resolved "https://registry.yarnpkg.com/code-point-at/-/code-point-at-1.1.0.tgz#0d070b4d043a5bea33a2f1a40e2edb3d9a4ccf77"
|
||||||
|
|
||||||
|
codemirror@^5.18.2:
|
||||||
|
version "5.26.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/codemirror/-/codemirror-5.26.0.tgz#bcbee86816ed123870c260461c2b5c40b68746e5"
|
||||||
|
|
||||||
color-convert@^1.0.0, color-convert@^1.3.0:
|
color-convert@^1.0.0, color-convert@^1.3.0:
|
||||||
version "1.9.0"
|
version "1.9.0"
|
||||||
resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.0.tgz#1accf97dd739b983bf994d56fec8f95853641b7a"
|
resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.0.tgz#1accf97dd739b983bf994d56fec8f95853641b7a"
|
||||||
@ -1721,7 +1729,7 @@ create-hmac@^1.1.0, create-hmac@^1.1.2, create-hmac@^1.1.4:
|
|||||||
safe-buffer "^5.0.1"
|
safe-buffer "^5.0.1"
|
||||||
sha.js "^2.4.8"
|
sha.js "^2.4.8"
|
||||||
|
|
||||||
create-react-class@^15.5.3:
|
create-react-class@^15.5.1, create-react-class@^15.5.3:
|
||||||
version "15.5.3"
|
version "15.5.3"
|
||||||
resolved "https://registry.yarnpkg.com/create-react-class/-/create-react-class-15.5.3.tgz#fb0f7cae79339e9a179e194ef466efa3923820fe"
|
resolved "https://registry.yarnpkg.com/create-react-class/-/create-react-class-15.5.3.tgz#fb0f7cae79339e9a179e194ef466efa3923820fe"
|
||||||
dependencies:
|
dependencies:
|
||||||
@ -4176,6 +4184,10 @@ lodash.cond@^4.3.0:
|
|||||||
version "4.5.2"
|
version "4.5.2"
|
||||||
resolved "https://registry.yarnpkg.com/lodash.cond/-/lodash.cond-4.5.2.tgz#f471a1da486be60f6ab955d17115523dd1d255d5"
|
resolved "https://registry.yarnpkg.com/lodash.cond/-/lodash.cond-4.5.2.tgz#f471a1da486be60f6ab955d17115523dd1d255d5"
|
||||||
|
|
||||||
|
lodash.debounce@^4.0.8:
|
||||||
|
version "4.0.8"
|
||||||
|
resolved "https://registry.yarnpkg.com/lodash.debounce/-/lodash.debounce-4.0.8.tgz#82d79bff30a67c4005ffd5e2515300ad9ca4d7af"
|
||||||
|
|
||||||
lodash.defaults@^4.2.0:
|
lodash.defaults@^4.2.0:
|
||||||
version "4.2.0"
|
version "4.2.0"
|
||||||
resolved "https://registry.yarnpkg.com/lodash.defaults/-/lodash.defaults-4.2.0.tgz#d09178716ffea4dde9e5fb7b37f6f0802274580c"
|
resolved "https://registry.yarnpkg.com/lodash.defaults/-/lodash.defaults-4.2.0.tgz#d09178716ffea4dde9e5fb7b37f6f0802274580c"
|
||||||
@ -4188,7 +4200,7 @@ lodash.isarraylike@^4.2.0:
|
|||||||
version "4.2.0"
|
version "4.2.0"
|
||||||
resolved "https://registry.yarnpkg.com/lodash.isarraylike/-/lodash.isarraylike-4.2.0.tgz#4623310ab318804b667ddc3619058137559400c4"
|
resolved "https://registry.yarnpkg.com/lodash.isarraylike/-/lodash.isarraylike-4.2.0.tgz#4623310ab318804b667ddc3619058137559400c4"
|
||||||
|
|
||||||
lodash.isequal@^4.1.1:
|
lodash.isequal@^4.1.1, lodash.isequal@^4.5.0:
|
||||||
version "4.5.0"
|
version "4.5.0"
|
||||||
resolved "https://registry.yarnpkg.com/lodash.isequal/-/lodash.isequal-4.5.0.tgz#415c4478f2bcc30120c22ce10ed3226f7d3e18e0"
|
resolved "https://registry.yarnpkg.com/lodash.isequal/-/lodash.isequal-4.5.0.tgz#415c4478f2bcc30120c22ce10ed3226f7d3e18e0"
|
||||||
|
|
||||||
@ -4603,10 +4615,6 @@ npmlog@^4.0.2:
|
|||||||
gauge "~2.7.3"
|
gauge "~2.7.3"
|
||||||
set-blocking "~2.0.0"
|
set-blocking "~2.0.0"
|
||||||
|
|
||||||
nprogress@^0.2.0:
|
|
||||||
version "0.2.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/nprogress/-/nprogress-0.2.0.tgz#cb8f34c53213d895723fcbab907e9422adbcafb1"
|
|
||||||
|
|
||||||
nth-check@~1.0.1:
|
nth-check@~1.0.1:
|
||||||
version "1.0.1"
|
version "1.0.1"
|
||||||
resolved "https://registry.yarnpkg.com/nth-check/-/nth-check-1.0.1.tgz#9929acdf628fc2c41098deab82ac580cf149aae4"
|
resolved "https://registry.yarnpkg.com/nth-check/-/nth-check-1.0.1.tgz#9929acdf628fc2c41098deab82ac580cf149aae4"
|
||||||
@ -5416,6 +5424,17 @@ react-apollo@^1.2.0:
|
|||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
react-dom "0.14.x || 15.* || ^15.0.0 || ^16.0.0-alpha"
|
react-dom "0.14.x || 15.* || ^15.0.0 || ^16.0.0-alpha"
|
||||||
|
|
||||||
|
react-codemirror@^1.0.0:
|
||||||
|
version "1.0.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/react-codemirror/-/react-codemirror-1.0.0.tgz#91467b53b1f5d80d916a2fd0b4c7adb85a9001ba"
|
||||||
|
dependencies:
|
||||||
|
classnames "^2.2.5"
|
||||||
|
codemirror "^5.18.2"
|
||||||
|
create-react-class "^15.5.1"
|
||||||
|
lodash.debounce "^4.0.8"
|
||||||
|
lodash.isequal "^4.5.0"
|
||||||
|
prop-types "^15.5.4"
|
||||||
|
|
||||||
react-dev-utils@^3.0.0:
|
react-dev-utils@^3.0.0:
|
||||||
version "3.0.0"
|
version "3.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/react-dev-utils/-/react-dev-utils-3.0.0.tgz#3677f37718ba0cae892ba9c01fe54d1622e6ef7c"
|
resolved "https://registry.yarnpkg.com/react-dev-utils/-/react-dev-utils-3.0.0.tgz#3677f37718ba0cae892ba9c01fe54d1622e6ef7c"
|
||||||
|
@ -20,7 +20,7 @@ type User {
|
|||||||
type DeploymentGroup {
|
type DeploymentGroup {
|
||||||
id: ID!
|
id: ID!
|
||||||
name: String!
|
name: String!
|
||||||
slug: String
|
slug: String!
|
||||||
services(name: String, slug: String, parentId: ID): [Service]
|
services(name: String, slug: String, parentId: ID): [Service]
|
||||||
version: Version
|
version: Version
|
||||||
history: [Version]
|
history: [Version]
|
||||||
@ -71,7 +71,7 @@ enum ManifestFormat {
|
|||||||
|
|
||||||
type Manifest {
|
type Manifest {
|
||||||
id: ID!
|
id: ID!
|
||||||
created: Date
|
created: Float
|
||||||
type: ManifestType!
|
type: ManifestType!
|
||||||
format: ManifestFormat!
|
format: ManifestFormat!
|
||||||
raw: String!
|
raw: String!
|
||||||
@ -85,8 +85,8 @@ type Service {
|
|||||||
name: String! # human readable name
|
name: String! # human readable name
|
||||||
slug: String!
|
slug: String!
|
||||||
instances(name: String, machineId: ID, status: InstanceStatus): [Instance]!
|
instances(name: String, machineId: ID, status: InstanceStatus): [Instance]!
|
||||||
# metrics: [MetricType]!
|
# metrics: [MetricType]
|
||||||
currentMetrics: [CurrentMetric]!
|
currentMetrics: [CurrentMetric]
|
||||||
connections: [String!] # list of serviceIds
|
connections: [String!] # list of serviceIds
|
||||||
parent: ID # parent service id
|
parent: ID # parent service id
|
||||||
package: Package! # we don't have this in current mock data,
|
package: Package! # we don't have this in current mock data,
|
||||||
|
23
packages/portal-api/bootstrap-data.js
vendored
23
packages/portal-api/bootstrap-data.js
vendored
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
const Data = require('portal-data');
|
const Data = require('portal-data');
|
||||||
|
|
||||||
const data = new Data();
|
|
||||||
|
|
||||||
const ifError = function (err) {
|
const ifError = function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
@ -11,7 +10,10 @@ const ifError = function (err) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
data.connect(() => {
|
const bootstrap = function () {
|
||||||
|
const data = new Data();
|
||||||
|
|
||||||
|
data.connect(() => {
|
||||||
data.createDatacenter({ region: 'us-sw', name: 'us-sw' }, (err, datacenter) => {
|
data.createDatacenter({ region: 'us-sw', name: 'us-sw' }, (err, datacenter) => {
|
||||||
ifError(err);
|
ifError(err);
|
||||||
|
|
||||||
@ -23,14 +25,21 @@ data.connect(() => {
|
|||||||
datacenter
|
datacenter
|
||||||
}, (err, portal) => {
|
}, (err, portal) => {
|
||||||
ifError(err);
|
ifError(err);
|
||||||
|
|
||||||
data.createDeploymentGroup({ name: 'test' }, (err) => {
|
|
||||||
ifError(err);
|
|
||||||
|
|
||||||
console.log('data bootstrapped');
|
console.log('data bootstrapped');
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
};
|
||||||
|
|
||||||
|
const main = function () {
|
||||||
|
const dropData = new Data();
|
||||||
|
|
||||||
|
dropData.connect(() => {
|
||||||
|
dropData._db.r.dbDrop('portal').run(dropData._db._connection, () => {
|
||||||
|
bootstrap();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
main();
|
||||||
|
@ -252,15 +252,16 @@ module.exports = class Data extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getDeploymentGroup (query, cb) {
|
getDeploymentGroup (query, cb) {
|
||||||
this._db.deployment_groups.single(query, (err, deploymentGroup) => {
|
this._db.deployment_groups.query(query, (err, deploymentGroups) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
return cb(err);
|
return cb(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!deploymentGroup) {
|
if (!deploymentGroups || !deploymentGroups.length) {
|
||||||
return cb(null, {});
|
return cb(null, {});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const deploymentGroup = deploymentGroups[0];
|
||||||
if (!deploymentGroup.service_ids || !deploymentGroup.service_ids.length) {
|
if (!deploymentGroup.service_ids || !deploymentGroup.service_ids.length) {
|
||||||
return cb(null, Transform.fromDeploymentGroup(deploymentGroup));
|
return cb(null, Transform.fromDeploymentGroup(deploymentGroup));
|
||||||
}
|
}
|
||||||
@ -274,7 +275,7 @@ module.exports = class Data extends EventEmitter {
|
|||||||
return reject(err);
|
return reject(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
resolve(services);
|
resolve(services || []);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@ -711,7 +712,25 @@ module.exports = class Data extends EventEmitter {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_getDeploymentGroupServices (deploymentGroupSlug, cb) {
|
||||||
|
this.getDeploymentGroup({ slug: deploymentGroupSlug }, (err, deploymentGroup) => {
|
||||||
|
if (err) {
|
||||||
|
return cb(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!deploymentGroup) {
|
||||||
|
return cb(null, {});
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.getServices({ deploymentGroupId: deploymentGroup.id }, cb);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
getServices (options, cb) {
|
getServices (options, cb) {
|
||||||
|
if (options.deploymentGroupSlug) {
|
||||||
|
return this._getDeploymentGroupServices(options.deploymentGroupSlug, cb);
|
||||||
|
}
|
||||||
|
|
||||||
const query = {};
|
const query = {};
|
||||||
if (options.ids && options.ids.length) {
|
if (options.ids && options.ids.length) {
|
||||||
query.id = this._db.or(options.ids);
|
query.id = this._db.or(options.ids);
|
||||||
|
@ -37,7 +37,7 @@ exports.fromDeploymentGroup = function (deploymentGroup, services) {
|
|||||||
exports.toDeploymentGroup = function ({ name }) {
|
exports.toDeploymentGroup = function ({ name }) {
|
||||||
return {
|
return {
|
||||||
name,
|
name,
|
||||||
slug: '',
|
slug: name,
|
||||||
services: [],
|
services: [],
|
||||||
version_id: '',
|
version_id: '',
|
||||||
history_version_ids: []
|
history_version_ids: []
|
||||||
@ -63,7 +63,7 @@ exports.fromService = function ({ service, instances, packages }) {
|
|||||||
|
|
||||||
exports.toService = function (clientService) {
|
exports.toService = function (clientService) {
|
||||||
return {
|
return {
|
||||||
version_hash: clientService.hash || '',
|
version_hash: clientService.hash || clientService.name,
|
||||||
deployment_group_id: clientService.deploymentGroupId,
|
deployment_group_id: clientService.deploymentGroupId,
|
||||||
name: clientService.name,
|
name: clientService.name,
|
||||||
slug: clientService.slug || '',
|
slug: clientService.slug || '',
|
||||||
|
Loading…
Reference in New Issue
Block a user