pepr 0.3.0-rc0 → 0.3.1

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.
Files changed (63) hide show
  1. package/README.md +3 -46
  2. package/dist/package.json +8 -6
  3. package/dist/src/cli/build.js +1 -1
  4. package/dist/src/cli/dev.js +4 -1
  5. package/dist/src/cli/init/index.js +1 -1
  6. package/dist/src/lib/capability.d.ts +29 -0
  7. package/dist/src/lib/capability.d.ts.map +1 -0
  8. package/dist/src/lib/controller.d.ts +18 -0
  9. package/dist/src/lib/controller.d.ts.map +1 -0
  10. package/dist/src/lib/fetch.d.ts +24 -0
  11. package/dist/src/lib/fetch.d.ts.map +1 -0
  12. package/dist/src/lib/filter.d.ts +11 -0
  13. package/dist/src/lib/filter.d.ts.map +1 -0
  14. package/dist/src/lib/index.d.ts +15 -0
  15. package/dist/src/lib/index.d.ts.map +1 -0
  16. package/dist/{index.js → src/lib/index.js} +6 -6
  17. package/dist/src/lib/k8s/index.d.ts +6 -0
  18. package/dist/src/lib/k8s/index.d.ts.map +1 -0
  19. package/dist/src/lib/k8s/kinds.d.ts +12 -0
  20. package/dist/src/lib/k8s/kinds.d.ts.map +1 -0
  21. package/dist/src/lib/k8s/tls.d.ts +18 -0
  22. package/dist/src/lib/k8s/tls.d.ts.map +1 -0
  23. package/dist/src/lib/k8s/types.d.ts +148 -0
  24. package/dist/src/lib/k8s/types.d.ts.map +1 -0
  25. package/dist/src/lib/k8s/upstream.d.ts +4 -0
  26. package/dist/src/lib/k8s/upstream.d.ts.map +1 -0
  27. package/dist/src/lib/k8s/webhook.d.ts +35 -0
  28. package/dist/src/lib/k8s/webhook.d.ts.map +1 -0
  29. package/dist/src/lib/logger.d.ts +56 -0
  30. package/dist/src/lib/logger.d.ts.map +1 -0
  31. package/dist/src/lib/module.d.ts +33 -0
  32. package/dist/src/lib/module.d.ts.map +1 -0
  33. package/dist/src/lib/processor.d.ts +5 -0
  34. package/dist/src/lib/processor.d.ts.map +1 -0
  35. package/dist/src/lib/request.d.ts +78 -0
  36. package/dist/src/lib/request.d.ts.map +1 -0
  37. package/dist/src/lib/types.d.ts +188 -0
  38. package/dist/src/lib/types.d.ts.map +1 -0
  39. package/package.json +8 -6
  40. package/{index.ts → src/lib/index.ts} +6 -6
  41. package/dist/fixtures/data/cm1.json +0 -75
  42. package/dist/fixtures/data/deployment1.json +0 -170
  43. package/dist/fixtures/data/ns1.json +0 -72
  44. package/dist/fixtures/data/pod1.json +0 -271
  45. package/dist/fixtures/data/pod2.json +0 -257
  46. package/dist/fixtures/data/svc1.json +0 -100
  47. package/dist/fixtures/loader.js +0 -60
  48. package/dist/src/cli/init/utils.test.js +0 -29
  49. package/dist/src/cli/init/walkthrough.test.js +0 -21
  50. package/dist/src/lib/fetch.test.js +0 -98
  51. package/dist/src/lib/filter.test.js +0 -208
  52. package/dist/src/lib/k8s/kinds.test.js +0 -296
  53. package/dist/src/lib/logger.test.js +0 -64
  54. package/docs/.prettierrc.json +0 -13
  55. package/docs/actions.md +0 -58
  56. package/docs/capabilities.md +0 -17
  57. package/docs/cli.md +0 -58
  58. package/docs/module.md +0 -90
  59. package/osv-scanner.toml +0 -4
  60. package/src/lib/fetch.test.ts +0 -115
  61. package/src/lib/filter.test.ts +0 -231
  62. package/src/lib/k8s/kinds.test.ts +0 -333
  63. package/src/lib/logger.test.ts +0 -80
package/README.md CHANGED
@@ -9,7 +9,7 @@ Pepr is on a mission to save Kubernetes from the tyranny of YAML, intimidating g
9
9
  - Zero-config K8s webhook mutations and [validations soon](https://github.com/defenseunicorns/pepr/issues/73).
10
10
  - Human-readable fluent API for generating [Pepr Capabilities](#capability)
11
11
  - Generate new K8s resources based off of cluster resource changes
12
- - Perform other exec/API calls based off of cluster resources changes or any other abitrary schedule
12
+ - Perform other exec/API calls based off of cluster resources changes or any other arbitrary schedule
13
13
  - Out of the box airgap support with [Zarf](https://zarf.dev)
14
14
  - Entire NPM ecosystem available for advanced operations
15
15
  - Realtime K8s debugging system for testing/reacting to cluster changes
@@ -76,7 +76,7 @@ https://user-images.githubusercontent.com/882485/230895880-c5623077-f811-4870-bb
76
76
 
77
77
  ### Module
78
78
 
79
- A module is the top-level collection of capabilities. It is a single, complete TypeScript project that includes an entry point to load all the configuration and capabilities, along with their CapabilityActions. During the Pepr build process, each module produces a unique Kubernetes MutatingWebhookConfiguration and ValidatingWebhookConfiguration, along with a secret containing the transpiled and compressed TypeScript code. The webhooks and secret are deployed into the Kubernetes cluster for processing by a common Pepr controller.
79
+ A module is the top-level collection of capabilities. It is a single, complete TypeScript project that includes an entry point to load all the configuration and capabilities, along with their CapabilityActions. During the Pepr build process, each module produces a unique Kubernetes MutatingWebhookConfiguration and ValidatingWebhookConfiguration, along with a secret containing the transpiled and compressed TypeScript code. The webhooks and secret are deployed into the Kubernetes cluster with their own isolated controller.
80
80
 
81
81
  See [Module](./docs/module.md) for more details.
82
82
 
@@ -95,50 +95,7 @@ For example, a CapabilityAction could be responsible for adding a specific label
95
95
  See [CapabilityActions](./docs/actions.md) for more details.
96
96
 
97
97
  ## Logical Pepr Flow
98
-
99
- ```mermaid
100
- graph LR
101
-
102
- subgraph "Module 3 (Validate Only)"
103
- direction LR
104
- Q[entrypoint 3] --> R[Validate Webhook];
105
- R --> S[Capability a <br><i>- action 1<br>- action 2</i>];
106
- S --> T[Capability b <br><i>- action 1<br>- action 2</i>];
107
- end
108
-
109
- subgraph "Module 2 (Mutate Only)"
110
- direction LR
111
- K[entrypoint 2] --> L[Mutate Webhook];
112
- L --> M[Capability a <br><i>- action 1<br>- action 2</i>];
113
- M --> N[Capability b <br><i>- action 1<br>- action 2<br>- action 3</i>];
114
- N --> O[Capability c <br><i>- action 1</i>];
115
- end
116
-
117
- subgraph "Module 1 (Mutate & Validate)"
118
- direction LR
119
- A[entrypoint 1] --> B[Mutate Webhook];
120
- A --> C[Validate Webhook];
121
- B --> D[Capability a <br><i>- action 1</i>];
122
- D --> E[Capability b <br><i>- action 1<br>- action 2</i>];
123
- E --> F[Capability c <br><i>- action 1<br>- action 2</i>];
124
- C --> G[Capability d <br><i>- action 1<br>- action 2</i>];
125
- G --> H[Capability e <br><i>- action 1</i>];
126
- H --> I[Capability f <br><i>- action 1<br>- action 2<br>- action 3</i>];
127
- end
128
-
129
-
130
-
131
- %% Defining node styles
132
- classDef Validate fill:#66ff66,color:#000;
133
- classDef Mutate fill:#5786ea,color:#000;
134
-
135
-
136
- class L,M,N,O Mutate;
137
- class B,D,E,F Mutate;
138
-
139
- class R,S,T Validate;
140
- class C,G,H,I Validate;
141
- ```
98
+ ![Module Diagram](./.images/modules.svg)
142
99
 
143
100
  ## TypeScript
144
101
 
package/dist/package.json CHANGED
@@ -9,15 +9,16 @@
9
9
  "engines": {
10
10
  "node": ">=18.0.0"
11
11
  },
12
- "version": "0.3.0-rc0",
13
- "main": "dist/index.js",
12
+ "version": "0.3.1",
13
+ "main": "dist/src/lib/index.js",
14
14
  "scripts": {
15
15
  "prebuild": "rm -fr dist/* && node hack/build-template-data.js",
16
16
  "build": "tsc",
17
+ "test": "npm run test:unit && npm run test:e2e",
17
18
  "test:unit": "npm run build && ava dist/**/*.test.js",
18
19
  "test:e2e": "npm run test:e2e:k3d && npm run test:e2e:build && npm run test:e2e:image && npm run test:e2e:run",
19
20
  "test:e2e:k3d": "k3d cluster delete pepr-dev && k3d cluster create pepr-dev --k3s-arg '--debug@server:0'",
20
- "test:e2e:build": "npm run build && npm uninstall pepr -g && npm install -g . && pepr",
21
+ "test:e2e:build": "npm run build && npm pack && npm uninstall pepr -g && npm install -g pepr-0.0.0-development.tgz && pepr",
21
22
  "test:e2e:image": "docker buildx build --tag pepr:dev . && k3d image import pepr:dev -c pepr-dev",
22
23
  "test:e2e:run": "ava hack/e2e.test.js --sequential --timeout=2m",
23
24
  "format:check": "eslint src && prettier src --check",
@@ -28,7 +29,7 @@
28
29
  "express": "4.18.2",
29
30
  "fast-json-patch": "3.1.1",
30
31
  "http-status-codes": "2.2.0",
31
- "node-fetch": "2.6.9",
32
+ "node-fetch": "2.6.10",
32
33
  "ramda": "0.29.0"
33
34
  },
34
35
  "devDependencies": {
@@ -38,8 +39,8 @@
38
39
  "@types/prompts": "2.4.4",
39
40
  "@types/ramda": "0.29.1",
40
41
  "@types/uuid": "9.0.1",
41
- "@typescript-eslint/eslint-plugin": "5.59.2",
42
- "@typescript-eslint/parser": "5.59.2",
42
+ "@typescript-eslint/eslint-plugin": "5.59.5",
43
+ "@typescript-eslint/parser": "5.59.5",
43
44
  "ava": "5.2.0",
44
45
  "eslint": "8.40.0",
45
46
  "nock": "13.3.1",
@@ -54,6 +55,7 @@
54
55
  "node-forge": "1.3.1",
55
56
  "prompts": "2.4.2",
56
57
  "rollup": "3.21.5",
58
+ "ts-node": "10.9.1",
57
59
  "typescript": "5.0.4",
58
60
  "uuid": "9.0.0"
59
61
  },
@@ -65,7 +65,7 @@ async function buildModule() {
65
65
  const { uuid } = cfg.pepr;
66
66
  const name = `pepr-${uuid}.js`;
67
67
  // Read the module's version from the package.json file
68
- if (cfg.dependencies.pepr && cfg.dependencies.pepr !== "file:../") {
68
+ if (cfg.dependencies.pepr && !cfg.dependencies.pepr.includes("file:")) {
69
69
  const versionMatch = /(\d+\.\d+\.\d+)/.exec(cfg.dependencies.pepr);
70
70
  if (!versionMatch || versionMatch.length < 2) {
71
71
  throw new Error("Could not find the Pepr version in package.json");
@@ -91,9 +91,12 @@ function default_1(program) {
91
91
  exports.default = default_1;
92
92
  async function runDev() {
93
93
  try {
94
- const { path } = await (0, build_1.buildModule)();
94
+ const path = (0, path_1.resolve)(".", "pepr.ts");
95
95
  logger_1.default.info(`Running module ${path}`);
96
96
  const program = (0, child_process_1.fork)(path, {
97
+ // Register ts-node
98
+ execArgv: ["-r", "ts-node/register"],
99
+ // Pass the environment variables
97
100
  env: {
98
101
  ...process.env,
99
102
  LOG_LEVEL: "debug",
@@ -23,7 +23,7 @@ function default_1(program) {
23
23
  // Overrides for testing. @todo: don't be so gross with Node CLI testing
24
24
  if (process.env.TEST_MODE === "true") {
25
25
  prompts_1.default.inject(["pepr-test-module", "A test module for Pepr", "ignore", "y"]);
26
- pkgOverride = "file:../";
26
+ pkgOverride = "file:../pepr-0.0.0-development.tgz";
27
27
  }
28
28
  const response = await (0, walkthrough_1.walkthrough)();
29
29
  const dirName = (0, utils_1.sanitizeName)(response.name);
@@ -0,0 +1,29 @@
1
+ import { GroupVersionKind } from "./k8s";
2
+ import { Binding, CapabilityCfg, GenericClass, HookPhase, WhenSelector } from "./types";
3
+ /**
4
+ * A capability is a unit of functionality that can be registered with the Pepr runtime.
5
+ */
6
+ export declare class Capability implements CapabilityCfg {
7
+ private _name;
8
+ private _description;
9
+ private _namespaces?;
10
+ private _mutateOrValidate;
11
+ private _bindings;
12
+ get bindings(): Binding[];
13
+ get name(): string;
14
+ get description(): string;
15
+ get namespaces(): string[];
16
+ get mutateOrValidate(): HookPhase;
17
+ constructor(cfg: CapabilityCfg);
18
+ /**
19
+ * The When method is used to register a capability action to be executed when a Kubernetes resource is
20
+ * processed by Pepr. The action will be executed if the resource matches the specified kind and any
21
+ * filters that are applied.
22
+ *
23
+ * @param model the KubernetesObject model to match
24
+ * @param kind if using a custom KubernetesObject not available in `a.*`, specify the GroupVersionKind
25
+ * @returns
26
+ */
27
+ When: <T extends GenericClass>(model: T, kind?: GroupVersionKind) => WhenSelector<T>;
28
+ }
29
+ //# sourceMappingURL=capability.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"capability.d.ts","sourceRoot":"","sources":["../../../src/lib/capability.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAA2B,MAAM,OAAO,CAAC;AAElE,OAAO,EAEL,OAAO,EAIP,aAAa,EAGb,YAAY,EACZ,SAAS,EACT,YAAY,EACb,MAAM,SAAS,CAAC;AAEjB;;GAEG;AACH,qBAAa,UAAW,YAAW,aAAa;IAC9C,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,WAAW,CAAC,CAAuB;IAG3C,OAAO,CAAC,iBAAiB,CAAoB;IAE7C,OAAO,CAAC,SAAS,CAAiB;IAElC,IAAI,QAAQ,IAAI,OAAO,EAAE,CAExB;IAED,IAAI,IAAI,WAEP;IAED,IAAI,WAAW,WAEd;IAED,IAAI,UAAU,aAEb;IAED,IAAI,gBAAgB,cAEnB;gBAEW,GAAG,EAAE,aAAa;IAQ9B;;;;;;;;OAQG;IACH,IAAI,4CAA6C,gBAAgB,qBAuF/D;CACH"}
@@ -0,0 +1,18 @@
1
+ import { Capability } from "./capability";
2
+ import { Request, Response } from "./k8s/types";
3
+ import { ModuleConfig } from "./types";
4
+ export declare class Controller {
5
+ private readonly config;
6
+ private readonly capabilities;
7
+ private readonly beforeHook?;
8
+ private readonly afterHook?;
9
+ private readonly app;
10
+ private running;
11
+ constructor(config: ModuleConfig, capabilities: Capability[], beforeHook?: ((req: Request) => void) | undefined, afterHook?: ((res: Response) => void) | undefined);
12
+ /** Start the webhook server */
13
+ startServer: (port: number) => void;
14
+ private logger;
15
+ private healthz;
16
+ private mutate;
17
+ }
18
+ //# sourceMappingURL=controller.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../../src/lib/controller.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEhD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAQvC,qBAAa,UAAU;IAKnB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,YAAY;IAC7B,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC;IAC5B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC;IAP7B,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAa;IACjC,OAAO,CAAC,OAAO,CAAS;gBAGL,MAAM,EAAE,YAAY,EACpB,YAAY,EAAE,UAAU,EAAE,EAC1B,UAAU,CAAC,SAAQ,OAAO,KAAK,IAAI,aAAA,EACnC,SAAS,CAAC,SAAQ,QAAQ,KAAK,IAAI,aAAA;IAuBtD,+BAA+B;IACxB,WAAW,SAAU,MAAM,UAoBhC;IAEF,OAAO,CAAC,MAAM,CAYZ;IAEF,OAAO,CAAC,OAAO,CAOb;IAEF,OAAO,CAAC,MAAM,CA+BZ;CACH"}
@@ -0,0 +1,24 @@
1
+ /// <reference types="node" />
2
+ import f, { RequestInfo, RequestInit } from "node-fetch";
3
+ export { f as fetchRaw };
4
+ export type FetchResponse<T> = {
5
+ data: T;
6
+ ok: boolean;
7
+ status: number;
8
+ statusText: string;
9
+ };
10
+ /**
11
+ * Perform an async HTTP call and return the parsed JSON response, optionally
12
+ * as a specific type.
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * fetch<string[]>("https://example.com/api/foo");
17
+ * ```
18
+ *
19
+ * @param url The URL or Request object to fetch
20
+ * @param init Additional options for the request
21
+ * @returns
22
+ */
23
+ export declare function fetch<T>(url: URL | RequestInfo, init?: RequestInit): Promise<FetchResponse<T>>;
24
+ //# sourceMappingURL=fetch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../../src/lib/fetch.ts"],"names":[],"mappings":";AAIA,OAAO,CAAC,EAAE,EAAc,WAAW,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAErE,OAAO,EAAE,CAAC,IAAI,QAAQ,EAAE,CAAC;AAEzB,MAAM,MAAM,aAAa,CAAC,CAAC,IAAI;IAC7B,IAAI,EAAE,CAAC,CAAC;IACR,EAAE,EAAE,OAAO,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,wBAAsB,KAAK,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG,GAAG,WAAW,EAAE,IAAI,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CA8CpG"}
@@ -0,0 +1,11 @@
1
+ import { Request } from "./k8s";
2
+ import { Binding } from "./types";
3
+ /**
4
+ * shouldSkipRequest determines if a request should be skipped based on the binding filters.
5
+ *
6
+ * @param binding the capability action binding
7
+ * @param req the incoming request
8
+ * @returns
9
+ */
10
+ export declare function shouldSkipRequest(binding: Binding, req: Request): boolean;
11
+ //# sourceMappingURL=filter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filter.d.ts","sourceRoot":"","sources":["../../../src/lib/filter.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAEhC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAElC;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,OAAO,WAwE/D"}
@@ -0,0 +1,15 @@
1
+ import k8s from "@kubernetes/client-node";
2
+ import { StatusCodes as fetchStatus } from "http-status-codes";
3
+ import utils from "ramda";
4
+ import { Capability } from "./capability";
5
+ import { fetch, fetchRaw } from "./fetch";
6
+ import { RegisterKind, a } from "./k8s";
7
+ import Log from "./logger";
8
+ import { PeprModule } from "./module";
9
+ import { PeprRequest } from "./request";
10
+ import type * as KubernetesClientNode from "@kubernetes/client-node";
11
+ import type * as RamdaUtils from "ramda";
12
+ export { a,
13
+ /** PeprModule is used to setup a complete Pepr Module: `new PeprModule(cfg, {...capabilities})` */
14
+ PeprModule, PeprRequest, RegisterKind, Capability, Log, utils, fetch, fetchRaw, fetchStatus, k8s, RamdaUtils, KubernetesClientNode, };
15
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/index.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,yBAAyB,CAAC;AAC1C,OAAO,EAAE,WAAW,IAAI,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,CAAC,EAAE,MAAM,OAAO,CAAC;AACxC,OAAO,GAAG,MAAM,UAAU,CAAC;AAC3B,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAGxC,OAAO,KAAK,KAAK,oBAAoB,MAAM,yBAAyB,CAAC;AACrE,OAAO,KAAK,KAAK,UAAU,MAAM,OAAO,CAAC;AAEzC,OAAO,EACL,CAAC;AACD,mGAAmG;AACnG,UAAU,EACV,WAAW,EACX,YAAY,EACZ,UAAU,EACV,GAAG,EACH,KAAK,EACL,KAAK,EACL,QAAQ,EACR,WAAW,EACX,GAAG,EAGH,UAAU,EACV,oBAAoB,GACrB,CAAC"}
@@ -10,17 +10,17 @@ const http_status_codes_1 = require("http-status-codes");
10
10
  Object.defineProperty(exports, "fetchStatus", { enumerable: true, get: function () { return http_status_codes_1.StatusCodes; } });
11
11
  const ramda_1 = __importDefault(require("ramda"));
12
12
  exports.utils = ramda_1.default;
13
- const capability_1 = require("./src/lib/capability");
13
+ const capability_1 = require("./capability");
14
14
  Object.defineProperty(exports, "Capability", { enumerable: true, get: function () { return capability_1.Capability; } });
15
- const fetch_1 = require("./src/lib/fetch");
15
+ const fetch_1 = require("./fetch");
16
16
  Object.defineProperty(exports, "fetch", { enumerable: true, get: function () { return fetch_1.fetch; } });
17
17
  Object.defineProperty(exports, "fetchRaw", { enumerable: true, get: function () { return fetch_1.fetchRaw; } });
18
- const k8s_1 = require("./src/lib/k8s");
18
+ const k8s_1 = require("./k8s");
19
19
  Object.defineProperty(exports, "RegisterKind", { enumerable: true, get: function () { return k8s_1.RegisterKind; } });
20
20
  Object.defineProperty(exports, "a", { enumerable: true, get: function () { return k8s_1.a; } });
21
- const logger_1 = __importDefault(require("./src/lib/logger"));
21
+ const logger_1 = __importDefault(require("./logger"));
22
22
  exports.Log = logger_1.default;
23
- const module_1 = require("./src/lib/module");
23
+ const module_1 = require("./module");
24
24
  Object.defineProperty(exports, "PeprModule", { enumerable: true, get: function () { return module_1.PeprModule; } });
25
- const request_1 = require("./src/lib/request");
25
+ const request_1 = require("./request");
26
26
  Object.defineProperty(exports, "PeprRequest", { enumerable: true, get: function () { return request_1.PeprRequest; } });
@@ -0,0 +1,6 @@
1
+ import * as kind from "./upstream";
2
+ /** a is a collection of K8s types to be used within a CapabilityAction: `When(a.Configmap)` */
3
+ export { kind as a };
4
+ export { modelToGroupVersionKind, gvkMap, RegisterKind } from "./kinds";
5
+ export * from "./types";
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/k8s/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,IAAI,MAAM,YAAY,CAAC;AACnC,+FAA+F;AAC/F,OAAO,EAAE,IAAI,IAAI,CAAC,EAAE,CAAC;AAErB,OAAO,EAAE,uBAAuB,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAExE,cAAc,SAAS,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { GenericClass } from "../types";
2
+ import { GroupVersionKind } from "./types";
3
+ export declare const gvkMap: Record<string, GroupVersionKind>;
4
+ export declare function modelToGroupVersionKind(key: string): GroupVersionKind;
5
+ /**
6
+ * Registers a new model and GroupVersionKind with Pepr for use with `When(a.<Kind>)`
7
+ *
8
+ * @param model Used to match the GroupVersionKind and define the type-data for the request
9
+ * @param groupVersionKind Contains the match parameters to determine the request should be handled
10
+ */
11
+ export declare const RegisterKind: (model: GenericClass, groupVersionKind: GroupVersionKind) => void;
12
+ //# sourceMappingURL=kinds.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kinds.d.ts","sourceRoot":"","sources":["../../../../src/lib/k8s/kinds.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAE3C,eAAO,MAAM,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CA4cnD,CAAC;AAEF,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,MAAM,GAAG,gBAAgB,CAErE;AAED;;;;;GAKG;AACH,eAAO,MAAM,YAAY,UAAW,YAAY,oBAAoB,gBAAgB,SAUnF,CAAC"}
@@ -0,0 +1,18 @@
1
+ export interface TLSOut {
2
+ ca: string;
3
+ crt: string;
4
+ key: string;
5
+ pem: {
6
+ ca: string;
7
+ crt: string;
8
+ key: string;
9
+ };
10
+ }
11
+ /**
12
+ * Generates a self-signed CA and server certificate with Subject Alternative Names (SANs) for the K8s webhook.
13
+ *
14
+ * @param {string} name - The name to use for the server certificate's Common Name and SAN DNS entry.
15
+ * @returns {TLSOut} - An object containing the Base64-encoded CA, server certificate, and server private key.
16
+ */
17
+ export declare function genTLS(name: string): TLSOut;
18
+ //# sourceMappingURL=tls.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tls.d.ts","sourceRoot":"","sources":["../../../../src/lib/k8s/tls.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,MAAM;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE;QACH,EAAE,EAAE,MAAM,CAAC;QACX,GAAG,EAAE,MAAM,CAAC;QACZ,GAAG,EAAE,MAAM,CAAC;KACb,CAAC;CACH;AAED;;;;;GAKG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAyC3C"}
@@ -0,0 +1,148 @@
1
+ import { V1ListMeta, V1ObjectMeta } from "@kubernetes/client-node";
2
+ export declare enum Operation {
3
+ CREATE = "CREATE",
4
+ UPDATE = "UPDATE",
5
+ DELETE = "DELETE",
6
+ CONNECT = "CONNECT"
7
+ }
8
+ export interface KubernetesObject {
9
+ apiVersion?: string;
10
+ kind?: string;
11
+ metadata?: V1ObjectMeta;
12
+ }
13
+ export interface KubernetesListObject<T extends KubernetesObject> {
14
+ apiVersion?: string;
15
+ kind?: string;
16
+ metadata?: V1ListMeta;
17
+ items: T[];
18
+ }
19
+ /**
20
+ * GenericKind is a generic Kubernetes object that can be used to represent any Kubernetes object
21
+ * that is not explicitly supported by Pepr. This can be used on its own or as a base class for
22
+ * other types. See the examples in `HelloPepr.ts` for more information.
23
+ */
24
+ export declare class GenericKind {
25
+ apiVersion?: string;
26
+ kind?: string;
27
+ metadata?: V1ObjectMeta;
28
+ [key: string]: any;
29
+ }
30
+ /**
31
+ * GroupVersionKind unambiguously identifies a kind. It doesn't anonymously include GroupVersion
32
+ * to avoid automatic coercion. It doesn't use a GroupVersion to avoid custom marshalling
33
+ **/
34
+ export interface GroupVersionKind {
35
+ /** The K8s resource kind, e..g "Pod". */
36
+ readonly kind: string;
37
+ readonly group: string;
38
+ readonly version?: string;
39
+ }
40
+ /**
41
+ * GroupVersionResource unambiguously identifies a resource. It doesn't anonymously include GroupVersion
42
+ * to avoid automatic coercion. It doesn't use a GroupVersion to avoid custom marshalling
43
+ */
44
+ export interface GroupVersionResource {
45
+ readonly group: string;
46
+ readonly version: string;
47
+ readonly resource: string;
48
+ }
49
+ /**
50
+ * A Kubernetes admission request to be processed by a capability.
51
+ */
52
+ export interface Request<T = KubernetesObject> {
53
+ /** UID is an identifier for the individual request/response. */
54
+ readonly uid: string;
55
+ /** Kind is the fully-qualified type of object being submitted (for example, v1.Pod or autoscaling.v1.Scale) */
56
+ readonly kind: GroupVersionKind;
57
+ /** Resource is the fully-qualified resource being requested (for example, v1.pods) */
58
+ readonly resource: GroupVersionResource;
59
+ /** SubResource is the sub-resource being requested, if any (for example, "status" or "scale") */
60
+ readonly subResource?: string;
61
+ /** RequestKind is the fully-qualified type of the original API request (for example, v1.Pod or autoscaling.v1.Scale). */
62
+ readonly requestKind?: GroupVersionKind;
63
+ /** RequestResource is the fully-qualified resource of the original API request (for example, v1.pods). */
64
+ readonly requestResource?: GroupVersionResource;
65
+ /** RequestSubResource is the sub-resource of the original API request, if any (for example, "status" or "scale"). */
66
+ readonly requestSubResource?: string;
67
+ /**
68
+ * Name is the name of the object as presented in the request. On a CREATE operation, the client may omit name and
69
+ * rely on the server to generate the name. If that is the case, this method will return the empty string.
70
+ */
71
+ readonly name: string;
72
+ /** Namespace is the namespace associated with the request (if any). */
73
+ readonly namespace?: string;
74
+ /**
75
+ * Operation is the operation being performed. This may be different than the operation
76
+ * requested. e.g. a patch can result in either a CREATE or UPDATE Operation.
77
+ */
78
+ readonly operation: Operation;
79
+ /** UserInfo is information about the requesting user */
80
+ readonly userInfo: {
81
+ /** The name that uniquely identifies this user among all active users. */
82
+ username?: string;
83
+ /**
84
+ * A unique value that identifies this user across time. If this user is deleted
85
+ * and another user by the same name is added, they will have different UIDs.
86
+ */
87
+ uid?: string;
88
+ /** The names of groups this user is a part of. */
89
+ groups?: string[];
90
+ /** Any additional information provided by the authenticator. */
91
+ extra?: {
92
+ [key: string]: string[];
93
+ };
94
+ };
95
+ /** Object is the object from the incoming request prior to default values being applied */
96
+ readonly object: T;
97
+ /** OldObject is the existing object. Only populated for UPDATE requests. */
98
+ readonly oldObject?: T;
99
+ /** DryRun indicates that modifications will definitely not be persisted for this request. Defaults to false. */
100
+ readonly dryRun?: boolean;
101
+ /**
102
+ * Options contains the options for the operation being performed.
103
+ * e.g. `meta.k8s.io/v1.DeleteOptions` or `meta.k8s.io/v1.CreateOptions`. This may be
104
+ * different than the options the caller provided. e.g. for a patch request the performed
105
+ * Operation might be a CREATE, in which case the Options will a
106
+ * `meta.k8s.io/v1.CreateOptions` even though the caller provided `meta.k8s.io/v1.PatchOptions`.
107
+ */
108
+ readonly options?: any;
109
+ }
110
+ export interface Response {
111
+ /** UID is an identifier for the individual request/response. This must be copied over from the corresponding AdmissionRequest. */
112
+ uid: string;
113
+ /** Allowed indicates whether or not the admission request was permitted. */
114
+ allowed: boolean;
115
+ /** Result contains extra details into why an admission request was denied. This field IS NOT consulted in any way if "Allowed" is "true". */
116
+ result?: string;
117
+ /** The patch body. Currently we only support "JSONPatch" which implements RFC 6902. */
118
+ patch?: string;
119
+ /** The type of Patch. Currently we only allow "JSONPatch". */
120
+ patchType?: "JSONPatch";
121
+ /** AuditAnnotations is an unstructured key value map set by remote admission controller (e.g. error=image-blacklisted). */
122
+ auditAnnotations?: {
123
+ [key: string]: string;
124
+ };
125
+ /** warnings is a list of warning messages to return to the requesting API client. */
126
+ warnings?: string[];
127
+ }
128
+ export type WebhookIgnore = {
129
+ /**
130
+ * List of Kubernetes namespaces to always ignore.
131
+ * Any resources in these namespaces will be ignored by Pepr.
132
+ *
133
+ * Note: `kube-system` and `pepr-system` are always ignored.
134
+ */
135
+ namespaces?: string[];
136
+ /**
137
+ * List of Kubernetes labels to always ignore.
138
+ * Any resources with these labels will be ignored by Pepr.
139
+ *
140
+ * The example below will ignore any resources with the label `my-label=ulta-secret`:
141
+ * ```
142
+ * alwaysIgnore:
143
+ * labels: [{ "my-label": "ultra-secret" }]
144
+ * ```
145
+ */
146
+ labels?: Record<string, string>[];
147
+ };
148
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/lib/k8s/types.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,4 @@
1
+ /** a is a colleciton of K8s types to be used within a CapabilityAction: `When(a.Configmap)` */
2
+ export { V1APIService as APIService, V1CertificateSigningRequest as CertificateSigningRequest, V1ConfigMap as ConfigMap, V1ControllerRevision as ControllerRevision, V1CronJob as CronJob, V1CSIDriver as CSIDriver, V1CSIStorageCapacity as CSIStorageCapacity, V1CustomResourceDefinition as CustomResourceDefinition, V1DaemonSet as DaemonSet, V1Deployment as Deployment, V1EndpointSlice as EndpointSlice, V1HorizontalPodAutoscaler as HorizontalPodAutoscaler, V1Ingress as Ingress, V1IngressClass as IngressClass, V1Job as Job, V1LimitRange as LimitRange, V1LocalSubjectAccessReview as LocalSubjectAccessReview, V1MutatingWebhookConfiguration as MutatingWebhookConfiguration, V1Namespace as Namespace, V1NetworkPolicy as NetworkPolicy, V1Node as Node, V1PersistentVolume as PersistentVolume, V1PersistentVolumeClaim as PersistentVolumeClaim, V1Pod as Pod, V1PodDisruptionBudget as PodDisruptionBudget, V1PodTemplate as PodTemplate, V1ReplicaSet as ReplicaSet, V1ReplicationController as ReplicationController, V1ResourceQuota as ResourceQuota, V1RuntimeClass as RuntimeClass, V1Secret as Secret, V1SelfSubjectAccessReview as SelfSubjectAccessReview, V1SelfSubjectRulesReview as SelfSubjectRulesReview, V1Service as Service, V1ServiceAccount as ServiceAccount, V1StatefulSet as StatefulSet, V1StorageClass as StorageClass, V1SubjectAccessReview as SubjectAccessReview, V1TokenReview as TokenReview, V1ValidatingWebhookConfiguration as ValidatingWebhookConfiguration, V1VolumeAttachment as VolumeAttachment, } from "@kubernetes/client-node/dist";
3
+ export { GenericKind } from "./types";
4
+ //# sourceMappingURL=upstream.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"upstream.d.ts","sourceRoot":"","sources":["../../../../src/lib/k8s/upstream.ts"],"names":[],"mappings":"AAGA,+FAA+F;AAC/F,OAAO,EACL,YAAY,IAAI,UAAU,EAC1B,2BAA2B,IAAI,yBAAyB,EACxD,WAAW,IAAI,SAAS,EACxB,oBAAoB,IAAI,kBAAkB,EAC1C,SAAS,IAAI,OAAO,EACpB,WAAW,IAAI,SAAS,EACxB,oBAAoB,IAAI,kBAAkB,EAC1C,0BAA0B,IAAI,wBAAwB,EACtD,WAAW,IAAI,SAAS,EACxB,YAAY,IAAI,UAAU,EAC1B,eAAe,IAAI,aAAa,EAChC,yBAAyB,IAAI,uBAAuB,EACpD,SAAS,IAAI,OAAO,EACpB,cAAc,IAAI,YAAY,EAC9B,KAAK,IAAI,GAAG,EACZ,YAAY,IAAI,UAAU,EAC1B,0BAA0B,IAAI,wBAAwB,EACtD,8BAA8B,IAAI,4BAA4B,EAC9D,WAAW,IAAI,SAAS,EACxB,eAAe,IAAI,aAAa,EAChC,MAAM,IAAI,IAAI,EACd,kBAAkB,IAAI,gBAAgB,EACtC,uBAAuB,IAAI,qBAAqB,EAChD,KAAK,IAAI,GAAG,EACZ,qBAAqB,IAAI,mBAAmB,EAC5C,aAAa,IAAI,WAAW,EAC5B,YAAY,IAAI,UAAU,EAC1B,uBAAuB,IAAI,qBAAqB,EAChD,eAAe,IAAI,aAAa,EAChC,cAAc,IAAI,YAAY,EAC9B,QAAQ,IAAI,MAAM,EAClB,yBAAyB,IAAI,uBAAuB,EACpD,wBAAwB,IAAI,sBAAsB,EAClD,SAAS,IAAI,OAAO,EACpB,gBAAgB,IAAI,cAAc,EAClC,aAAa,IAAI,WAAW,EAC5B,cAAc,IAAI,YAAY,EAC9B,qBAAqB,IAAI,mBAAmB,EAC5C,aAAa,IAAI,WAAW,EAC5B,gCAAgC,IAAI,8BAA8B,EAClE,kBAAkB,IAAI,gBAAgB,GACvC,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC"}
@@ -0,0 +1,35 @@
1
+ /// <reference types="node" />
2
+ import { V1ClusterRole, V1ClusterRoleBinding, V1Deployment, V1MutatingWebhookConfiguration, V1Namespace, V1NetworkPolicy, V1Secret, V1Service, V1ServiceAccount } from "@kubernetes/client-node";
3
+ import { ModuleConfig } from "../types";
4
+ import { TLSOut } from "./tls";
5
+ export declare class Webhook {
6
+ private readonly config;
7
+ private readonly host?;
8
+ private name;
9
+ private _tls;
10
+ image: string;
11
+ get tls(): TLSOut;
12
+ constructor(config: ModuleConfig, host?: string | undefined);
13
+ /** Generate the pepr-system namespace */
14
+ namespace(): V1Namespace;
15
+ /**
16
+ * Grants the controller access to cluster resources beyond the mutating webhook.
17
+ *
18
+ * @todo: should dynamically generate this based on resources used by the module. will also need to explore how this should work for multiple modules.
19
+ * @returns
20
+ */
21
+ clusterRole(): V1ClusterRole;
22
+ clusterRoleBinding(): V1ClusterRoleBinding;
23
+ serviceAccount(): V1ServiceAccount;
24
+ tlsSecret(): V1Secret;
25
+ mutatingWebhook(): V1MutatingWebhookConfiguration;
26
+ deployment(hash: string): V1Deployment;
27
+ /** Only permit the kube-system ns ingress access to the controller */
28
+ networkPolicy(): V1NetworkPolicy;
29
+ service(): V1Service;
30
+ moduleSecret(data: Buffer, hash: string): V1Secret;
31
+ zarfYaml(path: string): string;
32
+ allYaml(code: Buffer): string;
33
+ deploy(code: Buffer): Promise<void>;
34
+ }
35
+ //# sourceMappingURL=webhook.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webhook.d.ts","sourceRoot":"","sources":["../../../../src/lib/k8s/webhook.ts"],"names":[],"mappings":";AAGA,OAAO,EASL,aAAa,EACb,oBAAoB,EACpB,YAAY,EAEZ,8BAA8B,EAC9B,WAAW,EACX,eAAe,EACf,QAAQ,EACR,SAAS,EACT,gBAAgB,EAEjB,MAAM,yBAAyB,CAAC;AAIjC,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,MAAM,EAAU,MAAM,OAAO,CAAC;AAQvC,qBAAa,OAAO;IAUN,OAAO,CAAC,QAAQ,CAAC,MAAM;IAAgB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC;IATzE,OAAO,CAAC,IAAI,CAAS;IACrB,OAAO,CAAC,IAAI,CAAS;IAEd,KAAK,EAAE,MAAM,CAAC;IAErB,IAAW,GAAG,IAAI,MAAM,CAEvB;gBAE4B,MAAM,EAAE,YAAY,EAAmB,IAAI,CAAC,oBAAQ;IASjF,yCAAyC;IACzC,SAAS,IAAI,WAAW;IAQxB;;;;;OAKG;IACH,WAAW,IAAI,aAAa;IAgB5B,kBAAkB,IAAI,oBAAoB;IAqB1C,cAAc,IAAI,gBAAgB;IAWlC,SAAS,IAAI,QAAQ;IAgBrB,eAAe,IAAI,8BAA8B;IA+DjD,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY;IAyFtC,sEAAsE;IACtE,aAAa,IAAI,eAAe;IAsChC,OAAO,IAAI,SAAS;IAsBpB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,QAAQ;IAkBlD,QAAQ,CAAC,IAAI,EAAE,MAAM;IA2BrB,OAAO,CAAC,IAAI,EAAE,MAAM;IAqBd,MAAM,CAAC,IAAI,EAAE,MAAM;CAqI1B"}
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Enumeration representing different logging levels.
3
+ */
4
+ export declare enum LogLevel {
5
+ debug = 0,
6
+ info = 1,
7
+ warn = 2,
8
+ error = 3
9
+ }
10
+ /**
11
+ * Simple logger class that logs messages at different log levels.
12
+ */
13
+ export declare class Logger {
14
+ private _logLevel;
15
+ /**
16
+ * Create a new logger instance.
17
+ * @param logLevel - The minimum log level to log messages for.
18
+ */
19
+ constructor(logLevel: LogLevel);
20
+ /**
21
+ * Change the log level of the logger.
22
+ * @param logLevel - The log level to log the message at.
23
+ */
24
+ SetLogLevel(logLevel: string): void;
25
+ /**
26
+ * Log a debug message.
27
+ * @param message - The message to log.
28
+ */
29
+ debug<T>(message: T, prefix?: string): void;
30
+ /**
31
+ * Log an info message.
32
+ * @param message - The message to log.
33
+ */
34
+ info<T>(message: T, prefix?: string): void;
35
+ /**
36
+ * Log a warning message.
37
+ * @param message - The message to log.
38
+ */
39
+ warn<T>(message: T, prefix?: string): void;
40
+ /**
41
+ * Log an error message.
42
+ * @param message - The message to log.
43
+ */
44
+ error<T>(message: T, prefix?: string): void;
45
+ /**
46
+ * Log a message at the specified log level.
47
+ * @param logLevel - The log level of the message.
48
+ * @param message - The message to log.
49
+ */
50
+ private log;
51
+ private colorize;
52
+ }
53
+ /** Log is an instance of Logger used to generate log entries. */
54
+ declare const Log: Logger;
55
+ export default Log;
56
+ //# sourceMappingURL=logger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../../src/lib/logger.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,oBAAY,QAAQ;IAClB,KAAK,IAAI;IACT,IAAI,IAAI;IACR,IAAI,IAAI;IACR,KAAK,IAAI;CACV;AA8BD;;GAEG;AACH,qBAAa,MAAM;IACjB,OAAO,CAAC,SAAS,CAAW;IAE5B;;;OAGG;gBACS,QAAQ,EAAE,QAAQ;IAI9B;;;OAGG;IACI,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAK1C;;;OAGG;IACI,KAAK,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI;IAIlD;;;OAGG;IACI,IAAI,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI;IAIjD;;;OAGG;IACI,IAAI,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI;IAIjD;;;OAGG;IACI,KAAK,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI;IAIlD;;;;OAIG;IACH,OAAO,CAAC,GAAG;IAwBX,OAAO,CAAC,QAAQ;CAGjB;AAED,iEAAiE;AACjE,QAAA,MAAM,GAAG,QAA4B,CAAC;AAItC,eAAe,GAAG,CAAC"}