pepr 0.13.2 → 0.13.3

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.
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "engines": {
10
10
  "node": ">=18.0.0"
11
11
  },
12
- "version": "0.13.2",
12
+ "version": "0.13.3",
13
13
  "main": "dist/lib.js",
14
14
  "types": "dist/lib.d.ts",
15
15
  "scripts": {
@@ -32,7 +32,7 @@
32
32
  "fast-json-patch": "3.1.1",
33
33
  "http-status-codes": "2.2.0",
34
34
  "node-fetch": "2.7.0",
35
- "pino": "8.15.0",
35
+ "pino": "8.15.1",
36
36
  "pino-pretty": "10.2.0",
37
37
  "prom-client": "14.2.0",
38
38
  "ramda": "0.29.0"
package/src/lib/filter.ts CHANGED
@@ -12,13 +12,14 @@ import { Binding, Event } from "./types";
12
12
  * @param req the incoming request
13
13
  * @returns
14
14
  */
15
- export function shouldSkipRequest(binding: Binding, req: Request) {
15
+ export function shouldSkipRequest(binding: Binding, req: Request, capabilityNamespaces: string[]) {
16
16
  const { group, kind, version } = binding.kind || {};
17
17
  const { namespaces, labels, annotations, name } = binding.filters || {};
18
18
  const operation = req.operation.toUpperCase();
19
19
  // Use the old object if the request is a DELETE operation
20
20
  const srcObject = operation === Operation.DELETE ? req.oldObject : req.object;
21
21
  const { metadata } = srcObject || {};
22
+ const combinedNamespaces = [...namespaces, ...capabilityNamespaces];
22
23
 
23
24
  // Test for matching operation
24
25
  if (!binding.event.includes(operation) && !binding.event.includes(Event.Any)) {
@@ -46,7 +47,7 @@ export function shouldSkipRequest(binding: Binding, req: Request) {
46
47
  }
47
48
 
48
49
  // Test for matching namespaces
49
- if (namespaces.length && !namespaces.includes(req.namespace || "")) {
50
+ if (combinedNamespaces.length && !combinedNamespaces.includes(req.namespace || "")) {
50
51
  logger.debug("Namespace does not match");
51
52
  return true;
52
53
  }
@@ -40,7 +40,7 @@ export async function mutateProcessor(
40
40
 
41
41
  Log.info(reqMetadata, `Processing request`);
42
42
 
43
- for (const { name, bindings } of capabilities) {
43
+ for (const { name, bindings, namespaces } of capabilities) {
44
44
  const actionMetadata = { ...reqMetadata, name };
45
45
 
46
46
  for (const action of bindings) {
@@ -50,7 +50,7 @@ export async function mutateProcessor(
50
50
  }
51
51
 
52
52
  // Continue to the next action without doing anything if this one should be skipped
53
- if (shouldSkipRequest(action, req)) {
53
+ if (shouldSkipRequest(action, req, namespaces)) {
54
54
  continue;
55
55
  }
56
56
 
@@ -28,7 +28,7 @@ export async function validateProcessor(
28
28
 
29
29
  Log.info(reqMetadata, `Processing validation request`);
30
30
 
31
- for (const { name, bindings } of capabilities) {
31
+ for (const { name, bindings, namespaces } of capabilities) {
32
32
  const actionMetadata = { ...reqMetadata, name };
33
33
 
34
34
  for (const action of bindings) {
@@ -38,7 +38,7 @@ export async function validateProcessor(
38
38
  }
39
39
 
40
40
  // Continue to the next action without doing anything if this one should be skipped
41
- if (shouldSkipRequest(action, req)) {
41
+ if (shouldSkipRequest(action, req, namespaces)) {
42
42
  continue;
43
43
  }
44
44
 
@@ -9,7 +9,7 @@ import fs from "fs";
9
9
  import { gunzipSync } from "zlib";
10
10
 
11
11
  import Log from "../lib/logger";
12
- import { packageJSON } from "../cli/init/templates/data.json";
12
+ import { packageJSON } from "../templates/data.json";
13
13
 
14
14
  const { version } = packageJSON;
15
15
 
@@ -0,0 +1,13 @@
1
+ {
2
+ "arrowParens": "avoid",
3
+ "bracketSameLine": false,
4
+ "bracketSpacing": true,
5
+ "embeddedLanguageFormatting": "auto",
6
+ "insertPragma": false,
7
+ "printWidth": 80,
8
+ "quoteProps": "as-needed",
9
+ "requirePragma": false,
10
+ "semi": true,
11
+ "tabWidth": 2,
12
+ "useTabs": false
13
+ }
@@ -0,0 +1,21 @@
1
+ # Pepr Module
2
+
3
+ This is a Pepr Module. [Pepr](https://github.com/defenseunicorns/pepr) is a type-safe Kubernetes middleware system.
4
+
5
+ The `capabilities` directory contains all the capabilities for this module. By default,
6
+ a capability is a single typescript file in the format of `capability-name.ts` that is
7
+ imported in the root `pepr.ts` file as `import { HelloPepr } from "./capabilities/hello-pepr";`.
8
+ Because this is typescript, you can organize this however you choose, e.g. creating a sub-folder
9
+ per-capability or common logic in shared files or folders.
10
+
11
+ Example Structure:
12
+
13
+ ```
14
+ Module Root
15
+ ├── package.json
16
+ ├── pepr.ts
17
+ └── capabilities
18
+ ├── example-one.ts
19
+ ├── example-three.ts
20
+ └── example-two.ts
21
+ ```
@@ -0,0 +1,160 @@
1
+ [
2
+ {
3
+ "apiVersion": "v1",
4
+ "kind": "Namespace",
5
+ "metadata": {
6
+ "name": "pepr-demo",
7
+ "labels": {
8
+ "keep-me": "please",
9
+ "remove-me": "please"
10
+ }
11
+ }
12
+ },
13
+ {
14
+ "apiVersion": "v1",
15
+ "kind": "Namespace",
16
+ "metadata": {
17
+ "name": "pepr-demo-2"
18
+ }
19
+ },
20
+ {
21
+ "apiVersion": "v1",
22
+ "kind": "Secret",
23
+ "metadata": {
24
+ "name": "secret-1",
25
+ "namespace": "pepr-demo"
26
+ },
27
+ "data": {
28
+ "example": "dW5pY29ybiBtYWdpYw==",
29
+ "binary-data": "iCZQUg8xYucNUqD+8lyl2YcKjYYygvTtiDSEV9b9WKUkxSSLFJTgIWMJ9GcFFYs4T9JCdda51u74jfq8yHzRuEASl60EdTS/NfWgIIFTGqcNRfqMw+vgpyTMmCyJVaJEDFq6AA==",
30
+ "ascii-with-white-space": "VGhpcyBpcyBzb21lIHJhbmRvbSB0ZXh0OgoKICAgIC0gd2l0aCBsaW5lIGJyZWFrcwogICAgLSBhbmQgdGFicw=="
31
+ }
32
+ },
33
+ {
34
+ "apiVersion": "v1",
35
+ "kind": "ConfigMap",
36
+ "metadata": {
37
+ "name": "example-1",
38
+ "namespace": "pepr-demo"
39
+ },
40
+ "data": {
41
+ "key": "ex-1-val"
42
+ }
43
+ },
44
+ {
45
+ "apiVersion": "v1",
46
+ "kind": "ConfigMap",
47
+ "metadata": {
48
+ "name": "example-2",
49
+ "namespace": "pepr-demo"
50
+ },
51
+ "data": {
52
+ "key": "ex-2-val"
53
+ }
54
+ },
55
+ {
56
+ "apiVersion": "v1",
57
+ "kind": "ConfigMap",
58
+ "metadata": {
59
+ "name": "example-evil-cm",
60
+ "namespace": "pepr-demo",
61
+ "annotations": {
62
+ "evil": "true"
63
+ }
64
+ },
65
+ "data": {
66
+ "key": "ex-evil-cm-val"
67
+ }
68
+ },
69
+ {
70
+ "apiVersion": "v1",
71
+ "kind": "ConfigMap",
72
+ "metadata": {
73
+ "name": "example-3",
74
+ "namespace": "pepr-demo",
75
+ "labels": {
76
+ "change": "by-label"
77
+ }
78
+ },
79
+ "data": {
80
+ "key": "ex-3-val"
81
+ }
82
+ },
83
+ {
84
+ "apiVersion": "v1",
85
+ "kind": "ConfigMap",
86
+ "metadata": {
87
+ "name": "example-4",
88
+ "namespace": "pepr-demo"
89
+ },
90
+ "data": {
91
+ "key": "ex-4-val"
92
+ }
93
+ },
94
+ {
95
+ "apiVersion": "v1",
96
+ "kind": "ConfigMap",
97
+ "metadata": {
98
+ "name": "example-4a",
99
+ "namespace": "pepr-demo-2"
100
+ },
101
+ "data": {
102
+ "key": "ex-4-val"
103
+ }
104
+ },
105
+ {
106
+ "apiVersion": "v1",
107
+ "kind": "ConfigMap",
108
+ "metadata": {
109
+ "name": "example-5",
110
+ "namespace": "pepr-demo",
111
+ "labels": {
112
+ "chuck-norris": "test"
113
+ }
114
+ },
115
+ "data": {
116
+ "key": "ex-5-val"
117
+ }
118
+ },
119
+ {
120
+ "apiVersion": "apiextensions.k8s.io/v1",
121
+ "kind": "CustomResourceDefinition",
122
+ "metadata": {
123
+ "name": "unicorns.pepr.dev"
124
+ },
125
+ "spec": {
126
+ "group": "pepr.dev",
127
+ "versions": [
128
+ {
129
+ "name": "v1",
130
+ "served": true,
131
+ "storage": true,
132
+ "schema": {
133
+ "openAPIV3Schema": {
134
+ "type": "object",
135
+ "properties": {
136
+ "spec": {
137
+ "type": "object",
138
+ "properties": {
139
+ "message": {
140
+ "type": "string"
141
+ },
142
+ "counter": {
143
+ "type": "number"
144
+ }
145
+ }
146
+ }
147
+ }
148
+ }
149
+ }
150
+ }
151
+ ],
152
+ "scope": "Namespaced",
153
+ "names": {
154
+ "plural": "unicorns",
155
+ "singular": "unicorn",
156
+ "kind": "Unicorn"
157
+ }
158
+ }
159
+ }
160
+ ]
@@ -0,0 +1,372 @@
1
+ import {
2
+ Capability,
3
+ Log,
4
+ PeprMutateRequest,
5
+ RegisterKind,
6
+ a,
7
+ fetch,
8
+ fetchStatus,
9
+ } from "pepr";
10
+
11
+ /**
12
+ * The HelloPepr Capability is an example capability to demonstrate some general concepts of Pepr.
13
+ * To test this capability you run `pepr dev`and then run the following command:
14
+ * `kubectl apply -f capabilities/hello-pepr.samples.yaml`
15
+ */
16
+ export const HelloPepr = new Capability({
17
+ name: "hello-pepr",
18
+ description: "A simple example capability to show how things work.",
19
+ namespaces: ["pepr-demo", "pepr-demo-2"],
20
+ });
21
+
22
+ // Use the 'When' function to create a new Action
23
+ const { When } = HelloPepr;
24
+
25
+ /**
26
+ * ---------------------------------------------------------------------------------------------------
27
+ * Mutate Action (Namespace) *
28
+ * ---------------------------------------------------------------------------------------------------
29
+ *
30
+ * This action removes the label `remove-me` when a Namespace is created.
31
+ * Note we don't need to specify the namespace here, because we've already specified
32
+ * it in the Capability definition above.
33
+ */
34
+ When(a.Namespace)
35
+ .IsCreated()
36
+ .Mutate(ns => ns.RemoveLabel("remove-me"));
37
+
38
+ /**
39
+ * ---------------------------------------------------------------------------------------------------
40
+ * Mutate Action (CM Example 1) *
41
+ * ---------------------------------------------------------------------------------------------------
42
+ *
43
+ * This is a single action. They can be in the same file or put imported from other files.
44
+ * In this example, when a ConfigMap is created with the name `example-1`, then add a label and annotation.
45
+ *
46
+ * Equivalent to manually running:
47
+ * `kubectl label configmap example-1 pepr=was-here`
48
+ * `kubectl annotate configmap example-1 pepr.dev=annotations-work-too`
49
+ */
50
+ When(a.ConfigMap)
51
+ .IsCreated()
52
+ .WithName("example-1")
53
+ .Mutate(request => {
54
+ request
55
+ .SetLabel("pepr", "was-here")
56
+ .SetAnnotation("pepr.dev", "annotations-work-too");
57
+ });
58
+
59
+ /**
60
+ * ---------------------------------------------------------------------------------------------------
61
+ * Mutate & Validate Actions (CM Example 2) *
62
+ * ---------------------------------------------------------------------------------------------------
63
+ *
64
+ * This combines 2 different types of actions: 'Mutate', and 'Validate'. The order
65
+ * of the actions is required, but each action is optional. In this example, when a ConfigMap is created
66
+ * with the name `example-2`, then add a label and annotation and finally validate that the ConfigMap has the label
67
+ * `pepr`.
68
+ */
69
+ When(a.ConfigMap)
70
+ .IsCreated()
71
+ .WithName("example-2")
72
+ .Mutate(request => {
73
+ // This Mutate Action will mutate the request before it is persisted to the cluster
74
+
75
+ // Use `request.Merge()` to merge the new data with the existing data
76
+ request.Merge({
77
+ metadata: {
78
+ labels: {
79
+ pepr: "was-here",
80
+ },
81
+ annotations: {
82
+ "pepr.dev": "annotations-work-too",
83
+ },
84
+ },
85
+ });
86
+ })
87
+ .Validate(request => {
88
+ // This Validate Action will validate the request before it is persisted to the cluster
89
+
90
+ // Approve the request if the ConfigMap has the label 'pepr'
91
+ if (request.HasLabel("pepr")) {
92
+ return request.Approve();
93
+ }
94
+
95
+ // Otherwise, deny the request with an error message (optional)
96
+ return request.Deny("ConfigMap must have label 'pepr'");
97
+ });
98
+
99
+ /**
100
+ * ---------------------------------------------------------------------------------------------------
101
+ * Mutate Action (CM Example 2a) *
102
+ * ---------------------------------------------------------------------------------------------------
103
+ *
104
+ * This action shows a simple validation that will deny any ConfigMap that has the
105
+ * annotation `evil`. Note that the `Deny()` function takes an optional second parameter that is a
106
+ * user-defined status code to return.
107
+ */
108
+ When(a.ConfigMap)
109
+ .IsCreated()
110
+ .Validate(request => {
111
+ if (request.HasAnnotation("evil")) {
112
+ return request.Deny("No evil CM annotations allowed.", 400);
113
+ }
114
+
115
+ return request.Approve();
116
+ });
117
+
118
+ /**
119
+ * ---------------------------------------------------------------------------------------------------
120
+ * Mutate Action (CM Example 3) *
121
+ * ---------------------------------------------------------------------------------------------------
122
+ *
123
+ * This action combines different styles. Unlike the previous actions, this one will look
124
+ * for any ConfigMap in the `pepr-demo` namespace that has the label `change=by-label` during either
125
+ * CREATE or UPDATE. Note that all conditions added such as `WithName()`, `WithLabel()`, `InNamespace()`,
126
+ * are ANDs so all conditions must be true for the request to be processed.
127
+ */
128
+ When(a.ConfigMap)
129
+ .IsCreatedOrUpdated()
130
+ .WithLabel("change", "by-label")
131
+ .Mutate(request => {
132
+ // The K8s object e are going to mutate
133
+ const cm = request.Raw;
134
+
135
+ // Get the username and uid of the K8s request
136
+ const { username, uid } = request.Request.userInfo;
137
+
138
+ // Store some data about the request in the configmap
139
+ cm.data["username"] = username;
140
+ cm.data["uid"] = uid;
141
+
142
+ // You can still mix other ways of making changes too
143
+ request.SetAnnotation("pepr.dev", "making-waves");
144
+ });
145
+
146
+ // This action validates the label `change=by-label` is deleted
147
+ When(a.ConfigMap)
148
+ .IsDeleted()
149
+ .WithLabel("change", "by-label")
150
+ .Validate(request => {
151
+ // Log and then always approve the request
152
+ Log.info("CM with label 'change=by-label' was deleted.");
153
+ return request.Approve();
154
+ });
155
+
156
+ /**
157
+ * ---------------------------------------------------------------------------------------------------
158
+ * Mutate Action (CM Example 4) *
159
+ * ---------------------------------------------------------------------------------------------------
160
+ *
161
+ * This action show how you can use the `Mutate()` function without an inline function.
162
+ * This is useful if you want to keep your actions small and focused on a single task,
163
+ * or if you want to reuse the same function in multiple actions.
164
+ */
165
+ When(a.ConfigMap).IsCreated().WithName("example-4").Mutate(example4Cb);
166
+
167
+ // This function uses the complete type definition, but is not required.
168
+ function example4Cb(cm: PeprMutateRequest<a.ConfigMap>) {
169
+ cm.SetLabel("pepr.dev/first", "true");
170
+ cm.SetLabel("pepr.dev/second", "true");
171
+ cm.SetLabel("pepr.dev/third", "true");
172
+ }
173
+
174
+ /**
175
+ * ---------------------------------------------------------------------------------------------------
176
+ * Mutate Action (CM Example 4a) *
177
+ * ---------------------------------------------------------------------------------------------------
178
+ *
179
+ * This is the same as Example 4, except this only operates on a CM in the `pepr-demo-2` namespace.
180
+ * Note because the Capability defines namespaces, the namespace specified here must be one of those.
181
+ * Alternatively, you can remove the namespace from the Capability definition and specify it here.
182
+ */
183
+ When(a.ConfigMap)
184
+ .IsCreated()
185
+ .InNamespace("pepr-demo-2")
186
+ .WithName("example-4a")
187
+ .Mutate(example4Cb);
188
+
189
+ /**
190
+ * ---------------------------------------------------------------------------------------------------
191
+ * Mutate Action (CM Example 5) *
192
+ * ---------------------------------------------------------------------------------------------------
193
+ *
194
+ * This action is a bit more complex. It will look for any ConfigMap in the `pepr-demo`
195
+ * namespace that has the label `chuck-norris` during CREATE. When it finds one, it will fetch a
196
+ * random Chuck Norris joke from the API and add it to the ConfigMap. This is a great example of how
197
+ * you can use Pepr to make changes to your K8s objects based on external data.
198
+ *
199
+ * Note the use of the `async` keyword. This is required for any action that uses `await` or `fetch()`.
200
+ *
201
+ * Also note we are passing a type to the `fetch()` function. This is optional, but it will help you
202
+ * avoid mistakes when working with the data returned from the API. You can also use the `as` keyword to
203
+ * cast the data returned from the API.
204
+ *
205
+ * These are equivalent:
206
+ * ```ts
207
+ * const joke = await fetch<TheChuckNorrisJoke>("https://api.chucknorris.io/jokes/random?category=dev");
208
+ * const joke = await fetch("https://api.chucknorris.io/jokes/random?category=dev") as TheChuckNorrisJoke;
209
+ * ```
210
+ *
211
+ * Alternatively, you can drop the type completely:
212
+ *
213
+ * ```ts
214
+ * fetch("https://api.chucknorris.io/jokes/random?category=dev")
215
+ * ```
216
+ */
217
+ interface TheChuckNorrisJoke {
218
+ icon_url: string;
219
+ id: string;
220
+ url: string;
221
+ value: string;
222
+ }
223
+
224
+ When(a.ConfigMap)
225
+ .IsCreated()
226
+ .WithLabel("chuck-norris")
227
+ .Mutate(async change => {
228
+ // Try/catch is not needed as a response object will always be returned
229
+ const response = await fetch<TheChuckNorrisJoke>(
230
+ "https://api.chucknorris.io/jokes/random?category=dev",
231
+ );
232
+
233
+ // Instead, check the `response.ok` field
234
+ if (response.ok) {
235
+ // Add the Chuck Norris joke to the configmap
236
+ change.Raw.data["chuck-says"] = response.data.value;
237
+ return;
238
+ }
239
+
240
+ // You can also assert on different HTTP response codes
241
+ if (response.status === fetchStatus.NOT_FOUND) {
242
+ // Do something else
243
+ return;
244
+ }
245
+ });
246
+
247
+ /**
248
+ * ---------------------------------------------------------------------------------------------------
249
+ * Mutate Action (Secret Base64 Handling) *
250
+ * ---------------------------------------------------------------------------------------------------
251
+ *
252
+ * The K8s JS client provides incomplete support for base64 encoding/decoding handling for secrets,
253
+ * unlike the GO client. To make this less painful, Pepr automatically handles base64 encoding/decoding
254
+ * secret data before and after the action is executed.
255
+ */
256
+ When(a.Secret)
257
+ .IsCreated()
258
+ .WithName("secret-1")
259
+ .Mutate(request => {
260
+ const secret = request.Raw;
261
+
262
+ // This will be encoded at the end of all processing back to base64: "Y2hhbmdlLXdpdGhvdXQtZW5jb2Rpbmc="
263
+ secret.data.magic = "change-without-encoding";
264
+
265
+ // You can modify the data directly, and it will be encoded at the end of all processing
266
+ secret.data.example += " - modified by Pepr";
267
+ });
268
+
269
+ /**
270
+ * ---------------------------------------------------------------------------------------------------
271
+ * Mutate Action (Untyped Custom Resource) *
272
+ * ---------------------------------------------------------------------------------------------------
273
+ *
274
+ * Out of the box, Pepr supports all the standard Kubernetes objects. However, you can also create
275
+ * your own types. This is useful if you are working with an Operator that creates custom resources.
276
+ * There are two ways to do this, the first is to use the `When()` function with a `GenericKind`,
277
+ * the second is to create a new class that extends `GenericKind` and use the `RegisterKind()` function.
278
+ *
279
+ * This example shows how to use the `When()` function with a `GenericKind`. Note that you
280
+ * must specify the `group`, `version`, and `kind` of the object (if applicable). This is how Pepr knows
281
+ * if the action should be triggered or not. Since we are using a `GenericKind`,
282
+ * Pepr will not be able to provide any intellisense for the object, so you will need to refer to the
283
+ * Kubernetes API documentation for the object you are working with.
284
+ *
285
+ * You will need to wait for the CRD in `hello-pepr.samples.yaml` to be created, then you can apply
286
+ *
287
+ * ```yaml
288
+ * apiVersion: pepr.dev/v1
289
+ * kind: Unicorn
290
+ * metadata:
291
+ * name: example-1
292
+ * namespace: pepr-demo
293
+ * spec:
294
+ * message: replace-me
295
+ * counter: 0
296
+ * ```
297
+ */
298
+ When(a.GenericKind, {
299
+ group: "pepr.dev",
300
+ version: "v1",
301
+ kind: "Unicorn",
302
+ })
303
+ .IsCreated()
304
+ .WithName("example-1")
305
+ .Mutate(request => {
306
+ request.Merge({
307
+ spec: {
308
+ message: "Hello Pepr without type data!",
309
+ counter: Math.random(),
310
+ },
311
+ });
312
+ });
313
+
314
+ /**
315
+ * ---------------------------------------------------------------------------------------------------
316
+ * Mutate Action (Typed Custom Resource) *
317
+ * ---------------------------------------------------------------------------------------------------
318
+ *
319
+ * This example shows how to use the `RegisterKind()` function to create a new type. This is useful
320
+ * if you are working with an Operator that creates custom resources and you want to have intellisense
321
+ * for the object. Note that you must specify the `group`, `version`, and `kind` of the object (if applicable)
322
+ * as this is how Pepr knows if the action should be triggered or not.
323
+ *
324
+ * Once you register a new Kind with Pepr, you can use the `When()` function with the new Kind. Ideally,
325
+ * you should register custom Kinds at the top of your Capability file or Pepr Module so they are available
326
+ * to all actions, but we are putting it here for demonstration purposes.
327
+ *
328
+ * You will need to wait for the CRD in `hello-pepr.samples.yaml` to be created, then you can apply
329
+ *
330
+ * ```yaml
331
+ * apiVersion: pepr.dev/v1
332
+ * kind: Unicorn
333
+ * metadata:
334
+ * name: example-2
335
+ * namespace: pepr-demo
336
+ * spec:
337
+ * message: replace-me
338
+ * counter: 0
339
+ * ```*
340
+ */
341
+ class UnicornKind extends a.GenericKind {
342
+ spec: {
343
+ /**
344
+ * JSDoc comments can be added to explain more details about the field.
345
+ *
346
+ * @example
347
+ * ```ts
348
+ * request.Raw.spec.message = "Hello Pepr!";
349
+ * ```
350
+ * */
351
+ message: string;
352
+ counter: number;
353
+ };
354
+ }
355
+
356
+ RegisterKind(UnicornKind, {
357
+ group: "pepr.dev",
358
+ version: "v1",
359
+ kind: "Unicorn",
360
+ });
361
+
362
+ When(UnicornKind)
363
+ .IsCreated()
364
+ .WithName("example-2")
365
+ .Mutate(request => {
366
+ request.Merge({
367
+ spec: {
368
+ message: "Hello Pepr with type data!",
369
+ counter: Math.random(),
370
+ },
371
+ });
372
+ });
@@ -0,0 +1,4 @@
1
+ # Ignore node_modules and Pepr build artifacts
2
+ node_modules
3
+ dist
4
+ insecure*
@@ -0,0 +1,14 @@
1
+ {
2
+ "name": "pepr-dev-module",
3
+ "description": "static test package.json for local pepr core development",
4
+ "pepr": {
5
+ "name": "Development Module",
6
+ "uuid": "20e17cf6-a2e4-46b2-b626-75d88d96c88b",
7
+ "description": "Development module for pepr",
8
+ "onError": "ignore",
9
+ "alwaysIgnore": {
10
+ "namespaces": [],
11
+ "labels": []
12
+ }
13
+ }
14
+ }