pepr 0.47.0-nightly.2 → 0.47.0-nightly.4

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,7 +16,7 @@
16
16
  "!src/fixtures/**",
17
17
  "!dist/**/*.test.d.ts*"
18
18
  ],
19
- "version": "0.47.0-nightly.2",
19
+ "version": "0.47.0-nightly.4",
20
20
  "main": "dist/lib.js",
21
21
  "types": "dist/lib.d.ts",
22
22
  "scripts": {
@@ -54,7 +54,7 @@
54
54
  "heredoc": "^1.3.1",
55
55
  "http-status-codes": "^2.3.0",
56
56
  "json-pointer": "^0.6.2",
57
- "kubernetes-fluent-client": "3.4.6",
57
+ "kubernetes-fluent-client": "3.4.7",
58
58
  "pino": "9.6.0",
59
59
  "pino-pretty": "13.0.0",
60
60
  "prom-client": "15.1.3",
@@ -62,7 +62,7 @@ export class PeprModule {
62
62
  const controllerHooks: ControllerHooks = {
63
63
  beforeHook: opts.beforeHook,
64
64
  afterHook: opts.afterHook,
65
- onReady: (): void => {
65
+ onReady: async (): Promise<void> => {
66
66
  // Wait for the controller to be ready before setting up watches
67
67
  if (isWatchMode() || isDevMode()) {
68
68
  try {
@@ -86,13 +86,11 @@ const eventToPhaseMap = {
86
86
  * @param capabilities The capabilities to load watches for
87
87
  */
88
88
  export function setupWatch(capabilities: Capability[], ignoredNamespaces?: string[]): void {
89
- capabilities.map(capability =>
90
- capability.bindings
91
- .filter(binding => binding.isWatch)
92
- .forEach(bindingElement =>
93
- runBinding(bindingElement, capability.namespaces, ignoredNamespaces),
94
- ),
95
- );
89
+ for (const capability of capabilities) {
90
+ for (const binding of capability.bindings.filter(b => b.isWatch)) {
91
+ runBinding(binding, capability.namespaces, ignoredNamespaces);
92
+ }
93
+ }
96
94
  }
97
95
 
98
96
  /**
@@ -101,7 +99,7 @@ export function setupWatch(capabilities: Capability[], ignoredNamespaces?: strin
101
99
  * @param binding the binding to watch
102
100
  * @param capabilityNamespaces list of namespaces to filter on
103
101
  */
104
- async function runBinding(
102
+ export async function runBinding(
105
103
  binding: Binding,
106
104
  capabilityNamespaces: string[],
107
105
  ignoredNamespaces?: string[],
@@ -185,14 +183,20 @@ async function runBinding(
185
183
  );
186
184
 
187
185
  // Register event handlers
188
- registerWatchEventHandlers(watcher, logEvent, metricsCollector);
186
+ try {
187
+ registerWatchEventHandlers(watcher, logEvent, metricsCollector);
188
+ } catch (err) {
189
+ throw new Error(
190
+ "WatchEventHandler Registration Error: Unable to register event watch handler.",
191
+ { cause: err },
192
+ );
193
+ }
189
194
 
190
195
  // Start the watch
191
196
  try {
192
197
  await watcher.start();
193
198
  } catch (err) {
194
- Log.error(err, "Error starting watch");
195
- process.exit(1);
199
+ throw new Error("WatchStart Error: Unable to start watch.", { cause: err });
196
200
  }
197
201
  }
198
202
 
@@ -235,7 +239,10 @@ export function registerWatchEventHandlers(
235
239
  [WatchEvent.GIVE_UP]: err => {
236
240
  // If failure continues, log and exit
237
241
  logEvent(WatchEvent.GIVE_UP, err.message);
238
- process.exit(1);
242
+ throw new Error(
243
+ "WatchEvent GiveUp Error: The watch has failed to start after several attempts.",
244
+ { cause: err },
245
+ );
239
246
  },
240
247
  [WatchEvent.CONNECT]: url => logEvent(WatchEvent.CONNECT, url),
241
248
  [WatchEvent.DATA_ERROR]: err => logEvent(WatchEvent.DATA_ERROR, err.message),