pepr 0.29.2 → 0.30.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "engines": {
10
10
  "node": ">=18.0.0"
11
11
  },
12
- "version": "0.29.2",
12
+ "version": "0.30.0",
13
13
  "main": "dist/lib.js",
14
14
  "types": "dist/lib.d.ts",
15
15
  "scripts": {
@@ -35,17 +35,17 @@
35
35
  "@types/ramda": "0.29.12",
36
36
  "express": "4.19.2",
37
37
  "fast-json-patch": "3.1.1",
38
- "kubernetes-fluent-client": "2.3.1",
39
- "pino": "8.20.0",
38
+ "kubernetes-fluent-client": "2.3.2",
39
+ "pino": "9.0.0",
40
40
  "pino-pretty": "11.0.0",
41
41
  "prom-client": "15.1.2",
42
- "ramda": "0.29.1"
42
+ "ramda": "0.30.0"
43
43
  },
44
44
  "devDependencies": {
45
- "@commitlint/cli": "19.2.2",
45
+ "@commitlint/cli": "19.3.0",
46
46
  "@commitlint/config-conventional": "19.2.2",
47
47
  "@jest/globals": "29.7.0",
48
- "@types/eslint": "8.56.9",
48
+ "@types/eslint": "8.56.10",
49
49
  "@types/express": "4.17.21",
50
50
  "@types/node": "18.x.x",
51
51
  "@types/node-forge": "1.3.11",
@@ -5,9 +5,20 @@ import { promises as fs } from "fs";
5
5
  import { K8s, KubernetesObject, kind } from "kubernetes-fluent-client";
6
6
  import Log from "./logger";
7
7
  import { Binding, CapabilityExport } from "./types";
8
+ import { sanitizeResourceName } from "../sdk/sdk";
8
9
 
9
10
  export class ValidationError extends Error {}
10
11
 
12
+ export function validateCapabilityNames(capabilities: CapabilityExport[] | undefined): void {
13
+ if (capabilities && capabilities.length > 0) {
14
+ for (let i = 0; i < capabilities.length; i++) {
15
+ if (capabilities[i].name !== sanitizeResourceName(capabilities[i].name)) {
16
+ throw new ValidationError(`Capability name is not a valid Kubernetes resource name: ${capabilities[i].name}`);
17
+ }
18
+ }
19
+ }
20
+ }
21
+
11
22
  export function validateHash(expectedHash: string): void {
12
23
  // Require the hash to be a valid SHA-256 hash (64 characters, hexadecimal)
13
24
  const sha256Regex = /^[a-f0-9]{64}$/i;
@@ -10,8 +10,12 @@ import { Binding, Event } from "./types";
10
10
 
11
11
  // Watch configuration
12
12
  const watchCfg: WatchCfg = {
13
- retryMax: 5,
14
- retryDelaySec: 5,
13
+ retryMax: process.env.PEPR_RETRYMAX ? parseInt(process.env.PEPR_RETRYMAX, 10) : 5,
14
+ retryDelaySec: process.env.PEPR_RETRYDELAYSECONDS ? parseInt(process.env.PEPR_RETRYDELAYSECONDS, 10) : 5,
15
+ resyncIntervalSec: process.env.PEPR_RESYNCINTERVALSECONDS
16
+ ? parseInt(process.env.PEPR_RESYNCINTERVALSECONDS, 10)
17
+ : 300,
18
+ allowWatchBookmarks: process.env.PEPR_ALLOWWATCHBOOKMARKS ? process.env.PEPR_ALLOWWATCHBOOKMARKS === "true" : false,
15
19
  };
16
20
 
17
21
  // Map the event to the watch phase
@@ -47,6 +51,8 @@ async function runBinding(binding: Binding, capabilityNamespaces: string[]) {
47
51
  const phaseMatch: WatchPhase[] = eventToPhaseMap[binding.event] || eventToPhaseMap[Event.Any];
48
52
 
49
53
  // The watch callback is run when an object is received or dequeued
54
+
55
+ Log.debug({ watchCfg }, "Effective WatchConfig");
50
56
  const watchCallback = async (obj: KubernetesObject, type: WatchPhase) => {
51
57
  // First, filter the object based on the phase
52
58
  if (phaseMatch.includes(type)) {