pepr 0.13.4 → 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 (105) hide show
  1. package/README.md +23 -4
  2. package/dist/cli.js +375 -204
  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 +13 -17
  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/capabilities/hello-pepr.ts +54 -5
  79. package/src/templates/package.json +1 -0
  80. package/dist/lib/controller.d.ts +0 -10
  81. package/dist/lib/controller.d.ts.map +0 -1
  82. package/dist/lib/fetch.d.ts +0 -23
  83. package/dist/lib/fetch.d.ts.map +0 -1
  84. package/dist/lib/k8s/index.d.ts +0 -7
  85. package/dist/lib/k8s/index.d.ts.map +0 -1
  86. package/dist/lib/k8s/kinds.d.ts +0 -12
  87. package/dist/lib/k8s/kinds.d.ts.map +0 -1
  88. package/dist/lib/k8s/tls.d.ts.map +0 -1
  89. package/dist/lib/k8s/types.d.ts.map +0 -1
  90. package/dist/lib/k8s/upstream.d.ts +0 -4
  91. package/dist/lib/k8s/upstream.d.ts.map +0 -1
  92. package/jest.config.json +0 -4
  93. package/journey/before.ts +0 -21
  94. package/journey/k8s.ts +0 -100
  95. package/journey/pepr-build.ts +0 -69
  96. package/journey/pepr-deploy.ts +0 -174
  97. package/journey/pepr-dev.ts +0 -155
  98. package/journey/pepr-format.ts +0 -13
  99. package/journey/pepr-init.ts +0 -12
  100. package/src/lib/fetch.ts +0 -76
  101. package/src/lib/k8s/index.ts +0 -14
  102. package/src/lib/k8s/kinds.ts +0 -531
  103. package/src/lib/k8s/upstream.ts +0 -53
  104. /package/dist/lib/{k8s/tls.d.ts → tls.d.ts} +0 -0
  105. /package/src/lib/{k8s/tls.ts → tls.ts} +0 -0
package/README.md CHANGED
@@ -12,10 +12,15 @@
12
12
 
13
13
  Pepr is on a mission to save Kubernetes from the tyranny of YAML, intimidating glue code, bash scripts, and other makeshift solutions. As a Kubernetes controller, Pepr empowers you to define Kubernetes transformations using TypeScript, without software development expertise thanks to plain-english configurations. Pepr transforms a patchwork of forks, scripts, overlays, and other chaos into a cohesive, well-structured, and maintainable system. With Pepr, you can seamlessly transition IT ops tribal knowledge into code, simplifying documentation, testing, validation, and coordination of changes for a more predictable outcome.
14
14
 
15
+ #### _Note: Pepr is still in active development so breaking changes may occur, but will be documented in release notes._
16
+
15
17
  ## Features
16
18
 
17
- - Zero-config K8s webhook mutations and validations.
19
+ - Zero-config K8s webhook mutations and validations
20
+ - Automatic leader-elected K8s resource watching
21
+ - Lightweight async key-value store backed by K8s for stateful operations with the [Pepr Store](./docs/store.md)
18
22
  - Human-readable fluent API for generating [Pepr Capabilities](#capability)
23
+ - A fluent API for creating/modifying/watching and server-side applying K8s resources via [Kubernetes Fluent Client](https://github.com/defenseunicorns/kubernetes-fluent-client)
19
24
  - Generate new K8s resources based off of cluster resource changes
20
25
  - Perform other exec/API calls based off of cluster resources changes or any other arbitrary schedule
21
26
  - Out of the box airgap support with [Zarf](https://zarf.dev)
@@ -27,7 +32,7 @@ Pepr is on a mission to save Kubernetes from the tyranny of YAML, intimidating g
27
32
 
28
33
  ## Example Pepr Action
29
34
 
30
- This quick sample shows how to react to a ConfigMap being created or updated in the cluster. It adds a label and annotation to the ConfigMap and adds some data to the ConfigMap. Finally, it logs a message to the Pepr controller logs. For more see [actions](./docs/actions.md).
35
+ This quick sample shows how to react to a ConfigMap being created or updated in the cluster. It adds a label and annotation to the ConfigMap and adds some data to the ConfigMap. It also creates a Validating Webhook to make sure the "pepr" label still exists. Finally, after the ConfigMap is created, it logs a message to the Pepr controller and creates or updates a separate ConfigMap with the [kubernetes-fluent-client](https://github.com/defenseunicorns/kubernetes-fluent-client) using server-side apply. For more details see [actions](./docs/actions.md) section.
31
36
 
32
37
  ```ts
33
38
  When(a.ConfigMap)
@@ -54,6 +59,21 @@ When(a.ConfigMap)
54
59
 
55
60
  // Reject the ConfigMap if it doesn't have the label
56
61
  return request.Deny("ConfigMap must have a unicorn label");
62
+ })
63
+ // Watch behaves like controller-runtime's Manager.Watch()
64
+ .Watch(async (cm, phase) => {
65
+ Log.info(cm, `ConfigMap was ${phase}.`);
66
+
67
+ // Apply a ConfigMap using K8s server-side apply (will create or update)
68
+ await K8s(kind.ConfigMap).Apply({
69
+ metadata: {
70
+ name: "pepr-ssa-demo",
71
+ namespace: "pepr-demo-2",
72
+ },
73
+ data: {
74
+ uid: cm.metadata.uid,
75
+ },
76
+ });
57
77
  });
58
78
  ```
59
79
 
@@ -104,7 +124,7 @@ Action is a discrete set of behaviors defined in a single function that acts on
104
124
 
105
125
  For example, an action could be responsible for adding a specific label to a Kubernetes resource, or for modifying a specific field in a resource's metadata. Actions can be grouped together within a Capability to provide a more comprehensive set of operations that can be performed on Kubernetes resources.
106
126
 
107
- There are both `Mutate()` and `Validate()` Actions that can be used to modify or validate Kubernetes resources.
127
+ There are both `Mutate()` and `Validate()` Actions that can be used to modify or validate Kubernetes resources within the admission controller lifecycle. There is also a `Watch()` Action that can be used to watch for changes to Kubernetes resources that already exist.
108
128
 
109
129
  See [actions](./docs/actions.md) for more details.
110
130
 
@@ -116,4 +136,3 @@ See [actions](./docs/actions.md) for more details.
116
136
  ## TypeScript
117
137
 
118
138
  [TypeScript](https://www.typescriptlang.org/) is a strongly typed, object-oriented programming language built on top of JavaScript. It provides optional static typing and a rich type system, allowing developers to write more robust code. TypeScript is transpiled to JavaScript, enabling it to run in any environment that supports JavaScript. Pepr allows you to use JavaScript or TypeScript to write capabilities, but TypeScript is recommended for its type safety and rich type system. You can learn more about TypeScript [here](https://www.typescriptlang.org/docs/handbook/typescript-from-scratch.html).
119
-