From c28b1f1826015eb18bd0ee55426c10d56c5f86f1 Mon Sep 17 00:00:00 2001 From: Matteo Silvestri Date: Fri, 2 Sep 2022 11:02:44 +0200 Subject: [PATCH] fix tests and add inline doc Signed-off-by: Matteo Silvestri --- .../util/KubernetesContainerRunner.test.ts | 4 ++-- .../src/util/KubernetesContainerRunner.ts | 20 +++++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/packages/backend-common/src/util/KubernetesContainerRunner.test.ts b/packages/backend-common/src/util/KubernetesContainerRunner.test.ts index 11c4017ca8..e218abf960 100644 --- a/packages/backend-common/src/util/KubernetesContainerRunner.test.ts +++ b/packages/backend-common/src/util/KubernetesContainerRunner.test.ts @@ -112,9 +112,9 @@ describeIfKubernetes('KubernetesContainerRunner', () => { }, }; await expect(containerRunner.runContainer(runOptions)).rejects.toThrow( - `Mounted /notWorkdir/app dir should be subdirectories of '${ + `Mounted '/notWorkdir/app' dir should be subdirectories of '${ options!.mountBase!.basePath - }`, + }'`, ); }); diff --git a/packages/backend-common/src/util/KubernetesContainerRunner.ts b/packages/backend-common/src/util/KubernetesContainerRunner.ts index 9ca31fd088..af00351fd1 100644 --- a/packages/backend-common/src/util/KubernetesContainerRunner.ts +++ b/packages/backend-common/src/util/KubernetesContainerRunner.ts @@ -32,11 +32,29 @@ import { import { v4 as uuid } from 'uuid'; import { Request } from 'request'; +/** + * An existing Kubernetes volume that will be used as base for mounts. + * + * Every mount must start with the 'basePath'. + * + * @public + */ export type MountBaseOptions = { volumeName: string; basePath: string; }; +/** + * Options to create a {@link KubernetesContainerRunner} + * + * Kubernetes Jobs will be created on the provided 'namespace' + * and their names will be prefixed with the provided 'name'. + * + * 'podTemplate' defines a Pod template for the Jobs. It has to include + * a volume definition named as the {@link MountBaseOptions} 'volumeName'. + * + * @public + */ export type KubernetesContainerRunnerOptions = { kubeConfig: KubeConfig; name: string; @@ -49,6 +67,8 @@ export type KubernetesContainerRunnerOptions = { /** * A {@link ContainerRunner} for Kubernetes. * + * Runs containers leveraging Jobs on a Kubernetes cluster + * * @public */ export class KubernetesContainerRunner implements ContainerRunner {