Skip to content

Commit eaa6397

Browse files
Add waiverdb api
Signed-off-by: Andrei Stepanov <[email protected]>
1 parent d75c6f1 commit eaa6397

File tree

4 files changed

+22
-23
lines changed

4 files changed

+22
-23
lines changed

Diff for: dev-server.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"watch": ["src"],
33
"ext": ".ts,.js",
44
"ignore": [],
5-
"exec": "DEBUG=${DEBUG:-osci:*} source ./env.sh && ts-node ./src/server.ts | ./node_modules/.bin/pino-pretty"
5+
"exec": "DEBUG=${DEBUG:-osci:*} source ./env-devel.sh && ts-node ./src/server.ts | ./node_modules/.bin/pino-pretty"
66
}

Diff for: src/cfg.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -326,8 +326,8 @@ if (cfg.waiverdb?.url) {
326326
about: {
327327
api_url: new URL('/api/v1.0/about', cfg.waiverdb.url),
328328
},
329-
config: {
330-
api_url: new URL('/api/v1.0/config', cfg.waiverdb.url),
329+
permissions: {
330+
api_url: new URL('/api/v1.0/permissions', cfg.waiverdb.url),
331331
},
332332
};
333333
}

Diff for: src/schema/root_query_type.ts

+7-14
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ const {
4646

4747
import {
4848
WaiverDBInfoType,
49-
WaiverDBConfigType,
5049
WaiverDBWaiverType,
5150
WaiverDBWaiversType,
51+
WaiverDBPermissionsType,
5252
} from './waiverdb_types';
5353

5454
import {
@@ -241,22 +241,15 @@ const RootQuery = new GraphQLObjectType({
241241
.then((x) => x.data);
242242
},
243243
},
244-
waiver_db_config: {
245-
type: WaiverDBConfigType,
244+
waiver_db_permissions: {
245+
type: WaiverDBPermissionsType,
246246
resolve() {
247247
if (!waiverdb_cfg?.url) {
248248
throw new Error('Waiverdb is not configured.');
249249
}
250-
return axios.get(waiverdb_cfg.config.api_url.toString()).then((x) => {
251-
const { superusers } = x.data;
252-
const permission_mapping = _.values(
253-
_.mapValues(x.data.permission_mapping, (value, key) => {
254-
value['testcase_regex'] = key;
255-
return value;
256-
})
257-
);
258-
return { superusers, permission_mapping };
259-
});
250+
return axios
251+
.get(waiverdb_cfg.permissions.api_url.toString())
252+
.then((response) => response.data);
260253
},
261254
},
262255
waiver_db_waivers: {
@@ -297,7 +290,7 @@ const RootQuery = new GraphQLObjectType({
297290
*/
298291
include_obsolete: { type: GraphQLBoolean },
299292
},
300-
resolve(parentValue, args) {
293+
resolve(_parentValue, args) {
301294
if (!waiverdb_cfg?.url) {
302295
throw new Error('Waiverdb is not configured.');
303296
}

Diff for: src/schema/waiverdb_types.ts

+12-6
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,22 @@ export const WaiverDBConfigPermissionType = new GraphQLObjectType({
4545
}),
4646
});
4747

48-
export const WaiverDBConfigType = new GraphQLObjectType({
49-
name: 'WaiverDBConfigType',
48+
const WaiverDBPermissionItemType = new GraphQLObjectType({
49+
name: 'WaiverDBPermissionsItemType',
5050
fields: () => ({
51-
superusers: { type: new GraphQLList(GraphQLString) },
52-
permission_mapping: {
53-
type: new GraphQLList(WaiverDBConfigPermissionType),
54-
},
51+
name: { type: GraphQLString },
52+
description: { type: GraphQLString },
53+
maintainers: { type: new GraphQLList(GraphQLString) },
54+
testcases: { type: new GraphQLList(GraphQLString) },
55+
users: { type: new GraphQLList(GraphQLString) },
56+
groups: { type: new GraphQLList(GraphQLString) },
5557
}),
5658
});
5759

60+
export const WaiverDBPermissionsType = new GraphQLList(
61+
WaiverDBPermissionItemType
62+
);
63+
5864
/**
5965
* https://waiverdb/api/v1.0/waivers/
6066
*/

0 commit comments

Comments
 (0)