From 8ce8bf12ac0c640478aad710260989b9cb0a754d Mon Sep 17 00:00:00 2001 From: "coderabbitai[bot]" <136622811+coderabbitai[bot]@users.noreply.github.com> Date: Mon, 2 Jun 2025 12:24:30 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=9D=20Add=20docstrings=20to=20`feat/sw?= =?UTF-8?q?itch-to-k8s`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Docstrings generation was requested by @coodos. * https://github.com/MetaState-Prototype-Project/prototype/pull/179#issuecomment-2929410989 The following files were modified: * `infrastructure/evault-provisioner/src/templates/evault.nomad.ts` --- .../src/templates/evault.nomad.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/infrastructure/evault-provisioner/src/templates/evault.nomad.ts b/infrastructure/evault-provisioner/src/templates/evault.nomad.ts index 2a4f3557..0e68c439 100644 --- a/infrastructure/evault-provisioner/src/templates/evault.nomad.ts +++ b/infrastructure/evault-provisioner/src/templates/evault.nomad.ts @@ -3,6 +3,12 @@ import * as k8s from '@kubernetes/client-node'; import { execSync } from "child_process"; import { json } from "express"; +/** + * Generates a cryptographically secure random alphanumeric password of the specified length. + * + * @param length - The desired length of the generated password. Defaults to 16. + * @returns A random password consisting of uppercase letters, lowercase letters, and digits. + */ export function generatePassword(length = 16): string { const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; @@ -19,6 +25,17 @@ export function generatePassword(length = 16): string { return result; } +/** + * Provisions an eVault environment in a dedicated Kubernetes namespace and returns its accessible URL. + * + * Creates a namespace, persistent volume claims, a deployment with Neo4j and eVault containers, and a LoadBalancer service. The Neo4j password is derived by hashing the domain part of the provided {@link w3id}. The function determines the service endpoint using the LoadBalancer IP/hostname, node IP and NodePort, or Minikube IP as a fallback. + * + * @param w3id - The W3ID identifier, used to derive the namespace and database password. + * @param eVaultId - The unique identifier for the eVault instance. + * @returns The HTTP URL for accessing the provisioned eVault service. + * + * @throws {Error} If the service endpoint cannot be determined from the cluster. + */ export async function provisionEVault(w3id: string, eVaultId: string) { const idParts = w3id.split('@'); w3id = idParts[idParts.length - 1]