pepr 0.13.3 → 0.14.0

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 (106) hide show
  1. package/README.md +23 -4
  2. package/dist/cli.js +455 -266
  3. package/dist/controller.js +1 -1
  4. package/dist/lib/assets/deploy.d.ts.map +1 -1
  5. package/dist/lib/assets/destroy.d.ts +2 -0
  6. package/dist/lib/assets/destroy.d.ts.map +1 -0
  7. package/dist/lib/assets/index.d.ts +6 -5
  8. package/dist/lib/assets/index.d.ts.map +1 -1
  9. package/dist/lib/assets/networking.d.ts +6 -5
  10. package/dist/lib/assets/networking.d.ts.map +1 -1
  11. package/dist/lib/assets/pods.d.ts +84 -4
  12. package/dist/lib/assets/pods.d.ts.map +1 -1
  13. package/dist/lib/assets/rbac.d.ts +6 -4
  14. package/dist/lib/assets/rbac.d.ts.map +1 -1
  15. package/dist/lib/assets/store.d.ts +7 -0
  16. package/dist/lib/assets/store.d.ts.map +1 -0
  17. package/dist/lib/assets/webhooks.d.ts +2 -2
  18. package/dist/lib/assets/webhooks.d.ts.map +1 -1
  19. package/dist/lib/assets/yaml.d.ts.map +1 -1
  20. package/dist/lib/capability.d.ts +21 -4
  21. package/dist/lib/capability.d.ts.map +1 -1
  22. package/dist/lib/controller/index.d.ts +10 -0
  23. package/dist/lib/controller/index.d.ts.map +1 -0
  24. package/dist/lib/controller/store.d.ts +7 -0
  25. package/dist/lib/controller/store.d.ts.map +1 -0
  26. package/dist/lib/filter.d.ts +2 -2
  27. package/dist/lib/filter.d.ts.map +1 -1
  28. package/dist/lib/{k8s/types.d.ts → k8s.d.ts} +14 -25
  29. package/dist/lib/k8s.d.ts.map +1 -0
  30. package/dist/lib/metrics.d.ts +12 -12
  31. package/dist/lib/metrics.d.ts.map +1 -1
  32. package/dist/lib/module.d.ts +25 -4
  33. package/dist/lib/module.d.ts.map +1 -1
  34. package/dist/lib/mutate-processor.d.ts +3 -3
  35. package/dist/lib/mutate-processor.d.ts.map +1 -1
  36. package/dist/lib/mutate-request.d.ts +11 -10
  37. package/dist/lib/mutate-request.d.ts.map +1 -1
  38. package/dist/lib/storage.d.ts +56 -0
  39. package/dist/lib/storage.d.ts.map +1 -0
  40. package/dist/lib/tls.d.ts.map +1 -0
  41. package/dist/lib/types.d.ts +28 -48
  42. package/dist/lib/types.d.ts.map +1 -1
  43. package/dist/lib/validate-processor.d.ts +2 -2
  44. package/dist/lib/validate-processor.d.ts.map +1 -1
  45. package/dist/lib/validate-request.d.ts +9 -8
  46. package/dist/lib/validate-request.d.ts.map +1 -1
  47. package/dist/lib/watch-processor.d.ts +3 -0
  48. package/dist/lib/watch-processor.d.ts.map +1 -0
  49. package/dist/lib.d.ts +3 -7
  50. package/dist/lib.d.ts.map +1 -1
  51. package/dist/lib.js +484 -807
  52. package/dist/lib.js.map +4 -4
  53. package/package.json +16 -20
  54. package/src/lib/assets/deploy.ts +69 -127
  55. package/src/lib/assets/destroy.ts +33 -0
  56. package/src/lib/assets/index.ts +8 -14
  57. package/src/lib/assets/networking.ts +28 -5
  58. package/src/lib/assets/pods.ts +130 -11
  59. package/src/lib/assets/rbac.ts +42 -4
  60. package/src/lib/assets/store.ts +49 -0
  61. package/src/lib/assets/webhooks.ts +2 -2
  62. package/src/lib/assets/yaml.ts +13 -3
  63. package/src/lib/capability.ts +69 -14
  64. package/src/lib/{controller.ts → controller/index.ts} +25 -23
  65. package/src/lib/controller/store.ts +197 -0
  66. package/src/lib/filter.ts +2 -2
  67. package/src/lib/{k8s/types.ts → k8s.ts} +15 -26
  68. package/src/lib/metrics.ts +22 -38
  69. package/src/lib/module.ts +47 -10
  70. package/src/lib/mutate-processor.ts +6 -6
  71. package/src/lib/mutate-request.ts +18 -26
  72. package/src/lib/storage.ts +128 -0
  73. package/src/lib/types.ts +30 -53
  74. package/src/lib/validate-processor.ts +5 -4
  75. package/src/lib/validate-request.ts +15 -19
  76. package/src/lib/watch-processor.ts +55 -0
  77. package/src/lib.ts +4 -8
  78. package/src/templates/.eslintrc.template.json +18 -0
  79. package/src/templates/capabilities/hello-pepr.ts +54 -5
  80. package/src/templates/package.json +1 -0
  81. package/dist/lib/controller.d.ts +0 -10
  82. package/dist/lib/controller.d.ts.map +0 -1
  83. package/dist/lib/fetch.d.ts +0 -23
  84. package/dist/lib/fetch.d.ts.map +0 -1
  85. package/dist/lib/k8s/index.d.ts +0 -7
  86. package/dist/lib/k8s/index.d.ts.map +0 -1
  87. package/dist/lib/k8s/kinds.d.ts +0 -12
  88. package/dist/lib/k8s/kinds.d.ts.map +0 -1
  89. package/dist/lib/k8s/tls.d.ts.map +0 -1
  90. package/dist/lib/k8s/types.d.ts.map +0 -1
  91. package/dist/lib/k8s/upstream.d.ts +0 -4
  92. package/dist/lib/k8s/upstream.d.ts.map +0 -1
  93. package/jest.config.json +0 -4
  94. package/journey/before.ts +0 -21
  95. package/journey/k8s.ts +0 -100
  96. package/journey/pepr-build.ts +0 -69
  97. package/journey/pepr-deploy.ts +0 -174
  98. package/journey/pepr-dev.ts +0 -155
  99. package/journey/pepr-format.ts +0 -13
  100. package/journey/pepr-init.ts +0 -12
  101. package/src/lib/fetch.ts +0 -76
  102. package/src/lib/k8s/index.ts +0 -14
  103. package/src/lib/k8s/kinds.ts +0 -531
  104. package/src/lib/k8s/upstream.ts +0 -53
  105. /package/dist/lib/{k8s/tls.d.ts → tls.d.ts} +0 -0
  106. /package/src/lib/{k8s/tls.ts → tls.ts} +0 -0
@@ -48,7 +48,7 @@ if (process.env.LOG_LEVEL) {
48
48
  var logger_default = Log;
49
49
 
50
50
  // src/templates/data.json
51
- var packageJSON = { name: "pepr", description: "Kubernetes application engine", author: "Defense Unicorns", homepage: "https://github.com/defenseunicorns/pepr", license: "Apache-2.0", bin: "dist/cli.js", repository: "defenseunicorns/pepr", engines: { node: ">=18.0.0" }, version: "0.13.3", main: "dist/lib.js", types: "dist/lib.d.ts", scripts: { "gen-data-json": "node hack/build-template-data.js", prebuild: "rm -fr dist/* && npm run gen-data-json", build: "tsc && node build.mjs", test: "npm run test:unit && npm run test:journey", "test:unit": "npm run gen-data-json && jest src --coverage", "test:journey": "npm run test:journey:k3d && npm run test:journey:build && npm run test:journey:image && npm run test:journey:run", "test:journey:k3d": "k3d cluster delete pepr-dev && k3d cluster create pepr-dev --k3s-arg '--debug@server:0'", "test:journey:build": "npm run build && npm pack", "test:journey:image": "docker buildx build --tag pepr:dev . && k3d image import pepr:dev -c pepr-dev", "test:journey:run": "jest journey/entrypoint.test.ts", "format:check": "eslint src && prettier src --check", "format:fix": "eslint src --fix && prettier src --write" }, dependencies: { "@kubernetes/client-node": "0.18.1", express: "4.18.2", "fast-json-patch": "3.1.1", "http-status-codes": "2.2.0", "node-fetch": "2.7.0", pino: "8.15.1", "pino-pretty": "10.2.0", "prom-client": "14.2.0", ramda: "0.29.0" }, devDependencies: { "@jest/globals": "29.6.4", "@types/eslint": "8.44.2", "@types/express": "4.17.17", "@types/node": "18.x.x", "@types/node-fetch": "2.6.4", "@types/node-forge": "1.3.4", "@types/prettier": "3.0.0", "@types/prompts": "2.4.4", "@types/ramda": "0.29.3", "@types/uuid": "9.0.3", jest: "29.6.4", nock: "13.3.3", "ts-jest": "29.1.1" }, peerDependencies: { "@typescript-eslint/eslint-plugin": "6.5.0", "@typescript-eslint/parser": "6.5.0", commander: "11.0.0", esbuild: "0.19.2", eslint: "8.48.0", "node-forge": "1.3.1", prettier: "3.0.3", prompts: "2.4.2", typescript: "5.2.2", uuid: "9.0.0" } };
51
+ var packageJSON = { name: "pepr", description: "Kubernetes application engine", author: "Defense Unicorns", homepage: "https://github.com/defenseunicorns/pepr", license: "Apache-2.0", bin: "dist/cli.js", repository: "defenseunicorns/pepr", engines: { node: ">=18.0.0" }, version: "0.14.0", main: "dist/lib.js", types: "dist/lib.d.ts", scripts: { "gen-data-json": "node hack/build-template-data.js", prebuild: "rm -fr dist/* && npm run gen-data-json", build: "tsc && node build.mjs", test: "npm run test:unit && npm run test:journey", "test:unit": "npm run gen-data-json && jest src --coverage", "test:journey": "npm run test:journey:k3d && npm run test:journey:build && npm run test:journey:image && npm run test:journey:run", "test:journey:k3d": "k3d cluster delete pepr-dev && k3d cluster create pepr-dev --k3s-arg '--debug@server:0'", "test:journey:build": "npm run build && npm pack", "test:journey:image": "docker buildx build --tag pepr:dev . && k3d image import pepr:dev -c pepr-dev", "test:journey:run": "jest journey/entrypoint.test.ts", "format:check": "eslint src && prettier src --check", "format:fix": "eslint src --fix && prettier src --write" }, dependencies: { express: "4.18.2", "fast-json-patch": "3.1.1", "kubernetes-fluent-client": "1.4.1", pino: "8.15.3", "pino-pretty": "10.2.0", "prom-client": "14.2.0", ramda: "0.29.0" }, devDependencies: { "@jest/globals": "29.7.0", "@types/eslint": "8.44.3", "@types/express": "4.17.18", "@types/node": "18.x.x", "@types/node-forge": "1.3.6", "@types/prompts": "2.4.5", "@types/ramda": "0.29.5", "@types/uuid": "9.0.4", jest: "29.7.0", nock: "13.3.3", "ts-jest": "29.1.1" }, peerDependencies: { "@typescript-eslint/eslint-plugin": "6.7.3", "@typescript-eslint/parser": "6.7.3", commander: "11.0.0", esbuild: "0.19.4", eslint: "8.50.0", "node-forge": "1.3.1", prettier: "3.0.3", prompts: "2.4.2", typescript: "5.2.2", uuid: "9.0.1" } };
52
52
 
53
53
  // src/runtime/controller.ts
54
54
  var { version } = packageJSON;
@@ -1 +1 @@
1
- {"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../../src/lib/assets/deploy.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,CAAC;AAO3B,wBAAsB,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,MAAM,iBA6JnE"}
1
+ {"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../../src/lib/assets/deploy.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,CAAC;AAQ3B,wBAAsB,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,MAAM,iBA8CnE"}
@@ -0,0 +1,2 @@
1
+ export declare function destroyModule(name: string): Promise<void>;
2
+ //# sourceMappingURL=destroy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"destroy.d.ts","sourceRoot":"","sources":["../../../src/lib/assets/destroy.ts"],"names":[],"mappings":"AAQA,wBAAsB,aAAa,CAAC,IAAI,EAAE,MAAM,iBAwB/C"}
@@ -1,5 +1,6 @@
1
- import { TLSOut } from "../k8s/tls";
2
- import { CapabilityExport, ModuleConfig } from "../types";
1
+ import { ModuleConfig } from "../module";
2
+ import { TLSOut } from "../tls";
3
+ import { CapabilityExport } from "../types";
3
4
  export declare class Assets {
4
5
  readonly config: ModuleConfig;
5
6
  readonly path: string;
@@ -10,8 +11,8 @@ export declare class Assets {
10
11
  capabilities: CapabilityExport[];
11
12
  image: string;
12
13
  constructor(config: ModuleConfig, path: string, host?: string | undefined);
13
- deploy(webhookTimeout?: number): Promise<void>;
14
- zarfYaml(path: string): string;
15
- allYaml(): Promise<string>;
14
+ deploy: (webhookTimeout?: number) => Promise<void>;
15
+ zarfYaml: (path: string) => string;
16
+ allYaml: () => Promise<string>;
16
17
  }
17
18
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/assets/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,MAAM,EAAU,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAK1D,qBAAa,MAAM;IAQf,QAAQ,CAAC,MAAM,EAAE,YAAY;IAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM;IACrB,QAAQ,CAAC,IAAI,CAAC;IAThB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,YAAY,EAAG,gBAAgB,EAAE,CAAC;IAClC,KAAK,EAAE,MAAM,CAAC;gBAGH,MAAM,EAAE,YAAY,EACpB,IAAI,EAAE,MAAM,EACZ,IAAI,CAAC,oBAAQ;IAkBlB,MAAM,CAAC,cAAc,CAAC,EAAE,MAAM;IAKpC,QAAQ,CAAC,IAAI,EAAE,MAAM;IAIf,OAAO;CAId"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/assets/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,MAAM,EAAU,MAAM,QAAQ,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAK5C,qBAAa,MAAM;IAQf,QAAQ,CAAC,MAAM,EAAE,YAAY;IAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM;IACrB,QAAQ,CAAC,IAAI,CAAC;IAThB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,YAAY,EAAG,gBAAgB,EAAE,CAAC;IAClC,KAAK,EAAE,MAAM,CAAC;gBAGH,MAAM,EAAE,YAAY,EACpB,IAAI,EAAE,MAAM,EACZ,IAAI,CAAC,oBAAQ;IAaxB,MAAM,oBAA2B,MAAM,mBAGrC;IAEF,QAAQ,SAAU,MAAM,YAA0B;IAElD,OAAO,wBAGL;CACH"}
@@ -1,6 +1,7 @@
1
- import { TLSOut } from "../k8s/tls";
2
- import { Secret, Service } from "../k8s/upstream";
3
- export declare function apiTokenSecret(name: string, apiToken: string): Secret;
4
- export declare function tlsSecret(name: string, tls: TLSOut): Secret;
5
- export declare function service(name: string): Service;
1
+ import { kind } from "kubernetes-fluent-client";
2
+ import { TLSOut } from "../tls";
3
+ export declare function apiTokenSecret(name: string, apiToken: string): kind.Secret;
4
+ export declare function tlsSecret(name: string, tls: TLSOut): kind.Secret;
5
+ export declare function service(name: string): kind.Service;
6
+ export declare function watcherService(name: string): kind.Service;
6
7
  //# sourceMappingURL=networking.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"networking.d.ts","sourceRoot":"","sources":["../../../src/lib/assets/networking.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAElD,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAarE;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAc3D;AAED,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAoB7C"}
1
+ {"version":3,"file":"networking.d.ts","sourceRoot":"","sources":["../../../src/lib/assets/networking.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAEhD,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC,MAAM,CAa1E;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC,MAAM,CAchE;AAED,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC,OAAO,CAoBlD;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC,OAAO,CAoBzD"}
@@ -1,8 +1,88 @@
1
1
  /// <reference types="node" />
2
+ import { kind } from "kubernetes-fluent-client";
2
3
  import { Assets } from ".";
3
- import { Deployment, Namespace, Secret } from "../k8s/upstream";
4
4
  /** Generate the pepr-system namespace */
5
- export declare const namespace: Namespace;
6
- export declare function deployment(assets: Assets, hash: string): Deployment;
7
- export declare function moduleSecret(name: string, data: Buffer, hash: string): Secret;
5
+ export declare const namespace: kind.Namespace;
6
+ export declare function watcher(assets: Assets, hash: string): {
7
+ apiVersion: string;
8
+ kind: string;
9
+ metadata: {
10
+ name: string;
11
+ namespace: string;
12
+ labels: {
13
+ app: string;
14
+ };
15
+ };
16
+ spec: {
17
+ replicas: number;
18
+ strategy: {
19
+ type: string;
20
+ };
21
+ selector: {
22
+ matchLabels: {
23
+ app: string;
24
+ };
25
+ };
26
+ template: {
27
+ metadata: {
28
+ labels: {
29
+ app: string;
30
+ };
31
+ };
32
+ spec: {
33
+ serviceAccountName: string;
34
+ containers: {
35
+ name: string;
36
+ image: string;
37
+ imagePullPolicy: string;
38
+ command: string[];
39
+ readinessProbe: {
40
+ httpGet: {
41
+ path: string;
42
+ port: number;
43
+ scheme: string;
44
+ };
45
+ };
46
+ livenessProbe: {
47
+ httpGet: {
48
+ path: string;
49
+ port: number;
50
+ scheme: string;
51
+ };
52
+ };
53
+ ports: {
54
+ containerPort: number;
55
+ }[];
56
+ resources: {
57
+ requests: {
58
+ memory: string;
59
+ cpu: string;
60
+ };
61
+ limits: {
62
+ memory: string;
63
+ cpu: string;
64
+ };
65
+ };
66
+ volumeMounts: {
67
+ name: string;
68
+ mountPath: string;
69
+ readOnly: boolean;
70
+ }[];
71
+ env: {
72
+ name: string;
73
+ value: string;
74
+ }[];
75
+ }[];
76
+ volumes: {
77
+ name: string;
78
+ secret: {
79
+ secretName: string;
80
+ };
81
+ }[];
82
+ };
83
+ };
84
+ };
85
+ } | null;
86
+ export declare function deployment(assets: Assets, hash: string): kind.Deployment;
87
+ export declare function moduleSecret(name: string, data: Buffer, hash: string): kind.Secret;
8
88
  //# sourceMappingURL=pods.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"pods.d.ts","sourceRoot":"","sources":["../../../src/lib/assets/pods.ts"],"names":[],"mappings":";AAKA,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,CAAC;AAC3B,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAEhE,yCAAyC;AACzC,eAAO,MAAM,SAAS,EAAE,SAIvB,CAAC;AAEF,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,UAAU,CAkHnE;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAgB7E"}
1
+ {"version":3,"file":"pods.d.ts","sourceRoot":"","sources":["../../../src/lib/assets/pods.ts"],"names":[],"mappings":";AAGA,OAAO,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAGhD,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,CAAC;AAG3B,yCAAyC;AACzC,eAAO,MAAM,SAAS,EAAE,IAAI,CAAC,SAI5B,CAAC;AAEF,wBAAgB,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAsHnD;AAED,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC,UAAU,CAgHxE;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC,MAAM,CAgBlF"}
@@ -1,11 +1,13 @@
1
- import { ClusterRole, ClusterRoleBinding, ServiceAccount } from "../k8s/upstream";
1
+ import { kind } from "kubernetes-fluent-client";
2
2
  /**
3
3
  * Grants the controller access to cluster resources beyond the mutating webhook.
4
4
  *
5
5
  * @todo: should dynamically generate this based on resources used by the module. will also need to explore how this should work for multiple modules.
6
6
  * @returns
7
7
  */
8
- export declare function clusterRole(name: string): ClusterRole;
9
- export declare function clusterRoleBinding(name: string): ClusterRoleBinding;
10
- export declare function serviceAccount(name: string): ServiceAccount;
8
+ export declare function clusterRole(name: string): kind.ClusterRole;
9
+ export declare function clusterRoleBinding(name: string): kind.ClusterRoleBinding;
10
+ export declare function serviceAccount(name: string): kind.ServiceAccount;
11
+ export declare function storeRole(name: string): kind.Role;
12
+ export declare function storeRoleBinding(name: string): kind.RoleBinding;
11
13
  //# sourceMappingURL=rbac.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"rbac.d.ts","sourceRoot":"","sources":["../../../src/lib/assets/rbac.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAElF;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,CAcrD;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,kBAAkB,CAkBnE;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,CAS3D"}
1
+ {"version":3,"file":"rbac.d.ts","sourceRoot":"","sources":["../../../src/lib/assets/rbac.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAEhD;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC,WAAW,CAc1D;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC,kBAAkB,CAkBxE;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC,cAAc,CAShE;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC,IAAI,CAejD;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC,WAAW,CAmB/D"}
@@ -0,0 +1,7 @@
1
+ import { kind as k } from "kubernetes-fluent-client";
2
+ export declare const group: string, version: string, kind: string;
3
+ export declare const singular: string;
4
+ export declare const plural: string;
5
+ export declare const name: string;
6
+ export declare const peprStoreCRD: k.CustomResourceDefinition;
7
+ //# sourceMappingURL=store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../../src/lib/assets/store.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,IAAI,IAAI,CAAC,EAAE,MAAM,0BAA0B,CAAC;AAIrD,eAAO,MAAQ,KAAK,UAAE,OAAO,UAAE,IAAI,QAAiB,CAAC;AACrD,eAAO,MAAM,QAAQ,QAA2B,CAAC;AACjD,eAAO,MAAM,MAAM,QAAiB,CAAC;AACrC,eAAO,MAAM,IAAI,QAAuB,CAAC;AAEzC,eAAO,MAAM,YAAY,EAAE,CAAC,CAAC,wBAoC5B,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import { V1RuleWithOperations } from "@kubernetes/client-node";
2
+ import { kind } from "kubernetes-fluent-client";
2
3
  import { Assets } from ".";
3
- import { MutatingWebhookConfiguration, ValidatingWebhookConfiguration } from "../k8s/upstream";
4
4
  export declare function generateWebhookRules(assets: Assets, isMutateWebhook: boolean): Promise<V1RuleWithOperations[]>;
5
- export declare function webhookConfig(assets: Assets, mutateOrValidate: "mutate" | "validate", timeoutSeconds?: number): Promise<MutatingWebhookConfiguration | ValidatingWebhookConfiguration | null>;
5
+ export declare function webhookConfig(assets: Assets, mutateOrValidate: "mutate" | "validate", timeoutSeconds?: number): Promise<kind.MutatingWebhookConfiguration | kind.ValidatingWebhookConfiguration | null>;
6
6
  //# sourceMappingURL=webhooks.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"webhooks.d.ts","sourceRoot":"","sources":["../../../src/lib/assets/webhooks.ts"],"names":[],"mappings":"AAGA,OAAO,EAGL,oBAAoB,EACrB,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,CAAC;AAC3B,OAAO,EAAE,4BAA4B,EAAE,8BAA8B,EAAE,MAAM,iBAAiB,CAAC;AAW/F,wBAAsB,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,eAAe,EAAE,OAAO,mCA4ClF;AAED,wBAAsB,aAAa,CACjC,MAAM,EAAE,MAAM,EACd,gBAAgB,EAAE,QAAQ,GAAG,UAAU,EACvC,cAAc,SAAK,GAClB,OAAO,CAAC,4BAA4B,GAAG,8BAA8B,GAAG,IAAI,CAAC,CAkE/E"}
1
+ {"version":3,"file":"webhooks.d.ts","sourceRoot":"","sources":["../../../src/lib/assets/webhooks.ts"],"names":[],"mappings":"AAGA,OAAO,EAGL,oBAAoB,EACrB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAGhD,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,CAAC;AAW3B,wBAAsB,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,eAAe,EAAE,OAAO,mCA4ClF;AAED,wBAAsB,aAAa,CACjC,MAAM,EAAE,MAAM,EACd,gBAAgB,EAAE,QAAQ,GAAG,UAAU,EACvC,cAAc,SAAK,GAClB,OAAO,CAAC,IAAI,CAAC,4BAA4B,GAAG,IAAI,CAAC,8BAA8B,GAAG,IAAI,CAAC,CAkEzF"}
@@ -1 +1 @@
1
- {"version":3,"file":"yaml.d.ts","sourceRoot":"","sources":["../../../src/lib/assets/yaml.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,CAAC;AAM3B,wBAAgB,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,UA0BrE;AAED,wBAAsB,OAAO,CAAC,MAAM,EAAE,MAAM,mBAiC3C"}
1
+ {"version":3,"file":"yaml.d.ts","sourceRoot":"","sources":["../../../src/lib/assets/yaml.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,CAAC;AAO3B,wBAAgB,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,UA0BrE;AAED,wBAAsB,OAAO,CAAC,MAAM,EAAE,MAAM,mBA0C3C"}
@@ -1,17 +1,34 @@
1
- import { GroupVersionKind } from "./k8s/types";
2
- import { Binding, CapabilityCfg, CapabilityExport, GenericClass, WhenSelector } from "./types";
1
+ import { GenericClass, GroupVersionKind } from "kubernetes-fluent-client";
2
+ import { PeprStore, Storage } from "./storage";
3
+ import { Binding, CapabilityCfg, CapabilityExport, WhenSelector } from "./types";
3
4
  /**
4
5
  * A capability is a unit of functionality that can be registered with the Pepr runtime.
5
6
  */
6
7
  export declare class Capability implements CapabilityExport {
7
8
  #private;
9
+ /**
10
+ * Store is a key-value data store that can be used to persist data that should be shared
11
+ * between requests. Each capability has its own store, and the data is persisted in Kubernetes
12
+ * in the `pepr-system` namespace.
13
+ *
14
+ * Note: You should only access the store from within an action.
15
+ */
16
+ Store: PeprStore;
8
17
  get bindings(): Binding[];
9
18
  get name(): string;
10
19
  get description(): string;
11
20
  get namespaces(): string[];
12
21
  constructor(cfg: CapabilityCfg);
13
22
  /**
14
- * The When method is used to register a capability action to be executed when a Kubernetes resource is
23
+ * Register the store with the capability. This is called automatically by the Pepr controller.
24
+ *
25
+ * @param store
26
+ */
27
+ registerStore: () => {
28
+ store: Storage;
29
+ };
30
+ /**
31
+ * The When method is used to register a action to be executed when a Kubernetes resource is
15
32
  * processed by Pepr. The action will be executed if the resource matches the specified kind and any
16
33
  * filters that are applied.
17
34
  *
@@ -19,6 +36,6 @@ export declare class Capability implements CapabilityExport {
19
36
  * @param kind if using a custom KubernetesObject not available in `a.*`, specify the GroupVersionKind
20
37
  * @returns
21
38
  */
22
- When<T extends GenericClass>(model: T, kind?: GroupVersionKind): WhenSelector<T>;
39
+ When: <T extends GenericClass>(model: T, kind?: GroupVersionKind) => WhenSelector<T>;
23
40
  }
24
41
  //# sourceMappingURL=capability.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"capability.d.ts","sourceRoot":"","sources":["../../src/lib/capability.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,EACL,OAAO,EAGP,aAAa,EACb,gBAAgB,EAEhB,YAAY,EAIZ,YAAY,EACb,MAAM,SAAS,CAAC;AAEjB;;GAEG;AACH,qBAAa,UAAW,YAAW,gBAAgB;;IAMjD,IAAI,QAAQ,cAEX;IAED,IAAI,IAAI,WAEP;IAED,IAAI,WAAW,WAEd;IAED,IAAI,UAAU,aAEb;gBAEW,GAAG,EAAE,aAAa;IAY9B;;;;;;;;OAQG;IACH,IAAI,CAAC,CAAC,SAAS,YAAY,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,CAAC,EAAE,gBAAgB,GAAG,YAAY,CAAC,CAAC,CAAC;CAuGjF"}
1
+ {"version":3,"file":"capability.d.ts","sourceRoot":"","sources":["../../src/lib/capability.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAA2B,MAAM,0BAA0B,CAAC;AAMnG,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EACL,OAAO,EAGP,aAAa,EACb,gBAAgB,EAMhB,YAAY,EACb,MAAM,SAAS,CAAC;AAKjB;;GAEG;AACH,qBAAa,UAAW,YAAW,gBAAgB;;IAQjD;;;;;;OAMG;IACH,KAAK,EAAE,SAAS,CAOd;IAEF,IAAI,QAAQ,cAEX;IAED,IAAI,IAAI,WAEP;IAED,IAAI,WAAW,WAEd;IAED,IAAI,UAAU,aAEb;gBAEW,GAAG,EAAE,aAAa;IAS9B;;;;OAIG;IACH,aAAa;;MAaX;IAEF;;;;;;;;OAQG;IACH,IAAI,4CAA6C,gBAAgB,qBAqH/D;CACH"}
@@ -0,0 +1,10 @@
1
+ import { Capability } from "../capability";
2
+ import { MutateResponse, AdmissionRequest } from "../k8s";
3
+ import { ModuleConfig } from "../module";
4
+ export declare class Controller {
5
+ #private;
6
+ constructor(config: ModuleConfig, capabilities: Capability[], beforeHook?: (req: AdmissionRequest) => void, afterHook?: (res: MutateResponse) => void, onReady?: () => void);
7
+ /** Start the webhook server */
8
+ startServer: (port: number) => void;
9
+ }
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/controller/index.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAoB,MAAM,QAAQ,CAAC;AAG5E,OAAO,EAAE,YAAY,EAAe,MAAM,WAAW,CAAC;AAKtD,qBAAa,UAAU;;gBAoBnB,MAAM,EAAE,YAAY,EACpB,YAAY,EAAE,UAAU,EAAE,EAC1B,UAAU,CAAC,EAAE,CAAC,GAAG,EAAE,gBAAgB,KAAK,IAAI,EAC5C,SAAS,CAAC,EAAE,CAAC,GAAG,EAAE,cAAc,KAAK,IAAI,EACzC,OAAO,CAAC,EAAE,MAAM,IAAI;IA6BtB,+BAA+B;IAC/B,WAAW,SAAU,MAAM,UAqDzB;CAoKH"}
@@ -0,0 +1,7 @@
1
+ import { Capability } from "../capability";
2
+ import { ModuleConfig } from "../module";
3
+ export declare class PeprControllerStore {
4
+ #private;
5
+ constructor(config: ModuleConfig, capabilities: Capability[], onReady?: () => void);
6
+ }
7
+ //# sourceMappingURL=store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../../src/lib/controller/store.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAG3C,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAMzC,qBAAa,mBAAmB;;gBAMlB,MAAM,EAAE,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,EAAE,OAAO,CAAC,EAAE,MAAM,IAAI;CA8KnF"}
@@ -1,4 +1,4 @@
1
- import { Request } from "./k8s/types";
1
+ import { AdmissionRequest } from "./k8s";
2
2
  import { Binding } from "./types";
3
3
  /**
4
4
  * shouldSkipRequest determines if a request should be skipped based on the binding filters.
@@ -7,5 +7,5 @@ import { Binding } from "./types";
7
7
  * @param req the incoming request
8
8
  * @returns
9
9
  */
10
- export declare function shouldSkipRequest(binding: Binding, req: Request, capabilityNamespaces: string[]): boolean;
10
+ export declare function shouldSkipRequest(binding: Binding, req: AdmissionRequest, capabilityNamespaces: string[]): boolean;
11
11
  //# sourceMappingURL=filter.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"filter.d.ts","sourceRoot":"","sources":["../../src/lib/filter.ts"],"names":[],"mappings":"AAGA,OAAO,EAAa,OAAO,EAAE,MAAM,aAAa,CAAC;AAEjD,OAAO,EAAE,OAAO,EAAS,MAAM,SAAS,CAAC;AAEzC;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,oBAAoB,EAAE,MAAM,EAAE,WA4E/F"}
1
+ {"version":3,"file":"filter.d.ts","sourceRoot":"","sources":["../../src/lib/filter.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAa,MAAM,OAAO,CAAC;AAEpD,OAAO,EAAE,OAAO,EAAS,MAAM,SAAS,CAAC;AAEzC;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,EAAE,WA4ExG"}
@@ -1,5 +1,4 @@
1
- import { KubernetesListObject, KubernetesObject, V1ObjectMeta } from "@kubernetes/client-node";
2
- export { KubernetesListObject, KubernetesObject };
1
+ import { GenericKind, GroupVersionKind, KubernetesObject } from "kubernetes-fluent-client";
3
2
  export declare enum Operation {
4
3
  CREATE = "CREATE",
5
4
  UPDATE = "UPDATE",
@@ -7,28 +6,18 @@ export declare enum Operation {
7
6
  CONNECT = "CONNECT"
8
7
  }
9
8
  /**
10
- * GenericKind is a generic Kubernetes object that can be used to represent any Kubernetes object
11
- * that is not explicitly supported by Pepr. This can be used on its own or as a base class for
12
- * other types. See the examples in `HelloPepr.ts` for more information.
9
+ * PeprStore for internal use by Pepr. This is used to store arbitrary data in the cluster.
13
10
  */
14
- export declare class GenericKind {
15
- apiVersion?: string;
16
- kind?: string;
17
- metadata?: V1ObjectMeta;
18
- [key: string]: any;
19
- }
20
- /**
21
- * GroupVersionKind unambiguously identifies a kind. It doesn't anonymously include GroupVersion
22
- * to avoid automatic coercion. It doesn't use a GroupVersion to avoid custom marshalling
23
- **/
24
- export interface GroupVersionKind {
25
- /** The K8s resource kind, e..g "Pod". */
26
- readonly kind: string;
27
- readonly group: string;
28
- readonly version?: string;
29
- /** Optional, override the plural name for use in Webhook rules generation */
30
- readonly plural?: string;
11
+ export declare class PeprStore extends GenericKind {
12
+ data: {
13
+ [key: string]: string;
14
+ };
31
15
  }
16
+ export declare const peprStoreGVK: {
17
+ kind: string;
18
+ version: string;
19
+ group: string;
20
+ };
32
21
  /**
33
22
  * GroupVersionResource unambiguously identifies a resource. It doesn't anonymously include GroupVersion
34
23
  * to avoid automatic coercion. It doesn't use a GroupVersion to avoid custom marshalling
@@ -41,7 +30,7 @@ export interface GroupVersionResource {
41
30
  /**
42
31
  * A Kubernetes admission request to be processed by a capability.
43
32
  */
44
- export interface Request<T = KubernetesObject> {
33
+ export interface AdmissionRequest<T = KubernetesObject> {
45
34
  /** UID is an identifier for the individual request/response. */
46
35
  readonly uid: string;
47
36
  /** Kind is the fully-qualified type of object being submitted (for example, v1.Pod or autoscaling.v1.Scale) */
@@ -125,7 +114,7 @@ export interface ValidateResponse extends MutateResponse {
125
114
  /** Status contains extra details into why an admission request was denied. This field IS NOT consulted in any way if "Allowed" is "true". */
126
115
  status?: {
127
116
  /** A machine-readable description of why this operation is in the
128
- "Failure" status. If this value is empty there is no information available. */
117
+ "Failure" status. If this value is empty there is no information available. */
129
118
  code: number;
130
119
  /** A human-readable description of the status of this operation. */
131
120
  message: string;
@@ -151,4 +140,4 @@ export type WebhookIgnore = {
151
140
  */
152
141
  labels?: Record<string, string>[];
153
142
  };
154
- //# sourceMappingURL=types.d.ts.map
143
+ //# sourceMappingURL=k8s.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"k8s.d.ts","sourceRoot":"","sources":["../../src/lib/k8s.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,gBAAgB,EAAgB,MAAM,0BAA0B,CAAC;AAEzG,oBAAY,SAAS;IACnB,MAAM,WAAW;IACjB,MAAM,WAAW;IACjB,MAAM,WAAW;IACjB,OAAO,YAAY;CACpB;AAED;;GAEG;AACH,qBAAa,SAAU,SAAQ,WAAW;IAChC,IAAI,EAAE;QACZ,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;KACvB,CAAC;CACH;AAED,eAAO,MAAM,YAAY;;;;CAIxB,CAAC;AAIF;;;GAGG;AACH,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB,CAAC,CAAC,GAAG,gBAAgB;IACpD,gEAAgE;IAChE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAErB,+GAA+G;IAC/G,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAC;IAEhC,sFAAsF;IACtF,QAAQ,CAAC,QAAQ,EAAE,oBAAoB,CAAC;IAExC,iGAAiG;IACjG,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAE9B,yHAAyH;IACzH,QAAQ,CAAC,WAAW,CAAC,EAAE,gBAAgB,CAAC;IAExC,0GAA0G;IAC1G,QAAQ,CAAC,eAAe,CAAC,EAAE,oBAAoB,CAAC;IAEhD,qHAAqH;IACrH,QAAQ,CAAC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAErC;;;OAGG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,uEAAuE;IACvE,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAE5B;;;OAGG;IACH,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAE9B,wDAAwD;IACxD,QAAQ,CAAC,QAAQ,EAAE;QACjB,0EAA0E;QAC1E,QAAQ,CAAC,EAAE,MAAM,CAAC;QAElB;;;WAGG;QACH,GAAG,CAAC,EAAE,MAAM,CAAC;QAEb,kDAAkD;QAClD,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;QAElB,gEAAgE;QAChE,KAAK,CAAC,EAAE;YACN,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;SACzB,CAAC;KACH,CAAC;IAEF,2FAA2F;IAC3F,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;IAEnB,sFAAsF;IACtF,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;IAEvB,gHAAgH;IAChH,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAE1B;;;;;;OAMG;IAEH,QAAQ,CAAC,OAAO,CAAC,EAAE,GAAG,CAAC;CACxB;AAED,MAAM,WAAW,cAAc;IAC7B,kIAAkI;IAClI,GAAG,EAAE,MAAM,CAAC;IAEZ,4EAA4E;IAC5E,OAAO,EAAE,OAAO,CAAC;IAEjB,6IAA6I;IAC7I,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,uFAAuF;IACvF,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,8DAA8D;IAC9D,SAAS,CAAC,EAAE,WAAW,CAAC;IAExB;;;;OAIG;IACH,gBAAgB,CAAC,EAAE;QACjB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;KACvB,CAAC;IAEF,qFAAqF;IACrF,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;CACrB;AAED,MAAM,WAAW,gBAAiB,SAAQ,cAAc;IACtD,6IAA6I;IAC7I,MAAM,CAAC,EAAE;QACP;2FACmF;QACnF,IAAI,EAAE,MAAM,CAAC;QAEb,oEAAoE;QACpE,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;CACH;AAED,MAAM,MAAM,aAAa,GAAG;IAC1B;;;;;OAKG;IACH,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB;;;;;;;;;OASG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC;CACnC,CAAC"}
@@ -8,32 +8,32 @@ export declare class MetricsCollector {
8
8
  * @param [prefix='pepr'] - The prefix for the metric names.
9
9
  */
10
10
  constructor(prefix?: string);
11
- addCounter(name: string, help: string): void;
12
- addSummary(name: string, help: string): void;
13
- incCounter(name: string): void;
11
+ addCounter: (name: string, help: string) => void;
12
+ addSummary: (name: string, help: string) => void;
13
+ incCounter: (name: string) => void;
14
14
  /**
15
15
  * Increments the error counter.
16
16
  */
17
- error(): void;
17
+ error: () => void;
18
18
  /**
19
19
  * Increments the alerts counter.
20
20
  */
21
- alert(): void;
22
- /**
23
- * Returns the current timestamp from performance.now() method. Useful for start timing an operation.
24
- * @returns The timestamp.
25
- */
26
- observeStart(): number;
21
+ alert: () => void;
27
22
  /**
28
23
  * Observes the duration since the provided start time and updates the summary.
29
24
  * @param startTime - The start time.
30
25
  * @param name - The metrics summary to increment.
31
26
  */
32
- observeEnd(startTime: number, name?: string): void;
27
+ observeEnd: (startTime: number, name?: string) => void;
33
28
  /**
34
29
  * Fetches the current metrics from the registry.
35
30
  * @returns The metrics.
36
31
  */
37
- getMetrics(): Promise<string>;
32
+ getMetrics: () => Promise<string>;
33
+ /**
34
+ * Returns the current timestamp from performance.now() method. Useful for start timing an operation.
35
+ * @returns The timestamp.
36
+ */
37
+ static observeStart(): number;
38
38
  }
39
39
  //# sourceMappingURL=metrics.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"metrics.d.ts","sourceRoot":"","sources":["../../src/lib/metrics.ts"],"names":[],"mappings":"AAwBA;;GAEG;AACH,qBAAa,gBAAgB;;IAa3B;;;OAGG;gBACS,MAAM,SAAS;IAyC3B,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;IAIrC,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;IAIrC,UAAU,CAAC,IAAI,EAAE,MAAM;IAIvB;;OAEG;IACH,KAAK;IAIL;;OAEG;IACH,KAAK;IAIL;;;OAGG;IACH,YAAY;IAIZ;;;;OAIG;IACH,UAAU,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,GAAE,MAAiC;IAIrE;;;OAGG;IACG,UAAU;CAGjB"}
1
+ {"version":3,"file":"metrics.d.ts","sourceRoot":"","sources":["../../src/lib/metrics.ts"],"names":[],"mappings":"AAwBA;;GAEG;AACH,qBAAa,gBAAgB;;IAa3B;;;OAGG;gBACS,MAAM,SAAS;IA+B3B,UAAU,SAAU,MAAM,QAAQ,MAAM,UAEtC;IAEF,UAAU,SAAU,MAAM,QAAQ,MAAM,UAEtC;IAEF,UAAU,SAAU,MAAM,UAExB;IAEF;;OAEG;IACH,KAAK,aAAmD;IAExD;;OAEG;IACH,KAAK,aAAmD;IAExD;;;;OAIG;IACH,UAAU,cAAe,MAAM,SAAQ,MAAM,UAE3C;IAEF;;;OAGG;IACH,UAAU,wBAAkC;IAE5C;;;OAGG;IACH,MAAM,CAAC,YAAY;CAGpB"}
@@ -1,6 +1,24 @@
1
1
  import { Capability } from "./capability";
2
- import { MutateResponse, Request, ValidateResponse } from "./k8s/types";
3
- import { ModuleConfig } from "./types";
2
+ import { AdmissionRequest, MutateResponse, ValidateResponse, WebhookIgnore } from "./k8s";
3
+ /** Global configuration for the Pepr runtime. */
4
+ export type ModuleConfig = {
5
+ /** The user-defined name for the module */
6
+ name: string;
7
+ /** The Pepr version this module uses */
8
+ peprVersion?: string;
9
+ /** The user-defined version of the module */
10
+ appVersion?: string;
11
+ /** A unique identifier for this Pepr module. This is automatically generated by Pepr. */
12
+ uuid: string;
13
+ /** A description of the Pepr module and what it does. */
14
+ description?: string;
15
+ /** Reject K8s resource AdmissionRequests on error. */
16
+ onError?: string;
17
+ /** Configure global exclusions that will never be processed by Pepr. */
18
+ alwaysIgnore: WebhookIgnore;
19
+ /** Define the log level for the in-cluster controllers */
20
+ logLevel?: string;
21
+ };
4
22
  export type PackageJSON = {
5
23
  description: string;
6
24
  pepr: ModuleConfig;
@@ -8,10 +26,13 @@ export type PackageJSON = {
8
26
  export type PeprModuleOptions = {
9
27
  deferStart?: boolean;
10
28
  /** A user-defined callback to pre-process or intercept a Pepr request from K8s immediately before it is processed */
11
- beforeHook?: (req: Request) => void;
29
+ beforeHook?: (req: AdmissionRequest) => void;
12
30
  /** A user-defined callback to post-process or intercept a Pepr response just before it is returned to K8s */
13
31
  afterHook?: (res: MutateResponse | ValidateResponse) => void;
14
32
  };
33
+ export declare const isWatchMode: () => boolean;
34
+ export declare const isBuildMode: () => boolean;
35
+ export declare const isDevMode: () => boolean;
15
36
  export declare class PeprModule {
16
37
  #private;
17
38
  /**
@@ -28,6 +49,6 @@ export declare class PeprModule {
28
49
  *
29
50
  * @param port
30
51
  */
31
- start(port?: number): void;
52
+ start: (port?: number) => void;
32
53
  }
33
54
  //# sourceMappingURL=module.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../src/lib/module.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG1C,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACxE,OAAO,EAAoB,YAAY,EAAE,MAAM,SAAS,CAAC;AAEzD,MAAM,MAAM,WAAW,GAAG;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,YAAY,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB,qHAAqH;IACrH,UAAU,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,IAAI,CAAC;IAEpC,6GAA6G;IAC7G,SAAS,CAAC,EAAE,CAAC,GAAG,EAAE,cAAc,GAAG,gBAAgB,KAAK,IAAI,CAAC;CAC9D,CAAC;AAEF,qBAAa,UAAU;;IAGrB;;;;;;OAMG;gBACS,EAAE,WAAW,EAAE,IAAI,EAAE,EAAE,WAAW,EAAE,YAAY,GAAE,UAAU,EAAO,EAAE,IAAI,GAAE,iBAAsB;IAwC7G;;;;;OAKG;IACH,KAAK,CAAC,IAAI,SAAO;CAGlB"}
1
+ {"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../src/lib/module.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG1C,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAI1F,iDAAiD;AACjD,MAAM,MAAM,YAAY,GAAG;IACzB,2CAA2C;IAC3C,IAAI,EAAE,MAAM,CAAC;IACb,wCAAwC;IACxC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,6CAA6C;IAC7C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,yFAAyF;IACzF,IAAI,EAAE,MAAM,CAAC;IACb,yDAAyD;IACzD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,sDAAsD;IACtD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,wEAAwE;IACxE,YAAY,EAAE,aAAa,CAAC;IAC5B,0DAA0D;IAC1D,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,YAAY,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB,qHAAqH;IACrH,UAAU,CAAC,EAAE,CAAC,GAAG,EAAE,gBAAgB,KAAK,IAAI,CAAC;IAE7C,6GAA6G;IAC7G,SAAS,CAAC,EAAE,CAAC,GAAG,EAAE,cAAc,GAAG,gBAAgB,KAAK,IAAI,CAAC;CAC9D,CAAC;AAGF,eAAO,MAAM,WAAW,eAA+C,CAAC;AAGxE,eAAO,MAAM,WAAW,eAA0C,CAAC;AAEnE,eAAO,MAAM,SAAS,eAAwC,CAAC;AAE/D,qBAAa,UAAU;;IAGrB;;;;;;OAMG;gBACS,EAAE,WAAW,EAAE,IAAI,EAAE,EAAE,WAAW,EAAE,YAAY,GAAE,UAAU,EAAO,EAAE,IAAI,GAAE,iBAAsB;IAgD7G;;;;;OAKG;IACH,KAAK,0BAEH;CACH"}
@@ -1,5 +1,5 @@
1
1
  import { Capability } from "./capability";
2
- import { MutateResponse, Request } from "./k8s/types";
3
- import { ModuleConfig } from "./types";
4
- export declare function mutateProcessor(config: ModuleConfig, capabilities: Capability[], req: Request, reqMetadata: Record<string, string>): Promise<MutateResponse>;
2
+ import { MutateResponse, AdmissionRequest } from "./k8s";
3
+ import { ModuleConfig } from "./module";
4
+ export declare function mutateProcessor(config: ModuleConfig, capabilities: Capability[], req: AdmissionRequest, reqMetadata: Record<string, string>): Promise<MutateResponse>;
5
5
  //# sourceMappingURL=mutate-processor.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mutate-processor.d.ts","sourceRoot":"","sources":["../../src/lib/mutate-processor.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG1C,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAItD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAGvC,wBAAsB,eAAe,CACnC,MAAM,EAAE,YAAY,EACpB,YAAY,EAAE,UAAU,EAAE,EAC1B,GAAG,EAAE,OAAO,EACZ,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAClC,OAAO,CAAC,cAAc,CAAC,CAgIzB"}
1
+ {"version":3,"file":"mutate-processor.d.ts","sourceRoot":"","sources":["../../src/lib/mutate-processor.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG1C,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC;AAEzD,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAIxC,wBAAsB,eAAe,CACnC,MAAM,EAAE,YAAY,EACpB,YAAY,EAAE,UAAU,EAAE,EAC1B,GAAG,EAAE,gBAAgB,EACrB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAClC,OAAO,CAAC,cAAc,CAAC,CAgIzB"}
@@ -1,4 +1,5 @@
1
- import { KubernetesObject, Request } from "./k8s/types";
1
+ import { KubernetesObject } from "kubernetes-fluent-client";
2
+ import { AdmissionRequest } from "./k8s";
2
3
  import { DeepPartial } from "./types";
3
4
  /**
4
5
  * The RequestWrapper class provides methods to modify Kubernetes objects in the context
@@ -22,57 +23,57 @@ export declare class PeprMutateRequest<T extends KubernetesObject> {
22
23
  * Provides access to the request object.
23
24
  * @returns The request object containing the Kubernetes resource.
24
25
  */
25
- get Request(): Request<T>;
26
+ get Request(): AdmissionRequest<T>;
26
27
  /**
27
28
  * Creates a new instance of the action class.
28
29
  * @param input - The request object containing the Kubernetes resource to modify.
29
30
  */
30
- constructor(input: Request<T>);
31
+ constructor(input: AdmissionRequest<T>);
31
32
  /**
32
33
  * Deep merges the provided object with the current resource.
33
34
  *
34
35
  * @param obj - The object to merge with the current resource.
35
36
  */
36
- Merge(obj: DeepPartial<T>): void;
37
+ Merge: (obj: DeepPartial<T>) => void;
37
38
  /**
38
39
  * Updates a label on the Kubernetes resource.
39
40
  * @param key - The key of the label to update.
40
41
  * @param value - The value of the label.
41
42
  * @returns The current action instance for method chaining.
42
43
  */
43
- SetLabel(key: string, value: string): this;
44
+ SetLabel: (key: string, value: string) => this;
44
45
  /**
45
46
  * Updates an annotation on the Kubernetes resource.
46
47
  * @param key - The key of the annotation to update.
47
48
  * @param value - The value of the annotation.
48
49
  * @returns The current action instance for method chaining.
49
50
  */
50
- SetAnnotation(key: string, value: string): this;
51
+ SetAnnotation: (key: string, value: string) => this;
51
52
  /**
52
53
  * Removes a label from the Kubernetes resource.
53
54
  * @param key - The key of the label to remove.
54
55
  * @returns The current Action instance for method chaining.
55
56
  */
56
- RemoveLabel(key: string): this;
57
+ RemoveLabel: (key: string) => this;
57
58
  /**
58
59
  * Removes an annotation from the Kubernetes resource.
59
60
  * @param key - The key of the annotation to remove.
60
61
  * @returns The current Action instance for method chaining.
61
62
  */
62
- RemoveAnnotation(key: string): this;
63
+ RemoveAnnotation: (key: string) => this;
63
64
  /**
64
65
  * Check if a label exists on the Kubernetes resource.
65
66
  *
66
67
  * @param key the label key to check
67
68
  * @returns
68
69
  */
69
- HasLabel(key: string): boolean;
70
+ HasLabel: (key: string) => boolean;
70
71
  /**
71
72
  * Check if an annotation exists on the Kubernetes resource.
72
73
  *
73
74
  * @param key the annotation key to check
74
75
  * @returns
75
76
  */
76
- HasAnnotation(key: string): boolean;
77
+ HasAnnotation: (key: string) => boolean;
77
78
  }
78
79
  //# sourceMappingURL=mutate-request.d.ts.map