1
0
mirror of https://github.com/yldio/copilot.git synced 2024-11-28 14:10:04 +02:00

fix(cp-gql-mock-server): schema compability

This commit is contained in:
Sérgio Ramos 2017-05-31 17:09:06 +01:00
parent 487f3dcc6d
commit ead66d38e6
2 changed files with 38 additions and 41 deletions

View File

@ -1,11 +1,11 @@
{
"datacenter": {
"uuid": "datacenter-uuid",
"id": "datacenter-uuid",
"region": "us-east-1"
},
"portal": {
"user": {
"uuid": "uuid",
"id": "id",
"login": "juditgreskovits",
"firstName": "Judit",
"lastName": "Greskovits",
@ -14,24 +14,24 @@
},
"deploymentGroups": [
{
"uuid": "e0ea0c02-55cc-45fe-8064-3e5176a59401",
"id": "e0ea0c02-55cc-45fe-8064-3e5176a59401",
"slug": "forest-foundation-dev",
"name": "WarpRecords Blog"
},
{
"uuid": "9fcb374d-a267-4c2a-9d9c-ba469b804639",
"id": "9fcb374d-a267-4c2a-9d9c-ba469b804639",
"slug": "forest-foundation-testing",
"name": "Forest Foundation Testing"
},
{
"uuid": "ac2c2498-e865-4ee3-9e26-8c75a81cbe25",
"id": "ac2c2498-e865-4ee3-9e26-8c75a81cbe25",
"slug": "forest-foundation-production",
"name": "Forest Foundation Production"
}
],
"services": [
{
"uuid": "081a792c-47e0-4439-924b-2efa9788ae9e",
"id": "081a792c-47e0-4439-924b-2efa9788ae9e",
"slug": "nginx",
"name": "Nginx",
"deploymentGroup": "e0ea0c02-55cc-45fe-8064-3e5176a59401",
@ -40,7 +40,7 @@
]
},
{
"uuid": "be227788-74f1-4e5b-a85f-b5c71cbae8d8",
"id": "be227788-74f1-4e5b-a85f-b5c71cbae8d8",
"slug": "wordpress",
"name": "Wordpress",
"deploymentGroup": "e0ea0c02-55cc-45fe-8064-3e5176a59401",
@ -51,57 +51,57 @@
]
},
{
"uuid": "6a0eee76-c019-413b-9d5f-44712b55b993",
"id": "6a0eee76-c019-413b-9d5f-44712b55b993",
"slug": "nfs",
"name": "NFS",
"deploymentGroup": "e0ea0c02-55cc-45fe-8064-3e5176a59401"
},
{
"uuid": "6d31aff4-de1e-4042-a983-fbd23d5c530c",
"id": "6d31aff4-de1e-4042-a983-fbd23d5c530c",
"slug": "memcached",
"name": "Memcached",
"deploymentGroup": "e0ea0c02-55cc-45fe-8064-3e5176a59401"
},
{
"uuid": "4ee4103e-1a52-4099-a48e-01588f597c70",
"id": "4ee4103e-1a52-4099-a48e-01588f597c70",
"slug": "percona",
"name": "Percona",
"deploymentGroup": "e0ea0c02-55cc-45fe-8064-3e5176a59401"
},
{
"uuid": "9572d367-c4ae-4fb1-8ad5-f5e3830e7034",
"id": "9572d367-c4ae-4fb1-8ad5-f5e3830e7034",
"slug": "primary",
"name": "Primary",
"parent": "4ee4103e-1a52-4099-a48e-01588f597c70",
"deploymentGroup": "e0ea0c02-55cc-45fe-8064-3e5176a59401"
},
{
"uuid": "c8411ef0-ab39-42cb-a704-d20b170eff31",
"id": "c8411ef0-ab39-42cb-a704-d20b170eff31",
"slug": "secondaries",
"name": "Secondaries",
"parent": "4ee4103e-1a52-4099-a48e-01588f597c70",
"deploymentGroup": "e0ea0c02-55cc-45fe-8064-3e5176a59401"
},
{
"uuid": "97c68055-db88-45c9-ad49-f26da4264777",
"id": "97c68055-db88-45c9-ad49-f26da4264777",
"slug": "consul",
"name": "Consul",
"deploymentGroup": "e0ea0c02-55cc-45fe-8064-3e5176a59401"
},
{
"uuid": "primary-consul",
"id": "primary-consul",
"slug": "consul",
"name": "Consul",
"deploymentGroup": "9fcb374d-a267-4c2a-9d9c-ba469b804639"
},
{
"uuid": "primary-nginx",
"id": "primary-nginx",
"slug": "nginx",
"name": "Nginx",
"deploymentGroup": "9fcb374d-a267-4c2a-9d9c-ba469b804639"
},
{
"uuid": "primary-mongodb",
"id": "primary-mongodb",
"slug": "mongodb",
"name": "MongoDB",
"deploymentGroup": "9fcb374d-a267-4c2a-9d9c-ba469b804639"
@ -109,67 +109,67 @@
],
"instances": [
{
"uuid": "309ecd9f-ac03-474b-aff7-4bd2e743296c",
"id": "309ecd9f-ac03-474b-aff7-4bd2e743296c",
"name": "wordpress_01",
"service": "be227788-74f1-4e5b-a85f-b5c71cbae8d8",
"deploymentGroup": "e0ea0c02-55cc-45fe-8064-3e5176a59401"
},
{
"uuid": "0db6db53-de6f-4378-839e-5d5b452fbaf2",
"id": "0db6db53-de6f-4378-839e-5d5b452fbaf2",
"name": "nfs_01",
"service": "6a0eee76-c019-413b-9d5f-44712b55b993",
"deploymentGroup": "e0ea0c02-55cc-45fe-8064-3e5176a59401"
},
{
"uuid": "250c8a6c-7d02-49a9-8abd-e1c22773041d",
"id": "250c8a6c-7d02-49a9-8abd-e1c22773041d",
"name": "consul",
"service": "97c68055-db88-45c9-ad49-f26da4264777",
"deploymentGroup": "e0ea0c02-55cc-45fe-8064-3e5176a59401"
},
{
"uuid": "2c921f3a-8bc3-4f57-9cd7-789ebae72061",
"id": "2c921f3a-8bc3-4f57-9cd7-789ebae72061",
"name": "memcache_01",
"service": "6d31aff4-de1e-4042-a983-fbd23d5c530c",
"deploymentGroup": "e0ea0c02-55cc-45fe-8064-3e5176a59401"
},
{
"uuid": "68d3046e-8e34-4f5d-a0e5-db3795a250fd",
"id": "68d3046e-8e34-4f5d-a0e5-db3795a250fd",
"name": "memcache_02",
"service": "6d31aff4-de1e-4042-a983-fbd23d5c530c",
"deploymentGroup": "e0ea0c02-55cc-45fe-8064-3e5176a59401"
},
{
"uuid": "2ea99763-3b44-4179-8393-d66d94961051",
"id": "2ea99763-3b44-4179-8393-d66d94961051",
"name": "memcache_03",
"service": "6d31aff4-de1e-4042-a983-fbd23d5c530c",
"deploymentGroup": "e0ea0c02-55cc-45fe-8064-3e5176a59401"
},
{
"uuid": "25f6bc62-63b8-4959-908e-1f6d7ff6341d",
"id": "25f6bc62-63b8-4959-908e-1f6d7ff6341d",
"name": "memcache_04",
"service": "6d31aff4-de1e-4042-a983-fbd23d5c530c",
"deploymentGroup": "e0ea0c02-55cc-45fe-8064-3e5176a59401"
},
{
"uuid": "8be01042-0281-4a77-a357-25979e87bf3d",
"id": "8be01042-0281-4a77-a357-25979e87bf3d",
"name": "memcache_05",
"service": "6d31aff4-de1e-4042-a983-fbd23d5c530c",
"deploymentGroup": "e0ea0c02-55cc-45fe-8064-3e5176a59401"
},
{
"uuid": "3d652e9d-73e8-4a6f-8171-84fa83740662",
"id": "3d652e9d-73e8-4a6f-8171-84fa83740662",
"name": "nginx",
"service": "081a792c-47e0-4439-924b-2efa9788ae9e",
"deploymentGroup": "e0ea0c02-55cc-45fe-8064-3e5176a59401"
},
{
"uuid": "c3ec7633-a02b-4615-86a0-9e6faeaae94b",
"id": "c3ec7633-a02b-4615-86a0-9e6faeaae94b",
"name": "percona-primary",
"service": "4ee4103e-1a52-4099-a48e-01588f597c70",
"deploymentGroup": "e0ea0c02-55cc-45fe-8064-3e5176a59401"
},
{
"uuid": "c2b5fec2-31e2-41a7-b7fc-cd0bb1822e76",
"id": "c2b5fec2-31e2-41a7-b7fc-cd0bb1822e76",
"name": "percona-secondary",
"service": "4ee4103e-1a52-4099-a48e-01588f597c70",
"deploymentGroup": "e0ea0c02-55cc-45fe-8064-3e5176a59401"

View File

@ -13,7 +13,7 @@ const cleanQuery = (q = {}) => JSON.parse(JSON.stringify(q));
const getServiceInstances = s =>
Object.assign({}, s, {
instances: instances.filter(find({ service: s.uuid })).map(s =>
instances: instances.filter(find({ service: s.id })).map(s =>
Object.assign({}, s, {
slug: s.name
})
@ -23,7 +23,7 @@ const getServiceInstances = s =>
const getDeploymentGroupServices = dg =>
Object.assign({}, dg, {
services: services
.filter(find({ deploymentGroup: dg.uuid }))
.filter(find({ deploymentGroup: dg.id }))
.map(getServiceInstances)
});
@ -32,8 +32,7 @@ const getDeploymentGroups = query =>
.filter(find(cleanQuery(query)))
.map(getDeploymentGroupServices);
const getPortal = () =>
Object.assign({}, portal, {
const getPortal = () => Object.assign({}, portal, {
datacenter,
deploymentGroups: getDeploymentGroups()
});
@ -42,11 +41,9 @@ const getServices = query =>
services.filter(find(query)).map(getDeploymentGroupServices);
module.exports = {
Query: {
portal: getPortal,
deploymentGroups: getDeploymentGroups,
deploymentGroup: query => getDeploymentGroups(query).shift(),
services: getServices,
service: query => getServices(query).shift()
}
portal: (options, request, fn) => fn(null, getPortal()),
deploymentGroups: (options, request, fn) => fn(null, getDeploymentGroups(options)),
deploymentGroup: (options, request, fn) => fn(null, getDeploymentGroups(options).shift()),
services: (options, request, fn) => fn(null, getServices()),
service: (options, request, fn) => fn(null, getServices(options).shift())
};