Skip to content

Commit

Permalink
chore(mirage): use fake values
Browse files Browse the repository at this point in the history
  • Loading branch information
Thuan Vo committed Aug 22, 2023
1 parent 27765b0 commit ef41a72
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 25 deletions.
2 changes: 1 addition & 1 deletion src/mirage/factories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const targetFactory: FactoryDefinition<any> = Factory.extend({
jvmId: '1234',
annotations: {
platform: { 'io.cryostat.demo': 'this-is-not-real' },
cryostat: { hello: 'world', REALM: 'KubernetesApi' },
cryostat: { hello: 'world', REALM: 'Some Realm' },
},
});

Expand Down
35 changes: 11 additions & 24 deletions src/mirage/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,7 @@ export const startMirage = ({ environment = 'development' } = {}) => {
this.get('api/v1/targets', (schema) => schema.all(Resource.TARGET).models);
this.get('api/v2.1/discovery', (schema) => {
const models = schema.all(Resource.TARGET).models;
const ct = models.filter((t) => t.annotations.cryostat['REALM'] === 'Custom Targets');
const k8s = models.filter((t) => t.annotations.cryostat['REALM'] === 'KubernetesApi');
const realmTypes = models.map((t) => t.annotations.cryostat['REALM']);
return {
meta: {
status: 'OK',
Expand All @@ -142,32 +141,20 @@ export const startMirage = ({ environment = 'development' } = {}) => {
name: 'Universe',
nodeType: 'Universe',
labels: {},
children: [
{
name: 'KubernetesApi',
nodeType: 'Realm',
labels: {},
id: 'KubernetesApi',
children: k8s.map((t) => ({
children: realmTypes.map((r: string) => ({
name: r,
nodeType: 'Realm',
labels: {},
id: r,
children: models
.filter((t) => t.annotations.cryostat['REALM'] === r)
.map((t) => ({
id: t.alias,
name: t.alias,
nodeType: 'JVM',
nodeType: r === 'Custom Targets' ? 'CustomTarget' : 'JVM',
target: t,
})),
},
{
name: 'Custom Targets',
nodeType: 'Realm',
labels: {},
id: 'Custom Targets',
children: ct.map((t) => ({
id: t.alias,
name: t.alias,
nodeType: 'CustomTarget',
target: t,
})),
},
],
})),
},
},
};
Expand Down

0 comments on commit ef41a72

Please sign in to comment.