Skip to content

Commit

Permalink
Merge remote-tracking branch 'opendatahub-io/main' into f/ds-projects
Browse files Browse the repository at this point in the history
  • Loading branch information
DaoDaoNoCode committed Sep 12, 2023
2 parents 7d13ac5 + 93705d6 commit 4c11a7e
Show file tree
Hide file tree
Showing 30 changed files with 1,154 additions and 220 deletions.
7 changes: 5 additions & 2 deletions backend/src/routes/api/nb-events/eventUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,18 @@ import { KubeFastifyInstance } from '../../../types';
export const getNotebookEvents = async (
fastify: KubeFastifyInstance,
namespace: string,
podUID: string,
notebookName: string,
podUID: string | undefined,
): Promise<V1Event[]> => {
return fastify.kube.coreV1Api
.listNamespacedEvent(
namespace,
undefined,
undefined,
undefined,
`involvedObject.kind=Pod,involvedObject.uid=${podUID}`,
podUID
? `involvedObject.kind=Pod,involvedObject.uid=${podUID}`
: `involvedObject.kind=StatefulSet,involvedObject.name=${notebookName}`,
)
.then((res) => {
const body = res.body as V1EventList;
Expand Down
35 changes: 16 additions & 19 deletions backend/src/routes/api/nb-events/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,21 @@ import { getNotebookEvents } from './eventUtils';
import { secureRoute } from '../../../utils/route-security';

export default async (fastify: FastifyInstance): Promise<void> => {
fastify.get(
'/:namespace/:podUID',
secureRoute(fastify)(
async (
request: FastifyRequest<{
Params: {
namespace: string;
podUID: string;
};
Querystring: {
// TODO: Support server side filtering
from?: string;
};
}>,
) => {
const { namespace, podUID } = request.params;
return getNotebookEvents(fastify, namespace, podUID);
},
),
const routeHandler = secureRoute(fastify)(
async (
request: FastifyRequest<{
Params: {
namespace: string;
notebookName: string;
podUID: string | undefined;
};
}>,
) => {
const { namespace, notebookName, podUID } = request.params;
return getNotebookEvents(fastify, namespace, notebookName, podUID);
},
);

fastify.get('/:namespace/:notebookName', routeHandler);
fastify.get('/:namespace/:notebookName/:podUID', routeHandler);
};
Loading

0 comments on commit 4c11a7e

Please sign in to comment.