pepr 2.0.0 → 2.0.2

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
@@ -16,17 +16,18 @@
16
16
  "!src/fixtures/**",
17
17
  "!dist/**/*.test.d.ts*"
18
18
  ],
19
- "version": "2.0.0",
19
+ "version": "2.0.2",
20
20
  "main": "dist/lib.js",
21
21
  "types": "dist/lib.d.ts",
22
22
  "scripts": {
23
23
  "build": "tsc -p config/tsconfig.root.json && node build.mjs && npm pack",
24
24
  "build:image": "npm run build && docker buildx build --output type=docker --tag pepr:dev .",
25
- "build:image:unicorn": "npm run build && docker buildx build --output type=docker --tag pepr/private:dev $(node scripts/read-unicorn-build-args.mjs) .",
25
+ "build:image:unicorn": "npm run build && docker buildx build --file config/Dockerfile --output type=docker --tag pepr/private:dev .",
26
26
  "ci": "npm ci",
27
27
  "cluster:k3d": "k3d cluster delete pepr-dev && k3d cluster create pepr-dev --k3s-arg '--debug@server:0' --wait && kubectl rollout status deployment -n kube-system",
28
28
  "cluster:k3d:import-upstream": "npm run build && docker buildx build --output type=docker --tag pepr:dev . && k3d image import pepr:dev -c pepr-dev",
29
- "cluster:k3d:import-unicorn": "npm run build && docker buildx build --output type=docker --tag pepr/private:dev $(node scripts/read-unicorn-build-args.mjs) . && k3d image import pepr/private:dev -c pepr-dev",
29
+ "cluster:k3d:import-unicorn": "npm run build && docker buildx build --file config/Dockerfile --output type=docker --tag pepr/private:dev . && k3d image import pepr/private:dev -c pepr-dev",
30
+ "check:container-image-equality": "tsx scripts/check-chainguard-image-equality.ts",
30
31
  "format:check": "npm run format:src && npm run format:tests && npm run format:markdown && npm run format:integration && npm run format:prettier -- --check",
31
32
  "format:fix": "npm run format:src -- --fix && npm run format:markdown -- --fix && npm run format:integration -- --fix && npm run format:prettier -- --write",
32
33
  "format:integration": "eslint --config config/eslint.integration.config.mjs integration/cli integration/helpers",
@@ -35,7 +36,7 @@
35
36
  "format:src": "eslint --config config/eslint.root.config.mjs 'src/**/*.ts' '.github/workflows/scripts/**/*.ts' --ignore-pattern '**/*.test.ts' --ignore-pattern 'src/templates/**'",
36
37
  "format:tests": "eslint --config config/eslint.test.config.mjs 'src/**/*.test.ts'",
37
38
  "gen-data-json": "node hack/build-template-data.mjs",
38
- "prebuild": "rm -fr dist/* && npm run gen-data-json",
39
+ "prebuild": "node patches/apply-patches.mjs && rm -fr dist/* && npm run gen-data-json",
39
40
  "prepare": "if [ \"$NODE_ENV\" != 'production' ]; then husky; fi",
40
41
  "set-version": "bash -lc 'ver=${PEPR_VERSION:-}; if [ -z \"$ver\" ]; then git fetch --tags --force; ver=$(git describe --tags --abbrev=0); fi; ver=${ver#v}; echo Using version $ver; node ./scripts/set-version.js \"$ver\"'",
41
42
  "test": "npm run test:unit && npm run test:integration",
@@ -50,16 +51,16 @@
50
51
  },
51
52
  "dependencies": {
52
53
  "@types/ramda": "0.32.0",
53
- "@typescript-eslint/eslint-plugin": "8.66.0",
54
- "@typescript-eslint/parser": "8.66.0",
54
+ "@typescript-eslint/eslint-plugin": "8.70.0",
55
+ "@typescript-eslint/parser": "8.70.0",
55
56
  "commander": "15.0.0",
56
57
  "eslint": "^10.8.0",
57
58
  "express": "5.2.1",
58
59
  "fast-json-patch": "3.1.1",
59
- "globals": "17.9.0",
60
+ "globals": "17.12.0",
60
61
  "http-status-codes": "^2.3.0",
61
62
  "json-pointer": "^0.6.2",
62
- "kubernetes-fluent-client": "3.11.11",
63
+ "kubernetes-fluent-client": "3.12.3",
63
64
  "pino": "10.3.1",
64
65
  "pino-pretty": "13.1.3",
65
66
  "prom-client": "15.1.3",
@@ -67,8 +68,8 @@
67
68
  "ramda": "0.32.0"
68
69
  },
69
70
  "devDependencies": {
70
- "@commitlint/cli": "21.2.1",
71
- "@commitlint/config-conventional": "21.2.0",
71
+ "@commitlint/cli": "21.2.2",
72
+ "@commitlint/config-conventional": "21.2.2",
72
73
  "@eslint/eslintrc": "^3.3.6",
73
74
  "@eslint/js": "^10.0.1",
74
75
  "@types/command-line-args": "^5.2.3",
@@ -76,7 +77,7 @@
76
77
  "@types/json-pointer": "^1.0.34",
77
78
  "@types/json-schema": "^7.0.15",
78
79
  "@types/ms": "^2.1.0",
79
- "@types/node": "^24.13.3",
80
+ "@types/node": "^26.2.0",
80
81
  "@types/node-forge": "1.3.14",
81
82
  "@types/readable-stream": "^4.0.21",
82
83
  "@types/urijs": "^1.19.25",
@@ -86,18 +87,19 @@
86
87
  "husky": "^9.1.6",
87
88
  "js-yaml": "^5.2.1",
88
89
  "ms": "^2.1.3",
90
+ "patch-package": "^8.0.1",
89
91
  "prettier": "^3.6.2",
90
92
  "selfsigned": "^5.5.0",
91
93
  "shellcheck": "^4.1.0",
92
94
  "tsx": "^4.20.3",
93
- "undici": "8.10.0",
95
+ "undici": "8.10.2",
94
96
  "vitest": "^4.0.4"
95
97
  },
96
98
  "overrides": {
97
99
  "brace-expansion": "^5.0.9",
98
100
  "ip-address": "^10.5.0",
99
101
  "tar": "^7.5.16",
100
- "fast-uri": "^3.1.5"
102
+ "fast-uri": "^3.1.7"
101
103
  },
102
104
  "peerDependencies": {
103
105
  "@types/prompts": "^2.4.9",
@@ -0,0 +1,25 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ // SPDX-FileCopyrightText: 2023-Present The Pepr Authors
3
+
4
+ import { existsSync, readFileSync, writeFileSync } from "node:fs";
5
+ import { join } from "node:path";
6
+
7
+ const THREAD_STREAM_TYPES = ["thread-stream", "index.d.ts"];
8
+ const TRANSFER_LIST_ITEM = "workerThreads.TransferListItem[]";
9
+ const TRANSFERABLE = "workerThreads.Transferable[]";
10
+
11
+ export function applyBuildCompatibilityPatches(npmRoot: string): void {
12
+ const threadStreamTypes = join(npmRoot, ...THREAD_STREAM_TYPES);
13
+
14
+ if (!existsSync(threadStreamTypes)) {
15
+ return;
16
+ }
17
+
18
+ const currentTypes = readFileSync(threadStreamTypes, "utf8");
19
+
20
+ if (!currentTypes.includes(TRANSFER_LIST_ITEM) || currentTypes.includes(TRANSFERABLE)) {
21
+ return;
22
+ }
23
+
24
+ writeFileSync(threadStreamTypes, currentTypes.replace(TRANSFER_LIST_ITEM, TRANSFERABLE));
25
+ }
@@ -9,6 +9,7 @@ import { watchForChanges } from "./build.helpers";
9
9
  import { PeprConfig, Reloader } from "../types";
10
10
  import { BuildContext } from "esbuild";
11
11
  import { loadModule } from "./loadModule";
12
+ import { applyBuildCompatibilityPatches } from "./applyCompatibilityPatches";
12
13
 
13
14
  export type BuildModuleReturn = {
14
15
  ctx: BuildContext<BuildOptions>;
@@ -71,6 +72,7 @@ export async function buildModule(
71
72
 
72
73
  // Resolve node_modules folder (in support of npm workspaces!) and run tsc
73
74
  const npmRoot = execFileSync("npm", ["root"]).toString().trim();
75
+ applyBuildCompatibilityPatches(npmRoot);
74
76
  execFileSync(`${npmRoot}/.bin/tsc`, [
75
77
  "--project",
76
78
  `${modulePath}/tsconfig.json`,
@@ -142,18 +144,20 @@ export async function buildModule(
142
144
  }
143
145
  }
144
146
 
145
- interface BuildModuleResult {
147
+ interface BuildModuleError extends Error {
146
148
  stdout?: Buffer;
147
- stderr: Buffer;
149
+ stderr?: Buffer;
148
150
  }
149
151
 
150
- function handleModuleBuildError(e: BuildModuleResult): void {
152
+ function handleModuleBuildError(e: BuildModuleError): never {
151
153
  console.error(`Error building module:`, e);
152
154
 
153
- if (!e.stdout) process.exit(1); // Exit with a non-zero exit code on any other error
155
+ if (!e.stdout) {
156
+ throw e;
157
+ }
154
158
 
155
159
  const out = e.stdout.toString() as string;
156
- const err = e.stderr.toString();
160
+ const err = e.stderr?.toString() ?? "";
157
161
 
158
162
  console.info(out);
159
163
  console.error(err);
@@ -183,4 +187,6 @@ function handleModuleBuildError(e: BuildModuleResult): void {
183
187
  );
184
188
  });
185
189
  }
190
+
191
+ throw e;
186
192
  }
@@ -182,24 +182,6 @@ export class Assets {
182
182
  mutateWebhook: V1MutatingWebhookConfiguration | V1ValidatingWebhookConfiguration | null,
183
183
  helm: Record<string, Record<string, string>>,
184
184
  ): Promise<void> => {
185
- if (validateWebhook || mutateWebhook) {
186
- await fs.writeFile(
187
- helm.files.admissionDeploymentYaml,
188
- dedent(admissionDeployTemplate(this.buildTimestamp, "admission")),
189
- );
190
- await fs.writeFile(
191
- helm.files.admissionServiceMonitorYaml,
192
- dedent(
193
- serviceMonitorTemplate(
194
- process.env.PEPR_CUSTOM_BUILD_NAME
195
- ? `admission-${process.env.PEPR_CUSTOM_BUILD_NAME}`
196
- : "admission",
197
- `admission`,
198
- ),
199
- ),
200
- );
201
- }
202
-
203
185
  if (mutateWebhook) {
204
186
  await fs.writeFile(
205
187
  helm.files.mutationWebhookYaml,
@@ -215,6 +197,26 @@ export class Assets {
215
197
  }
216
198
  };
217
199
 
200
+ writeAdmissionControllerFiles = async (
201
+ helm: Record<string, Record<string, string>>,
202
+ ): Promise<void> => {
203
+ await fs.writeFile(
204
+ helm.files.admissionDeploymentYaml,
205
+ dedent(admissionDeployTemplate(this.buildTimestamp, "admission")),
206
+ );
207
+ await fs.writeFile(
208
+ helm.files.admissionServiceMonitorYaml,
209
+ dedent(
210
+ serviceMonitorTemplate(
211
+ process.env.PEPR_CUSTOM_BUILD_NAME
212
+ ? `admission-${process.env.PEPR_CUSTOM_BUILD_NAME}`
213
+ : "admission",
214
+ `admission`,
215
+ ),
216
+ ),
217
+ );
218
+ };
219
+
218
220
  generateHelmChart = async (
219
221
  webhookGeneratorFunction: (
220
222
  assets: Assets,
@@ -299,6 +301,10 @@ export class Assets {
299
301
  ),
300
302
  };
301
303
 
304
+ if (isAdmission(this.capabilities) || norWatchOrAdmission(this.capabilities)) {
305
+ await this.writeAdmissionControllerFiles(helm);
306
+ }
307
+
302
308
  await this.writeWebhookFiles(webhooks.validate, webhooks.mutate, helm);
303
309
 
304
310
  const watchDeployment = getWatcherFunction(this, moduleHash, this.buildTimestamp);
@@ -5,6 +5,7 @@ type ConfigType = "manifests" | "charts";
5
5
 
6
6
  export function generateZarfYamlGeneric(assets: Assets, path: string, type: ConfigType): string {
7
7
  const zarfComponentName = process.env.PEPR_CUSTOM_BUILD_NAME ?? "module";
8
+ const helmReleaseName = process.env.PEPR_CUSTOM_BUILD_NAME ?? assets.name;
8
9
  const manifestSettings = {
9
10
  name: zarfComponentName,
10
11
  namespace: "pepr-system",
@@ -15,6 +16,7 @@ export function generateZarfYamlGeneric(assets: Assets, path: string, type: Conf
15
16
  namespace: "pepr-system",
16
17
  version: `${assets.config.appVersion || "0.0.1"}`,
17
18
  localPath: path,
19
+ releaseName: helmReleaseName,
18
20
  };
19
21
 
20
22
  const component = {
@@ -1,7 +1,7 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  // SPDX-FileCopyrightText: 2023-Present The Pepr Authors
3
3
  import { KubernetesObject } from "@kubernetes/client-node";
4
- import { WatchPhase } from "kubernetes-fluent-client/dist/fluent/shared-types";
4
+ import { WatchPhase } from "kubernetes-fluent-client";
5
5
  import { randomBytes } from "node:crypto";
6
6
  import Log from "../telemetry/logger";
7
7
 
@@ -5,16 +5,16 @@ import { Binding } from "../types";
5
5
  import { Capability } from "../core/capability";
6
6
  import { Event } from "../enums";
7
7
  import {
8
+ GenericClass,
8
9
  K8s,
10
+ KubernetesListObject,
9
11
  KubernetesObject,
10
12
  WatchCfg,
11
13
  WatchEvent,
12
- GenericClass,
14
+ WatcherType,
15
+ WatchPhase,
13
16
  } from "kubernetes-fluent-client";
14
17
  import { Queue } from "../core/queue";
15
- import { WatcherType } from "kubernetes-fluent-client/dist/fluent/types";
16
- import { WatchPhase } from "kubernetes-fluent-client/dist/fluent/shared-types";
17
- import { KubernetesListObject } from "kubernetes-fluent-client/dist/types";
18
18
  import { filterNoMatchReason } from "../filter/filter";
19
19
  import { metricsCollector, MetricsCollectorInstance } from "../telemetry/metrics";
20
20
  import { removeFinalizer } from "../finalizer";
package/src/lib/types.ts CHANGED
@@ -1,9 +1,13 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  // SPDX-FileCopyrightText: 2023-Present The Pepr Authors
3
3
 
4
- import { GenericClass, GroupVersionKind, KubernetesObject } from "kubernetes-fluent-client";
4
+ import {
5
+ GenericClass,
6
+ GroupVersionKind,
7
+ KubernetesObject,
8
+ WatchPhase,
9
+ } from "kubernetes-fluent-client";
5
10
  import { Event } from "./enums";
6
- import { WatchPhase } from "kubernetes-fluent-client/dist/fluent/shared-types";
7
11
  import { Logger } from "pino";
8
12
  import { PeprMutateRequest } from "./mutate-request";
9
13
  import { PeprValidateRequest } from "./validate-request";