Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pepr always fails when you select "audit" or "reject" when creating a new capability #235

Closed
AustinAbro321 opened this issue Aug 31, 2023 · 1 comment · Fixed by #238
Closed
Assignees

Comments

@AustinAbro321
Copy link

There are inconsistent values between the askErrorBehavior prompt and what's looked for when pepr validates. Gives an error like below when you run npx pepr dev

Running module /home/austin/code/test-4/dist/pepr-d26d73ab-fb93-5747-9085-b4e29dc96f23.js
/home/austin/code/test-4/node_modules/pepr/dist/lib.js:1485
      throw new Error(`Invalid onErrors value: ${config.onError}`);
      ^

Error: Invalid onErrors value: audit
    at new PeprModule (/home/austin/code/test-4/node_modules/pepr/dist/lib.js:1485:13)
    at Object.<anonymous> (/home/austin/code/test-4/dist/pepr-d26d73ab-fb93-5747-9085-b4e29dc96f23.js:146:1)
    at Module._compile (node:internal/modules/cjs/loader:1233:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1287:10)
    at Module.load (node:internal/modules/cjs/loader:1091:32)
    at Module._load (node:internal/modules/cjs/loader:938:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:83:12)
    at node:internal/main/run_main_module:23:47

Node.js v20.5.1

const askErrorBehavior: PromptObject = {
type: "select",
name: "errorBehavior",
message: "How do you want Pepr to handle errors encountered during K8s operations?",
choices: [
{
title: "Ignore",
value: "ignore",
description:
"Pepr will continue processing and generate an entry in the Pepr Controller log.",
selected: true,
},
{
title: "Log an audit event",
value: "audit",
description:
"Pepr will continue processing and generate an entry in the Pepr Controller log as well as an audit event in the cluster.",
},
{
title: "Reject the operation",
value: "reject",
description: "Pepr will reject the operation and return an error to the client.",
},
],
};

pepr/src/lib/module.ts

Lines 41 to 44 in 076ba73

const validOnErrors = ["ignore", "warn", "fail"];
if (!validOnErrors.includes(config.onError || "")) {
throw new Error(`Invalid onErrors value: ${config.onError}`);
}

@bdw617
Copy link
Contributor

bdw617 commented Aug 31, 2023

@AustinAbro321 it's not a difficult fix, but going to let @jeff-mccoy own it as he understands this specific problem well.

@jeff-mccoy jeff-mccoy linked a pull request Sep 1, 2023 that will close this issue
jeff-mccoy added a commit that referenced this issue Sep 4, 2023
Fixes #235.

Changes:
- Migrate from E2E -> Journey + additional unit tests w/mocks
- Migrate from Ava -> Jest (for better mocking support, coverage, TS
test support)
- Add audit annotations based on [K8s Audit
Annotations](https://kubernetes.io/docs/reference/labels-annotations-taints/audit-annotations/),
note this will still require cluster admin config to utilize
- Migrate all `private` TS modifiers to [ECMA2022 Private Class
Features](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/Private_class_fields)
and
- Remove `public` (implicit) Typescript modifier from all class features
- Migrate from arrow functions to bound class methods for public methods
- Add unit test coverage output 
- Move unsafe https ops from global Node settings to single `fetch`
calls on metrics/api journey tests
- Small dep updates
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants