From d75c0e58d6df97d8dced8ef779fcc97fc937c8e0 Mon Sep 17 00:00:00 2001 From: Barrett <81570928+btlghrants@users.noreply.github.com> Date: Mon, 11 Mar 2024 13:29:42 -0500 Subject: [PATCH] fix: typos/missing types (#636) ## Description A couple minor, rando fixes containing things I noticed while writing tests in #288. ## Type of change - [x] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Other (security config, docs update, etc) ## Checklist before merging - [ ] Test, docs, adr added or updated as needed - [ ] [Contributor Guide Steps](https://github.com/defenseunicorns/pepr/blob/main/CONTRIBUTING.md#submitting-a-pull-request) followed --------- Co-authored-by: Case Wylie --- src/lib/controller/index.ts | 4 ++-- src/lib/helpers.test.ts | 6 +++--- src/lib/helpers.ts | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/lib/controller/index.ts b/src/lib/controller/index.ts index 527945bd..c16a3730 100644 --- a/src/lib/controller/index.ts +++ b/src/lib/controller/index.ts @@ -32,13 +32,13 @@ export class Controller { readonly #config: ModuleConfig; readonly #capabilities: Capability[]; readonly #beforeHook?: (req: AdmissionRequest) => void; - readonly #afterHook?: (res: MutateResponse) => void; + readonly #afterHook?: (res: MutateResponse | ValidateResponse) => void; constructor( config: ModuleConfig, capabilities: Capability[], beforeHook?: (req: AdmissionRequest) => void, - afterHook?: (res: MutateResponse) => void, + afterHook?: (res: MutateResponse | ValidateResponse) => void, onReady?: () => void, ) { this.#config = config; diff --git a/src/lib/helpers.test.ts b/src/lib/helpers.test.ts index 6f93a10e..ce62aa9c 100644 --- a/src/lib/helpers.test.ts +++ b/src/lib/helpers.test.ts @@ -442,14 +442,14 @@ describe("generateWatchNamespaceError", () => { test("returns error for binding and capability namespace conflict", () => { const error = generateWatchNamespaceError([""], ["ns2"], ["ns3"]); expect(error).toBe( - "Binding uses namespace not governed by capability: bindingNamespaces: [ns2] capabilityNamespaces:$[ns3].", + "Binding uses namespace not governed by capability: bindingNamespaces: [ns2] capabilityNamespaces: [ns3].", ); }); test("returns combined error for both conflicts", () => { const error = generateWatchNamespaceError(["ns1"], ["ns1"], ["ns3", "ns4"]); expect(error).toBe( - "Binding uses a Pepr ignored namespace: ignoredNamespaces: [ns1] bindingNamespaces: [ns1]. Binding uses namespace not governed by capability: bindingNamespaces: [ns1] capabilityNamespaces:$[ns3, ns4].", + "Binding uses a Pepr ignored namespace: ignoredNamespaces: [ns1] bindingNamespaces: [ns1]. Binding uses namespace not governed by capability: bindingNamespaces: [ns1] capabilityNamespaces: [ns3, ns4].", ); }); @@ -563,7 +563,7 @@ describe("namespaceComplianceValidator", () => { namespaceComplianceValidator(nsViolation[0]); } catch (e) { expect(e.message).toBe( - "Error in test-capability-namespaces capability. A binding violates namespace rules. Please check ignoredNamespaces and capability namespaces: Binding uses namespace not governed by capability: bindingNamespaces: [new york] capabilityNamespaces:$[miami, dallas, milwaukee].", + "Error in test-capability-namespaces capability. A binding violates namespace rules. Please check ignoredNamespaces and capability namespaces: Binding uses namespace not governed by capability: bindingNamespaces: [new york] capabilityNamespaces: [miami, dallas, milwaukee].", ); } }); diff --git a/src/lib/helpers.ts b/src/lib/helpers.ts index 4ef68b9a..4049a985 100644 --- a/src/lib/helpers.ts +++ b/src/lib/helpers.ts @@ -189,7 +189,7 @@ export function generateWatchNamespaceError( if (bindingAndCapabilityNSConflict(bindingNamespaces, capabilityNamespaces)) { err += `Binding uses namespace not governed by capability: bindingNamespaces: [${bindingNamespaces.join( ", ", - )}] capabilityNamespaces:$[${capabilityNamespaces.join(", ")}].`; + )}] capabilityNamespaces: [${capabilityNamespaces.join(", ")}].`; } // add a space if there is a period in the middle of the string