Skip to content

Commit

Permalink
0.1.7
Browse files Browse the repository at this point in the history
  • Loading branch information
sebt3 committed Mar 6, 2024
1 parent 20068cb commit d838cb9
Show file tree
Hide file tree
Showing 156 changed files with 54,064 additions and 15,952 deletions.
1 change: 1 addition & 0 deletions back/dev.ts
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env -S npx tsx
import { server, setup, app, httpServer } from './main.js'
import { createServer as createViteServer } from 'vite'

Expand Down
4 changes: 3 additions & 1 deletion back/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ const typeDefs = gqlWrapper(
importGraphQL('jaegertracing.graphql'),
importGraphQL('cattle.graphql'),
importGraphQL('cilium.graphql'),
importGraphQL('namecheap.graphql'),
importGraphQL('tekton.graphql'),
);

interface MyContext {
Expand All @@ -58,7 +60,7 @@ export function setup() {
app.use(
'/graphql',
cors<cors.CorsRequest>(),
express.json(),
express.json({limit: '25mb'}),
expressMiddleware(server, {
context: async ({ req }) => ({ token: req.headers.token }),
}),
Expand Down
8 changes: 8 additions & 0 deletions back/resolvers/core/Advice.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export const mutations = {
};
export const lists = {
};
export const queries = {
};
export const resolvers = {
};
8 changes: 8 additions & 0 deletions back/resolvers/core/Problem.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export const mutations = {
};
export const lists = {
};
export const queries = {
};
export const resolvers = {
};
29 changes: 22 additions & 7 deletions back/resolvers/k8slibs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,10 @@ export const cache = new NodeCache({ stdTTL: 2, useClones: false, deleteOnExpire
if (process.env['NODE_ENV']=='dev') kc.loadFromDefault();
else kc.loadFromCluster();
export function getMetaNS(args: object) {
return {
namespace: args['namespace'],
name: args['name'],
}
return args['metadata']
}
export function getMeta(args: object) {
return {
name: args['name'],
}
return args['metadata']
}

export function getByPath(obj, path) {
Expand All @@ -30,6 +25,26 @@ function addByPath(target,path,data) {
path.split("/").slice(0,-1).reduce((res,cur) => {if (res[cur]==undefined) res[cur]={};return res[cur]},target)[path.split("/").slice(-1)[0]] = data
}

export async function applyHaving(obj,args, resolvers) {
if (args['params']==null||args['params']==undefined||typeof args['params']!=='object'||((args['params']['havingAny']==null||args['params']['havingAny']==undefined||!Array.isArray(args['params']['havingAny'])&&(args['params']['havingAll']==null||args['params']['havingAll']==undefined||!Array.isArray(args['params']['havingAll'])))))
return true;
let ret = true;
if (args['params']['havingAny']!=null&&args['params']['havingAny']!=undefined&&Array.isArray(args['params']['havingAny'])) {
ret = args['params']['havingAny'].reduce(async (res,cur)=>{
if (typeof resolvers[cur['resolver']] != 'function') return res;
const content=await resolvers[cur['resolver']](obj,{...args, filters: cur['filters']})
return res||Array.isArray(content)
}, false)
//if (ret) console.log('applyHaving', obj)
}
if (args['params']['havingAll']!=null&&args['params']['havingAll']!=undefined&&Array.isArray(args['params']['havingAll'])) {
ret = ret && args['params']['havingAll'].reduce(async (res,cur)=>{
if (typeof resolvers[cur['resolver']] != 'function') return false;
return res&&Array.isArray(await resolvers[cur['resolver']](obj,{...args, filters: cur['filters']}))
}, true)
}
return ret;
}
export function applyFilter(obj,args) {
if (args['params']==null||args['params']==undefined||typeof args['params']!=='object'||args['params']['filters']==null||args['params']['filters']==undefined||!Array.isArray(args['params']['filters']))
return true;
Expand Down
35 changes: 32 additions & 3 deletions back/schema/core.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,34 @@ input ExcludeInclude {
path: String!
include: Boolean
}
input Having {
resolver: String!
filters: [Filter!]
}
input queryParameters {
filters: [Filter!]
excludes: [ExcludeInclude!]
havingAny: [Having!]
havingAll: [Having!]
maxLines: Int
}
input metadataMore {
labels: [Label!]
annotations: [Label!]
input ownerReferenceInput {
apiVersion: String!
blockOwnerDeletion: Boolean
controller: Boolean
kind: String!
name: String!
uid: String!
}
input metadataInput {
name: String!
namespace: String
annotations: JSONObject
labels: JSONObject
creationTimestamp: String
ownerReferences: [ownerReferenceInput]
resourceVersion: String
uid: String
}
type ownerReference {
apiVersion: String!
Expand Down Expand Up @@ -106,6 +126,15 @@ type coreEvent {
reportingComponent: String
reportingInstance: String
}
type coreProblem {
source: String
description: String
}
type coreAdvice {
source: String
reason: String
description: String
}
type coreLog {
lines: [String]!
}
Expand Down
1,464 changes: 1,059 additions & 405 deletions data/certmanager.json

Large diffs are not rendered by default.

Loading

0 comments on commit d838cb9

Please sign in to comment.