pepr 0.27.0 → 0.28.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.
- package/dist/cli.js +71 -25
- package/dist/controller.js +1 -1
- package/dist/lib/assets/helm.d.ts.map +1 -1
- package/dist/lib/assets/pods.d.ts +1 -0
- package/dist/lib/assets/pods.d.ts.map +1 -1
- package/dist/lib/assets/yaml.d.ts.map +1 -1
- package/dist/lib/controller/index.d.ts +2 -2
- package/dist/lib/controller/index.d.ts.map +1 -1
- package/dist/lib/helpers.d.ts +7 -0
- package/dist/lib/helpers.d.ts.map +1 -1
- package/dist/lib/k8s.d.ts +0 -11
- package/dist/lib/k8s.d.ts.map +1 -1
- package/dist/lib/module.d.ts +0 -2
- package/dist/lib/module.d.ts.map +1 -1
- package/dist/lib/watch-processor.d.ts +1 -2
- package/dist/lib/watch-processor.d.ts.map +1 -1
- package/dist/lib.js +87 -61
- package/dist/lib.js.map +4 -4
- package/package.json +8 -8
- package/src/cli.ts +2 -0
- package/src/lib/assets/helm.ts +2 -0
- package/src/lib/assets/pods.ts +2 -0
- package/src/lib/assets/yaml.ts +8 -4
- package/src/lib/controller/index.ts +2 -2
- package/src/lib/controller/store.ts +1 -1
- package/src/lib/helpers.ts +96 -6
- package/src/lib/k8s.ts +0 -11
- package/src/lib/module.ts +4 -4
- package/src/lib/watch-processor.ts +22 -65
- package/src/templates/package.json +1 -2
package/dist/cli.js
CHANGED
|
@@ -296,7 +296,6 @@ var import_zlib = require("zlib");
|
|
|
296
296
|
// src/lib/helpers.ts
|
|
297
297
|
var import_kubernetes_fluent_client = require("kubernetes-fluent-client");
|
|
298
298
|
var import_fs2 = require("fs");
|
|
299
|
-
var import_commander = __toESM(require("commander"));
|
|
300
299
|
var createRBACMap = (capabilities) => {
|
|
301
300
|
return capabilities.reduce((acc, capability) => {
|
|
302
301
|
capability.bindings.forEach((binding) => {
|
|
@@ -357,7 +356,7 @@ function generateWatchNamespaceError(ignoredNamespaces, bindingNamespaces, capab
|
|
|
357
356
|
if (bindingAndCapabilityNSConflict(bindingNamespaces, capabilityNamespaces)) {
|
|
358
357
|
err += `Binding uses namespace not governed by capability: bindingNamespaces: [${bindingNamespaces.join(
|
|
359
358
|
", "
|
|
360
|
-
)}] capabilityNamespaces
|
|
359
|
+
)}] capabilityNamespaces: [${capabilityNamespaces.join(", ")}].`;
|
|
361
360
|
}
|
|
362
361
|
return err.replace(/\.([^ ])/g, ". $1");
|
|
363
362
|
}
|
|
@@ -420,11 +419,11 @@ var parseTimeout = (value, previous) => {
|
|
|
420
419
|
const parsedValue = parseInt(value, 10);
|
|
421
420
|
const floatValue = parseFloat(value);
|
|
422
421
|
if (isNaN(parsedValue)) {
|
|
423
|
-
throw new
|
|
422
|
+
throw new Error("Not a number.");
|
|
424
423
|
} else if (parsedValue !== floatValue) {
|
|
425
|
-
throw new
|
|
424
|
+
throw new Error("Value must be an integer.");
|
|
426
425
|
} else if (parsedValue < 1 || parsedValue > 30) {
|
|
427
|
-
throw new
|
|
426
|
+
throw new Error("Number must be between 1 and 30.");
|
|
428
427
|
}
|
|
429
428
|
return parsedValue;
|
|
430
429
|
};
|
|
@@ -521,6 +520,7 @@ function watcher(assets, hash, buildTimestamp) {
|
|
|
521
520
|
}
|
|
522
521
|
},
|
|
523
522
|
spec: {
|
|
523
|
+
terminationGracePeriodSeconds: 5,
|
|
524
524
|
serviceAccountName: name2,
|
|
525
525
|
securityContext: {
|
|
526
526
|
runAsUser: 65532,
|
|
@@ -643,6 +643,7 @@ function deployment(assets, hash, buildTimestamp) {
|
|
|
643
643
|
}
|
|
644
644
|
},
|
|
645
645
|
spec: {
|
|
646
|
+
terminationGracePeriodSeconds: 5,
|
|
646
647
|
priorityClassName: "system-node-critical",
|
|
647
648
|
serviceAccountName: name2,
|
|
648
649
|
securityContext: {
|
|
@@ -1144,14 +1145,13 @@ async function overridesFile({ hash, name: name2, image, config, apiToken }, pat
|
|
|
1144
1145
|
},
|
|
1145
1146
|
uuid: name2,
|
|
1146
1147
|
admission: {
|
|
1148
|
+
terminationGracePeriodSeconds: 5,
|
|
1147
1149
|
failurePolicy: config.onError === "reject" ? "Fail" : "Ignore",
|
|
1148
1150
|
webhookTimeout: config.webhookTimeout,
|
|
1149
1151
|
env: [
|
|
1150
1152
|
{ name: "PEPR_WATCH_MODE", value: "false" },
|
|
1151
1153
|
{ name: "PEPR_PRETTY_LOG", value: "false" },
|
|
1152
|
-
{ name: "LOG_LEVEL", value: "debug" }
|
|
1153
|
-
process.env.PEPR_MODE === "dev" && { name: "MY_CUSTOM_VAR", value: "example-value" },
|
|
1154
|
-
process.env.PEPR_MODE === "dev" && { name: "ZARF_VAR", value: "###ZARF_VAR_THING###" }
|
|
1154
|
+
{ name: "LOG_LEVEL", value: "debug" }
|
|
1155
1155
|
],
|
|
1156
1156
|
image,
|
|
1157
1157
|
annotations: {
|
|
@@ -1192,12 +1192,11 @@ async function overridesFile({ hash, name: name2, image, config, apiToken }, pat
|
|
|
1192
1192
|
affinity: {}
|
|
1193
1193
|
},
|
|
1194
1194
|
watcher: {
|
|
1195
|
+
terminationGracePeriodSeconds: 5,
|
|
1195
1196
|
env: [
|
|
1196
1197
|
{ name: "PEPR_WATCH_MODE", value: "true" },
|
|
1197
1198
|
{ name: "PEPR_PRETTY_LOG", value: "false" },
|
|
1198
|
-
{ name: "LOG_LEVEL", value: "debug" }
|
|
1199
|
-
process.env.PEPR_MODE === "dev" && { name: "MY_CUSTOM_VAR", value: "example-value" },
|
|
1200
|
-
process.env.PEPR_MODE === "dev" && { name: "ZARF_VAR", value: "###ZARF_VAR_THING###" }
|
|
1199
|
+
{ name: "LOG_LEVEL", value: "debug" }
|
|
1201
1200
|
],
|
|
1202
1201
|
image,
|
|
1203
1202
|
annotations: {
|
|
@@ -1238,6 +1237,12 @@ async function overridesFile({ hash, name: name2, image, config, apiToken }, pat
|
|
|
1238
1237
|
affinity: {}
|
|
1239
1238
|
}
|
|
1240
1239
|
};
|
|
1240
|
+
if (process.env.PEPR_MODE === "dev") {
|
|
1241
|
+
overrides.admission.env.push({ name: "ZARF_VAR", value: "###ZARF_VAR_THING###" });
|
|
1242
|
+
overrides.watcher.env.push({ name: "ZARF_VAR", value: "###ZARF_VAR_THING###" });
|
|
1243
|
+
overrides.admission.env.push({ name: "MY_CUSTOM_VAR", value: "example-value" });
|
|
1244
|
+
overrides.watcher.env.push({ name: "MY_CUSTOM_VAR", value: "example-value" });
|
|
1245
|
+
}
|
|
1241
1246
|
await import_fs4.promises.writeFile(path, (0, import_client_node.dumpYaml)(overrides, { noRefs: true, forceQuotes: true }));
|
|
1242
1247
|
}
|
|
1243
1248
|
function zarfYaml({ name: name2, image, config }, path) {
|
|
@@ -1374,6 +1379,7 @@ function watcherDeployTemplate(buildTimestamp) {
|
|
|
1374
1379
|
app: {{ .Values.uuid }}-watcher
|
|
1375
1380
|
pepr.dev/controller: watcher
|
|
1376
1381
|
spec:
|
|
1382
|
+
terminationGracePeriodSeconds: {{ .Values.watcher.terminationGracePeriodSeconds }}
|
|
1377
1383
|
serviceAccountName: {{ .Values.uuid }}
|
|
1378
1384
|
securityContext:
|
|
1379
1385
|
{{- toYaml .Values.admission.securityContext | nindent 8 }}
|
|
@@ -1444,6 +1450,7 @@ function admissionDeployTemplate(buildTimestamp) {
|
|
|
1444
1450
|
app: {{ .Values.uuid }}
|
|
1445
1451
|
pepr.dev/controller: admission
|
|
1446
1452
|
spec:
|
|
1453
|
+
terminationGracePeriodSeconds: {{ .Values.admission.terminationGracePeriodSeconds }}
|
|
1447
1454
|
priorityClassName: system-node-critical
|
|
1448
1455
|
serviceAccountName: {{ .Values.uuid }}
|
|
1449
1456
|
securityContext:
|
|
@@ -1825,7 +1832,7 @@ var gitIgnore = "# Ignore node_modules and Pepr build artifacts\nnode_modules\nd
|
|
|
1825
1832
|
var readmeMd = '# Pepr Module\n\nThis is a Pepr Module. [Pepr](https://github.com/defenseunicorns/pepr) is a type-safe Kubernetes middleware system.\n\nThe `capabilities` directory contains all the capabilities for this module. By default,\na capability is a single typescript file in the format of `capability-name.ts` that is\nimported in the root `pepr.ts` file as `import { HelloPepr } from "./capabilities/hello-pepr";`.\nBecause this is typescript, you can organize this however you choose, e.g. creating a sub-folder\nper-capability or common logic in shared files or folders.\n\nExample Structure:\n\n```\nModule Root\n\u251C\u2500\u2500 package.json\n\u251C\u2500\u2500 pepr.ts\n\u2514\u2500\u2500 capabilities\n \u251C\u2500\u2500 example-one.ts\n \u251C\u2500\u2500 example-three.ts\n \u2514\u2500\u2500 example-two.ts\n```\n';
|
|
1826
1833
|
var peprTS = 'import { PeprModule } from "pepr";\n// cfg loads your pepr configuration from package.json\nimport cfg from "./package.json";\n\n// HelloPepr is a demo capability that is included with Pepr. Comment or delete the line below to remove it.\nimport { HelloPepr } from "./capabilities/hello-pepr";\n\n/**\n * This is the main entrypoint for this Pepr module. It is run when the module is started.\n * This is where you register your Pepr configurations and capabilities.\n */\nnew PeprModule(cfg, [\n // "HelloPepr" is a demo capability that is included with Pepr. Comment or delete the line below to remove it.\n HelloPepr,\n\n // Your additional capabilities go here\n]);\n';
|
|
1827
1834
|
var helloPeprTS = 'import {\n Capability,\n K8s,\n Log,\n PeprMutateRequest,\n RegisterKind,\n a,\n fetch,\n fetchStatus,\n kind,\n} from "pepr";\n\n/**\n * The HelloPepr Capability is an example capability to demonstrate some general concepts of Pepr.\n * To test this capability you run `pepr dev`and then run the following command:\n * `kubectl apply -f capabilities/hello-pepr.samples.yaml`\n */\nexport const HelloPepr = new Capability({\n name: "hello-pepr",\n description: "A simple example capability to show how things work.",\n namespaces: ["pepr-demo", "pepr-demo-2"],\n});\n\n// Use the \'When\' function to create a new action, use \'Store\' to persist data\nconst { When, Store } = HelloPepr;\n\n/**\n * ---------------------------------------------------------------------------------------------------\n * Mutate Action (Namespace) *\n * ---------------------------------------------------------------------------------------------------\n *\n * This action removes the label `remove-me` when a Namespace is created.\n * Note we don\'t need to specify the namespace here, because we\'ve already specified\n * it in the Capability definition above.\n */\nWhen(a.Namespace)\n .IsCreated()\n .Mutate(ns => ns.RemoveLabel("remove-me"));\n\n/**\n * ---------------------------------------------------------------------------------------------------\n * Watch Action with K8s SSA (Namespace) *\n * ---------------------------------------------------------------------------------------------------\n *\n * This action watches for the `pepr-demo-2` namespace to be created, then creates a ConfigMap with\n * the name `pepr-ssa-demo` and adds the namespace UID to the ConfigMap data. Because Pepr uses\n * server-side apply for this operation, the ConfigMap will be created or updated if it already exists.\n */\nWhen(a.Namespace)\n .IsCreated()\n .WithName("pepr-demo-2")\n .Watch(async ns => {\n Log.info("Namespace pepr-demo-2 was created.");\n\n try {\n // Apply the ConfigMap using K8s server-side apply\n await K8s(kind.ConfigMap).Apply({\n metadata: {\n name: "pepr-ssa-demo",\n namespace: "pepr-demo-2",\n },\n data: {\n "ns-uid": ns.metadata.uid,\n },\n });\n } catch (error) {\n // You can use the Log object to log messages to the Pepr controller pod\n Log.error(error, "Failed to apply ConfigMap using server-side apply.");\n }\n\n // You can share data between actions using the Store, including between different types of actions\n Store.setItem("watch-data", "This data was stored by a Watch Action.");\n });\n\n/**\n * ---------------------------------------------------------------------------------------------------\n * Mutate Action (CM Example 1) *\n * ---------------------------------------------------------------------------------------------------\n *\n * This is a single action. They can be in the same file or put imported from other files.\n * In this example, when a ConfigMap is created with the name `example-1`, then add a label and annotation.\n *\n * Equivalent to manually running:\n * `kubectl label configmap example-1 pepr=was-here`\n * `kubectl annotate configmap example-1 pepr.dev=annotations-work-too`\n */\nWhen(a.ConfigMap)\n .IsCreated()\n .WithName("example-1")\n .Mutate(request => {\n request\n .SetLabel("pepr", "was-here")\n .SetAnnotation("pepr.dev", "annotations-work-too");\n\n // Use the Store to persist data between requests and Pepr controller pods\n Store.setItem("example-1", "was-here");\n\n // This data is written asynchronously and can be read back via `Store.getItem()` or `Store.subscribe()`\n Store.setItem("example-1-data", JSON.stringify(request.Raw.data));\n });\n\n/**\n * ---------------------------------------------------------------------------------------------------\n * Mutate & Validate Actions (CM Example 2) *\n * ---------------------------------------------------------------------------------------------------\n *\n * This combines 3 different types of actions: \'Mutate\', \'Validate\', and \'Watch\'. The order\n * of the actions is required, but each action is optional. In this example, when a ConfigMap is created\n * with the name `example-2`, then add a label and annotation, validate that the ConfigMap has the label\n * `pepr`, and log the request.\n */\nWhen(a.ConfigMap)\n .IsCreated()\n .WithName("example-2")\n .Mutate(request => {\n // This Mutate Action will mutate the request before it is persisted to the cluster\n\n // Use `request.Merge()` to merge the new data with the existing data\n request.Merge({\n metadata: {\n labels: {\n pepr: "was-here",\n },\n annotations: {\n "pepr.dev": "annotations-work-too",\n },\n },\n });\n })\n .Validate(request => {\n // This Validate Action will validate the request before it is persisted to the cluster\n\n // Approve the request if the ConfigMap has the label \'pepr\'\n if (request.HasLabel("pepr")) {\n return request.Approve();\n }\n\n // Otherwise, deny the request with an error message (optional)\n return request.Deny("ConfigMap must have label \'pepr\'");\n })\n .Watch((cm, phase) => {\n // This Watch Action will watch the ConfigMap after it has been persisted to the cluster\n Log.info(cm, `ConfigMap was ${phase} with the name example-2`);\n });\n\n/**\n * ---------------------------------------------------------------------------------------------------\n * Mutate Action (CM Example 2a) *\n * ---------------------------------------------------------------------------------------------------\n *\n * This action shows a simple validation that will deny any ConfigMap that has the\n * annotation `evil`. Note that the `Deny()` function takes an optional second parameter that is a\n * user-defined status code to return.\n */\nWhen(a.ConfigMap)\n .IsCreated()\n .Validate(request => {\n if (request.HasAnnotation("evil")) {\n return request.Deny("No evil CM annotations allowed.", 400);\n }\n\n return request.Approve();\n });\n\n/**\n * ---------------------------------------------------------------------------------------------------\n * Mutate Action (CM Example 3) *\n * ---------------------------------------------------------------------------------------------------\n *\n * This action combines different styles. Unlike the previous actions, this one will look\n * for any ConfigMap in the `pepr-demo` namespace that has the label `change=by-label` during either\n * CREATE or UPDATE. Note that all conditions added such as `WithName()`, `WithLabel()`, `InNamespace()`,\n * are ANDs so all conditions must be true for the request to be processed.\n */\nWhen(a.ConfigMap)\n .IsCreatedOrUpdated()\n .WithLabel("change", "by-label")\n .Mutate(request => {\n // The K8s object e are going to mutate\n const cm = request.Raw;\n\n // Get the username and uid of the K8s request\n const { username, uid } = request.Request.userInfo;\n\n // Store some data about the request in the configmap\n cm.data["username"] = username;\n cm.data["uid"] = uid;\n\n // You can still mix other ways of making changes too\n request.SetAnnotation("pepr.dev", "making-waves");\n });\n\n// This action validates the label `change=by-label` is deleted\nWhen(a.ConfigMap)\n .IsDeleted()\n .WithLabel("change", "by-label")\n .Validate(request => {\n // Log and then always approve the request\n Log.info("CM with label \'change=by-label\' was deleted.");\n return request.Approve();\n });\n\n/**\n * ---------------------------------------------------------------------------------------------------\n * Mutate Action (CM Example 4) *\n * ---------------------------------------------------------------------------------------------------\n *\n * This action show how you can use the `Mutate()` function without an inline function.\n * This is useful if you want to keep your actions small and focused on a single task,\n * or if you want to reuse the same function in multiple actions.\n */\nWhen(a.ConfigMap).IsCreated().WithName("example-4").Mutate(example4Cb);\n\n// This function uses the complete type definition, but is not required.\nfunction example4Cb(cm: PeprMutateRequest<a.ConfigMap>) {\n cm.SetLabel("pepr.dev/first", "true");\n cm.SetLabel("pepr.dev/second", "true");\n cm.SetLabel("pepr.dev/third", "true");\n}\n\n/**\n * ---------------------------------------------------------------------------------------------------\n * Mutate Action (CM Example 4a) *\n * ---------------------------------------------------------------------------------------------------\n *\n * This is the same as Example 4, except this only operates on a CM in the `pepr-demo-2` namespace.\n * Note because the Capability defines namespaces, the namespace specified here must be one of those.\n * Alternatively, you can remove the namespace from the Capability definition and specify it here.\n */\nWhen(a.ConfigMap)\n .IsCreated()\n .InNamespace("pepr-demo-2")\n .WithName("example-4a")\n .Mutate(example4Cb);\n\n/**\n * ---------------------------------------------------------------------------------------------------\n * Mutate Action (CM Example 5) *\n * ---------------------------------------------------------------------------------------------------\n *\n * This action is a bit more complex. It will look for any ConfigMap in the `pepr-demo`\n * namespace that has the label `chuck-norris` during CREATE. When it finds one, it will fetch a\n * random Chuck Norris joke from the API and add it to the ConfigMap. This is a great example of how\n * you can use Pepr to make changes to your K8s objects based on external data.\n *\n * Note the use of the `async` keyword. This is required for any action that uses `await` or `fetch()`.\n *\n * Also note we are passing a type to the `fetch()` function. This is optional, but it will help you\n * avoid mistakes when working with the data returned from the API. You can also use the `as` keyword to\n * cast the data returned from the API.\n *\n * These are equivalent:\n * ```ts\n * const joke = await fetch<TheChuckNorrisJoke>("https://api.chucknorris.io/jokes/random?category=dev");\n * const joke = await fetch("https://api.chucknorris.io/jokes/random?category=dev") as TheChuckNorrisJoke;\n * ```\n *\n * Alternatively, you can drop the type completely:\n *\n * ```ts\n * fetch("https://api.chucknorris.io/jokes/random?category=dev")\n * ```\n */\ninterface TheChuckNorrisJoke {\n icon_url: string;\n id: string;\n url: string;\n value: string;\n}\n\nWhen(a.ConfigMap)\n .IsCreated()\n .WithLabel("chuck-norris")\n .Mutate(async change => {\n // Try/catch is not needed as a response object will always be returned\n const response = await fetch<TheChuckNorrisJoke>(\n "https://api.chucknorris.io/jokes/random?category=dev",\n );\n\n // Instead, check the `response.ok` field\n if (response.ok) {\n // Add the Chuck Norris joke to the configmap\n change.Raw.data["chuck-says"] = response.data.value;\n return;\n }\n\n // You can also assert on different HTTP response codes\n if (response.status === fetchStatus.NOT_FOUND) {\n // Do something else\n return;\n }\n });\n\n/**\n * ---------------------------------------------------------------------------------------------------\n * Mutate Action (Secret Base64 Handling) *\n * ---------------------------------------------------------------------------------------------------\n *\n * The K8s JS client provides incomplete support for base64 encoding/decoding handling for secrets,\n * unlike the GO client. To make this less painful, Pepr automatically handles base64 encoding/decoding\n * secret data before and after the action is executed.\n */\nWhen(a.Secret)\n .IsCreated()\n .WithName("secret-1")\n .Mutate(request => {\n const secret = request.Raw;\n\n // This will be encoded at the end of all processing back to base64: "Y2hhbmdlLXdpdGhvdXQtZW5jb2Rpbmc="\n secret.data.magic = "change-without-encoding";\n\n // You can modify the data directly, and it will be encoded at the end of all processing\n secret.data.example += " - modified by Pepr";\n });\n\n/**\n * ---------------------------------------------------------------------------------------------------\n * Mutate Action (Untyped Custom Resource) *\n * ---------------------------------------------------------------------------------------------------\n *\n * Out of the box, Pepr supports all the standard Kubernetes objects. However, you can also create\n * your own types. This is useful if you are working with an Operator that creates custom resources.\n * There are two ways to do this, the first is to use the `When()` function with a `GenericKind`,\n * the second is to create a new class that extends `GenericKind` and use the `RegisterKind()` function.\n *\n * This example shows how to use the `When()` function with a `GenericKind`. Note that you\n * must specify the `group`, `version`, and `kind` of the object (if applicable). This is how Pepr knows\n * if the action should be triggered or not. Since we are using a `GenericKind`,\n * Pepr will not be able to provide any intellisense for the object, so you will need to refer to the\n * Kubernetes API documentation for the object you are working with.\n *\n * You will need to wait for the CRD in `hello-pepr.samples.yaml` to be created, then you can apply\n *\n * ```yaml\n * apiVersion: pepr.dev/v1\n * kind: Unicorn\n * metadata:\n * name: example-1\n * namespace: pepr-demo\n * spec:\n * message: replace-me\n * counter: 0\n * ```\n */\nWhen(a.GenericKind, {\n group: "pepr.dev",\n version: "v1",\n kind: "Unicorn",\n})\n .IsCreated()\n .WithName("example-1")\n .Mutate(request => {\n request.Merge({\n spec: {\n message: "Hello Pepr without type data!",\n counter: Math.random(),\n },\n });\n });\n\n/**\n * ---------------------------------------------------------------------------------------------------\n * Mutate Action (Typed Custom Resource) *\n * ---------------------------------------------------------------------------------------------------\n *\n * This example shows how to use the `RegisterKind()` function to create a new type. This is useful\n * if you are working with an Operator that creates custom resources and you want to have intellisense\n * for the object. Note that you must specify the `group`, `version`, and `kind` of the object (if applicable)\n * as this is how Pepr knows if the action should be triggered or not.\n *\n * Once you register a new Kind with Pepr, you can use the `When()` function with the new Kind. Ideally,\n * you should register custom Kinds at the top of your Capability file or Pepr Module so they are available\n * to all actions, but we are putting it here for demonstration purposes.\n *\n * You will need to wait for the CRD in `hello-pepr.samples.yaml` to be created, then you can apply\n *\n * ```yaml\n * apiVersion: pepr.dev/v1\n * kind: Unicorn\n * metadata:\n * name: example-2\n * namespace: pepr-demo\n * spec:\n * message: replace-me\n * counter: 0\n * ```*\n */\nclass UnicornKind extends a.GenericKind {\n spec: {\n /**\n * JSDoc comments can be added to explain more details about the field.\n *\n * @example\n * ```ts\n * request.Raw.spec.message = "Hello Pepr!";\n * ```\n * */\n message: string;\n counter: number;\n };\n}\n\nRegisterKind(UnicornKind, {\n group: "pepr.dev",\n version: "v1",\n kind: "Unicorn",\n});\n\nWhen(UnicornKind)\n .IsCreated()\n .WithName("example-2")\n .Mutate(request => {\n request.Merge({\n spec: {\n message: "Hello Pepr with type data!",\n counter: Math.random(),\n },\n });\n });\n\n/**\n * A callback function that is called once the Pepr Store is fully loaded.\n */\nStore.onReady(data => {\n Log.info(data, "Pepr Store Ready");\n});\n';
|
|
1828
|
-
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.
|
|
1835
|
+
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.28.1", 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 --detectOpenHandles --coverageDirectory=./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:prep": "if [ ! -d ./pepr-upgrade-test ]; then git clone https://github.com/defenseunicorns/pepr-upgrade-test.git ; fi", "test:journey-wasm": "npm run test:journey:k3d && npm run test:journey:build && npm run test:journey:image && npm run test:journey:run-wasm", "test:journey:k3d": "k3d cluster delete pepr-dev && k3d cluster create pepr-dev --k3s-arg '--debug@server:0' --wait && kubectl rollout status deployment -n kube-system", "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 --detectOpenHandles journey/entrypoint.test.ts && npm run test:journey:prep && npm run test:journey:upgrade", "test:journey:run-wasm": "jest --detectOpenHandles journey/entrypoint-wasm.test.ts", "test:journey:upgrade": "npm run test:journey:k3d && npm run test:journey:image && jest --detectOpenHandles journey/pepr-upgrade.test.ts", "format:check": "eslint src && prettier src --check", "format:fix": "eslint src --fix && prettier src --write" }, dependencies: { "@types/ramda": "0.29.11", express: "4.18.3", "fast-json-patch": "3.1.1", "kubernetes-fluent-client": "2.2.3", pino: "8.19.0", "pino-pretty": "10.3.1", "prom-client": "15.1.0", ramda: "0.29.1" }, devDependencies: { "@commitlint/cli": "19.1.0", "@commitlint/config-conventional": "19.1.0", "@jest/globals": "29.7.0", "@types/eslint": "8.56.5", "@types/express": "4.17.21", "@types/node": "18.x.x", "@types/node-forge": "1.3.11", "@types/prompts": "2.4.9", "@types/uuid": "9.0.8", jest: "29.7.0", nock: "13.5.4", "ts-jest": "29.1.2" }, peerDependencies: { "@typescript-eslint/eslint-plugin": "6.15.0", "@typescript-eslint/parser": "6.15.0", commander: "11.1.0", esbuild: "0.19.10", eslint: "8.56.0", "node-forge": "1.3.1", prettier: "3.1.1", prompts: "2.4.2", typescript: "5.3.3", uuid: "9.0.1" } };
|
|
1829
1836
|
|
|
1830
1837
|
// src/templates/pepr.code-snippets.json
|
|
1831
1838
|
var pepr_code_snippets_default = {
|
|
@@ -1928,7 +1935,6 @@ function genPkgJSON(opts, pgkVerOverride) {
|
|
|
1928
1935
|
node: ">=18.0.0"
|
|
1929
1936
|
},
|
|
1930
1937
|
pepr: {
|
|
1931
|
-
name: opts.name.trim(),
|
|
1932
1938
|
uuid: pgkVerOverride ? "static-test" : uuid,
|
|
1933
1939
|
onError: opts.errorBehavior,
|
|
1934
1940
|
webhookTimeout: 10,
|
|
@@ -1938,8 +1944,7 @@ function genPkgJSON(opts, pgkVerOverride) {
|
|
|
1938
1944
|
}
|
|
1939
1945
|
},
|
|
1940
1946
|
alwaysIgnore: {
|
|
1941
|
-
namespaces: []
|
|
1942
|
-
labels: []
|
|
1947
|
+
namespaces: []
|
|
1943
1948
|
},
|
|
1944
1949
|
includedFiles: [],
|
|
1945
1950
|
env: pgkVerOverride ? testEnv : {}
|
|
@@ -2059,7 +2064,7 @@ async function peprFormat(validateOnly) {
|
|
|
2059
2064
|
}
|
|
2060
2065
|
|
|
2061
2066
|
// src/cli/build.ts
|
|
2062
|
-
var
|
|
2067
|
+
var import_commander = require("commander");
|
|
2063
2068
|
var peprTS2 = "pepr.ts";
|
|
2064
2069
|
var outputDir = "dist";
|
|
2065
2070
|
function build_default(program2) {
|
|
@@ -2067,22 +2072,25 @@ function build_default(program2) {
|
|
|
2067
2072
|
"-n, --no-embed",
|
|
2068
2073
|
"Disables embedding of deployment files into output module. Useful when creating library modules intended solely for reuse/distribution via NPM."
|
|
2069
2074
|
).option(
|
|
2070
|
-
"-i, --custom-image
|
|
2075
|
+
"-i, --custom-image <custom-image>",
|
|
2071
2076
|
"Custom Image: Use custom image for Admission and Watch Deployments."
|
|
2072
2077
|
).option(
|
|
2073
2078
|
"-r, --registry-info [<registry>/<username>]",
|
|
2074
2079
|
"Registry Info: Image registry and username. Note: You must be signed into the registry"
|
|
2075
|
-
).option("-o, --output-dir
|
|
2076
|
-
"--timeout
|
|
2080
|
+
).option("-o, --output-dir <output directory>", "Define where to place build output").option(
|
|
2081
|
+
"--timeout <timeout>",
|
|
2077
2082
|
"How long the API server should wait for a webhook to respond before treating the call as a failure",
|
|
2078
2083
|
parseTimeout
|
|
2084
|
+
).option(
|
|
2085
|
+
"-v, --version <version>. Example: '0.27.3'",
|
|
2086
|
+
"The version of the Pepr image to use in the deployment manifests."
|
|
2079
2087
|
).addOption(
|
|
2080
|
-
new
|
|
2088
|
+
new import_commander.Option(
|
|
2081
2089
|
"--registry <GitHub|Iron Bank>",
|
|
2082
2090
|
"Container registry: Choose container registry for deployment manifests. Can't be used with --custom-image."
|
|
2083
2091
|
).choices(["GitHub", "Iron Bank"])
|
|
2084
2092
|
).addOption(
|
|
2085
|
-
new
|
|
2093
|
+
new import_commander.Option("--rbac-mode [admin|scoped]", "Rbac Mode: admin, scoped (default: admin)").choices(["admin", "scoped"]).default("admin")
|
|
2086
2094
|
).action(async (opts) => {
|
|
2087
2095
|
if (opts.outputDir) {
|
|
2088
2096
|
outputDir = opts.outputDir;
|
|
@@ -2117,6 +2125,9 @@ function build_default(program2) {
|
|
|
2117
2125
|
console.info(`\u2705 Module built successfully at ${path}`);
|
|
2118
2126
|
return;
|
|
2119
2127
|
}
|
|
2128
|
+
if (opts.version) {
|
|
2129
|
+
cfg.pepr.peprVersion = opts.version;
|
|
2130
|
+
}
|
|
2120
2131
|
const assets = new Assets(
|
|
2121
2132
|
{
|
|
2122
2133
|
...cfg.pepr,
|
|
@@ -2297,8 +2308,9 @@ function deploy_default(program2) {
|
|
|
2297
2308
|
if (opts.image) {
|
|
2298
2309
|
webhook.image = opts.image;
|
|
2299
2310
|
}
|
|
2311
|
+
const timeout = cfg.pepr.webhookTimeout ? cfg.pepr.webhookTimeout : 10;
|
|
2300
2312
|
try {
|
|
2301
|
-
await webhook.deploy(opts.force);
|
|
2313
|
+
await webhook.deploy(opts.force, timeout);
|
|
2302
2314
|
await namespaceDeploymentsReady();
|
|
2303
2315
|
console.info(`\u2705 Module deployed successfully`);
|
|
2304
2316
|
} catch (e) {
|
|
@@ -2619,11 +2631,11 @@ function uuid_default(program2) {
|
|
|
2619
2631
|
}
|
|
2620
2632
|
|
|
2621
2633
|
// src/cli/root.ts
|
|
2622
|
-
var
|
|
2623
|
-
var RootCmd = class extends
|
|
2634
|
+
var import_commander2 = require("commander");
|
|
2635
|
+
var RootCmd = class extends import_commander2.Command {
|
|
2624
2636
|
// eslint-disable-next-line class-methods-use-this
|
|
2625
2637
|
createCommand(name2) {
|
|
2626
|
-
const cmd = new
|
|
2638
|
+
const cmd = new import_commander2.Command(name2);
|
|
2627
2639
|
cmd.option("-l, --log-level [level]", "Log level: debug, info, warn, error", "info");
|
|
2628
2640
|
cmd.hook("preAction", (run) => {
|
|
2629
2641
|
logger_default.level = run.opts().logLevel;
|
|
@@ -2690,6 +2702,39 @@ function update_default(program2) {
|
|
|
2690
2702
|
});
|
|
2691
2703
|
}
|
|
2692
2704
|
|
|
2705
|
+
// src/cli/kfc.ts
|
|
2706
|
+
var import_child_process6 = require("child_process");
|
|
2707
|
+
var import_prompts6 = __toESM(require("prompts"));
|
|
2708
|
+
function kfc_default(program2) {
|
|
2709
|
+
program2.command("kfc [args...]").description("Execute Kubernetes Fluent Client commands").action(async (args) => {
|
|
2710
|
+
const { confirm: confirm2 } = await (0, import_prompts6.default)({
|
|
2711
|
+
type: "confirm",
|
|
2712
|
+
name: "confirm",
|
|
2713
|
+
message: "For commands that generate files, this may overwrite any previously generated files.\nAre you sure you want to continue?"
|
|
2714
|
+
});
|
|
2715
|
+
if (!confirm2) {
|
|
2716
|
+
return;
|
|
2717
|
+
}
|
|
2718
|
+
console.log("Preparing to execute the requested KFC command...");
|
|
2719
|
+
try {
|
|
2720
|
+
if (args.length === 0) {
|
|
2721
|
+
console.log(
|
|
2722
|
+
"No kubernetes-fluent-client arguments provided. Showing kubernetes-fluent-client help..."
|
|
2723
|
+
);
|
|
2724
|
+
args.push("--help");
|
|
2725
|
+
}
|
|
2726
|
+
const argsString = args.join(" ");
|
|
2727
|
+
(0, import_child_process6.execSync)(`kubernetes-fluent-client ${argsString}`, {
|
|
2728
|
+
stdio: "inherit"
|
|
2729
|
+
});
|
|
2730
|
+
console.log(`\u2705 KFC command executed successfully`);
|
|
2731
|
+
} catch (e) {
|
|
2732
|
+
console.error(e.message);
|
|
2733
|
+
process.exit(1);
|
|
2734
|
+
}
|
|
2735
|
+
});
|
|
2736
|
+
}
|
|
2737
|
+
|
|
2693
2738
|
// src/cli.ts
|
|
2694
2739
|
if (process.env.npm_lifecycle_event !== "npx") {
|
|
2695
2740
|
console.warn("Pepr should be run via `npx pepr <command>` instead of `pepr <command>`.");
|
|
@@ -2714,4 +2759,5 @@ update_default(program);
|
|
|
2714
2759
|
format_default(program);
|
|
2715
2760
|
monitor_default(program);
|
|
2716
2761
|
uuid_default(program);
|
|
2762
|
+
kfc_default(program);
|
|
2717
2763
|
program.parse();
|
package/dist/controller.js
CHANGED
|
@@ -49,7 +49,7 @@ if (process.env.LOG_LEVEL) {
|
|
|
49
49
|
var logger_default = Log;
|
|
50
50
|
|
|
51
51
|
// src/templates/data.json
|
|
52
|
-
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.
|
|
52
|
+
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.28.1", 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 --detectOpenHandles --coverageDirectory=./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:prep": "if [ ! -d ./pepr-upgrade-test ]; then git clone https://github.com/defenseunicorns/pepr-upgrade-test.git ; fi", "test:journey-wasm": "npm run test:journey:k3d && npm run test:journey:build && npm run test:journey:image && npm run test:journey:run-wasm", "test:journey:k3d": "k3d cluster delete pepr-dev && k3d cluster create pepr-dev --k3s-arg '--debug@server:0' --wait && kubectl rollout status deployment -n kube-system", "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 --detectOpenHandles journey/entrypoint.test.ts && npm run test:journey:prep && npm run test:journey:upgrade", "test:journey:run-wasm": "jest --detectOpenHandles journey/entrypoint-wasm.test.ts", "test:journey:upgrade": "npm run test:journey:k3d && npm run test:journey:image && jest --detectOpenHandles journey/pepr-upgrade.test.ts", "format:check": "eslint src && prettier src --check", "format:fix": "eslint src --fix && prettier src --write" }, dependencies: { "@types/ramda": "0.29.11", express: "4.18.3", "fast-json-patch": "3.1.1", "kubernetes-fluent-client": "2.2.3", pino: "8.19.0", "pino-pretty": "10.3.1", "prom-client": "15.1.0", ramda: "0.29.1" }, devDependencies: { "@commitlint/cli": "19.1.0", "@commitlint/config-conventional": "19.1.0", "@jest/globals": "29.7.0", "@types/eslint": "8.56.5", "@types/express": "4.17.21", "@types/node": "18.x.x", "@types/node-forge": "1.3.11", "@types/prompts": "2.4.9", "@types/uuid": "9.0.8", jest: "29.7.0", nock: "13.5.4", "ts-jest": "29.1.2" }, peerDependencies: { "@typescript-eslint/eslint-plugin": "6.15.0", "@typescript-eslint/parser": "6.15.0", commander: "11.1.0", esbuild: "0.19.10", eslint: "8.56.0", "node-forge": "1.3.1", prettier: "3.1.1", prompts: "2.4.2", typescript: "5.3.3", uuid: "9.0.1" } };
|
|
53
53
|
|
|
54
54
|
// src/lib/k8s.ts
|
|
55
55
|
var import_kubernetes_fluent_client = require("kubernetes-fluent-client");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helm.d.ts","sourceRoot":"","sources":["../../../src/lib/assets/helm.ts"],"names":[],"mappings":"AAGA,wBAAgB,UAAU,WAezB;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,UA2B3D;AAED,wBAAgB,qBAAqB,CAAC,cAAc,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"helm.d.ts","sourceRoot":"","sources":["../../../src/lib/assets/helm.ts"],"names":[],"mappings":"AAGA,wBAAgB,UAAU,WAezB;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,UA2B3D;AAED,wBAAgB,qBAAqB,CAAC,cAAc,EAAE,MAAM,UAwE3D;AAED,wBAAgB,uBAAuB,CAAC,cAAc,EAAE,MAAM,UA6E7D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pods.d.ts","sourceRoot":"","sources":["../../../src/lib/assets/pods.ts"],"names":[],"mappings":";AAGA,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAGhD,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,CAAC;AAI3B,yCAAyC;AACzC,wBAAgB,SAAS,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;;;;;;;;;;;;;;EAmBjE;AAED,wBAAgB,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM
|
|
1
|
+
{"version":3,"file":"pods.d.ts","sourceRoot":"","sources":["../../../src/lib/assets/pods.ts"],"names":[],"mappings":";AAGA,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAGhD,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,CAAC;AAI3B,yCAAyC;AACzC,wBAAgB,SAAS,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;;;;;;;;;;;;;;EAmBjE;AAED,wBAAgB,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAiJ3E;AAED,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC,UAAU,CAuIhG;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC,MAAM,CAuBlF"}
|
|
@@ -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;AAO3B,wBAAsB,aAAa,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,
|
|
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,wBAAsB,aAAa,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,iBAkHhG;AACD,wBAAgB,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,UA0BrE;AAED,wBAAsB,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,mBAyC7D"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Capability } from "../capability";
|
|
2
|
-
import { MutateResponse, AdmissionRequest } from "../k8s";
|
|
2
|
+
import { MutateResponse, AdmissionRequest, ValidateResponse } from "../k8s";
|
|
3
3
|
import { ModuleConfig } from "../module";
|
|
4
4
|
export declare class Controller {
|
|
5
5
|
#private;
|
|
6
|
-
constructor(config: ModuleConfig, capabilities: Capability[], beforeHook?: (req: AdmissionRequest) => void, afterHook?: (res: MutateResponse) => void, onReady?: () => void);
|
|
6
|
+
constructor(config: ModuleConfig, capabilities: Capability[], beforeHook?: (req: AdmissionRequest) => void, afterHook?: (res: MutateResponse | ValidateResponse) => void, onReady?: () => void);
|
|
7
7
|
/** Start the webhook server */
|
|
8
8
|
startServer: (port: number) => void;
|
|
9
9
|
}
|
|
@@ -1 +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,
|
|
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,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AAG5E,OAAO,EAAE,YAAY,EAAe,MAAM,WAAW,CAAC;AAMtD,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,GAAG,gBAAgB,KAAK,IAAI,EAC5D,OAAO,CAAC,EAAE,MAAM,IAAI;IAiCtB,+BAA+B;IAC/B,WAAW,SAAU,MAAM,UAqDzB;CAqMH"}
|
package/dist/lib/helpers.d.ts
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
|
+
import { KubernetesObject } from "kubernetes-fluent-client";
|
|
1
2
|
import { CapabilityExport } from "./types";
|
|
3
|
+
import { Binding } from "./types";
|
|
2
4
|
type RBACMap = {
|
|
3
5
|
[key: string]: {
|
|
4
6
|
verbs: string[];
|
|
5
7
|
plural: string;
|
|
6
8
|
};
|
|
7
9
|
};
|
|
10
|
+
export declare function checkOverlap(record1: Record<string, string>, record2: Record<string, string>): boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Decide to run callback after the event comes back from API Server
|
|
13
|
+
**/
|
|
14
|
+
export declare const filterMatcher: (binding: Partial<Binding>, obj: Partial<KubernetesObject>, capabilityNamespaces: string[]) => string;
|
|
8
15
|
export declare const addVerbIfNotExists: (verbs: string[], verb: string) => void;
|
|
9
16
|
export declare const createRBACMap: (capabilities: CapabilityExport[]) => RBACMap;
|
|
10
17
|
export declare function createDirectoryIfNotExists(path: string): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/lib/helpers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/lib/helpers.ts"],"names":[],"mappings":"AAGA,OAAO,EAAO,gBAAgB,EAAQ,MAAM,0BAA0B,CAAC;AAEvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAE3C,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAElC,KAAK,OAAO,GAAG;IACb,CAAC,GAAG,EAAE,MAAM,GAAG;QACb,KAAK,EAAE,MAAM,EAAE,CAAC;QAChB,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;CACH,CAAC;AAGF,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,WAc5F;AAED;;IAEI;AACJ,eAAO,MAAM,aAAa,YACf,QAAQ,OAAO,CAAC,OACpB,QAAQ,gBAAgB,CAAC,wBACR,MAAM,EAAE,KAC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"}
|
package/dist/lib/k8s.d.ts
CHANGED
|
@@ -128,16 +128,5 @@ export type WebhookIgnore = {
|
|
|
128
128
|
* Note: `kube-system` and `pepr-system` are always ignored.
|
|
129
129
|
*/
|
|
130
130
|
namespaces?: string[];
|
|
131
|
-
/**
|
|
132
|
-
* List of Kubernetes labels to always ignore.
|
|
133
|
-
* Any resources with these labels will be ignored by Pepr.
|
|
134
|
-
*
|
|
135
|
-
* The example below will ignore any resources with the label `my-label=ulta-secret`:
|
|
136
|
-
* ```
|
|
137
|
-
* alwaysIgnore:
|
|
138
|
-
* labels: [{ "my-label": "ultra-secret" }]
|
|
139
|
-
* ```
|
|
140
|
-
*/
|
|
141
|
-
labels?: Record<string, string>[];
|
|
142
131
|
};
|
|
143
132
|
//# sourceMappingURL=k8s.d.ts.map
|
package/dist/lib/k8s.d.ts.map
CHANGED
|
@@ -1 +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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AE,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;CACvB,CAAC"}
|
package/dist/lib/module.d.ts
CHANGED
|
@@ -6,8 +6,6 @@ export interface CustomLabels {
|
|
|
6
6
|
}
|
|
7
7
|
/** Global configuration for the Pepr runtime. */
|
|
8
8
|
export type ModuleConfig = {
|
|
9
|
-
/** The user-defined name for the module */
|
|
10
|
-
name: string;
|
|
11
9
|
/** The Pepr version this module uses */
|
|
12
10
|
peprVersion?: string;
|
|
13
11
|
/** The user-defined version of the module */
|
package/dist/lib/module.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../src/lib/module.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAA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,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;IAsD7G;;;;;OAKG;IACH,KAAK,0BAEH;CACH"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import { Capability } from "./capability";
|
|
2
|
-
export declare function
|
|
3
|
-
export declare function setupWatch(uuid: string, capabilities: Capability[]): Promise<void>;
|
|
2
|
+
export declare function setupWatch(capabilities: Capability[]): void;
|
|
4
3
|
//# sourceMappingURL=watch-processor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"watch-processor.d.ts","sourceRoot":"","sources":["../../src/lib/watch-processor.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"watch-processor.d.ts","sourceRoot":"","sources":["../../src/lib/watch-processor.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAS1C,wBAAgB,UAAU,CAAC,YAAY,EAAE,UAAU,EAAE,QAMpD"}
|