Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: defenseunicorns/pepr
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.20.2
Choose a base ref
...
head repository: defenseunicorns/pepr
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v0.20.3
Choose a head ref
  • 1 commit
  • 2 files changed
  • 1 contributor

Commits on Dec 22, 2023

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    4b3277e View commit details
Showing with 9 additions and 4 deletions.
  1. +8 −4 src/lib/watch-processor.ts
  2. +1 −0 src/templates/settings.json
12 changes: 8 additions & 4 deletions src/lib/watch-processor.ts
Original file line number Diff line number Diff line change
@@ -3,8 +3,8 @@

import { K8s } from "kubernetes-fluent-client";
import { WatchPhase } from "kubernetes-fluent-client/dist/fluent/types";

import { WatchCfg } from "kubernetes-fluent-client/dist/fluent/watch";

import { Capability } from "./capability";
import Log from "./logger";
import { Binding, Event } from "./types";
@@ -37,15 +37,19 @@ async function runBinding(binding: Binding) {
Log.error(e, "Watch failed after 3 attempts, giving up");
process.exit(1);
},
// pino binding explodes unless we wrap it
logFn: (obj: unknown, msg?: string, ...args: unknown[]) => Log.debug(obj, msg, ...args),
};

// Watch the resource
await K8s(binding.model, binding.filters).Watch((obj, type) => {
await K8s(binding.model, binding.filters).Watch(async (obj, type) => {
Log.debug(obj, `Watch event ${type} received`);

// If the type matches the phase, call the watch callback
if (phaseMatch.includes(type)) {
try {
// This may be a promise, but we don't need to wait for it
void binding.watchCallback?.(obj, type);
// Perform the watch callback
await binding.watchCallback?.(obj, type);
} catch (e) {
// Errors in the watch callback should not crash the controller
Log.error(e, "Error executing watch callback");
1 change: 1 addition & 0 deletions src/templates/settings.json
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@
"enableTurboSourcemaps": true,
"resolveSourceMapLocations": [
"${workspaceFolder}/**",
"node_modules/kubernetes-fluent-client/**",
"node_modules/pepr/**"
]
}