pepr 0.52.3-nightly.9 → 0.53.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.
- package/dist/cli/dev.d.ts.map +1 -1
- package/dist/cli/init/createProjectFiles.d.ts.map +1 -1
- package/dist/cli/init/doPostInitActions.d.ts.map +1 -1
- package/dist/cli/init/templates.d.ts +6 -0
- package/dist/cli/init/templates.d.ts.map +1 -1
- package/dist/cli.js +67 -17
- package/dist/controller.js +1 -1
- package/dist/lib/assets/webhooks.d.ts +5 -1
- package/dist/lib/assets/webhooks.d.ts.map +1 -1
- package/dist/lib/assets/yaml/overridesFile.d.ts +1 -0
- package/dist/lib/assets/yaml/overridesFile.d.ts.map +1 -1
- package/dist/lib/types.d.ts +7 -0
- package/dist/lib/types.d.ts.map +1 -1
- package/package.json +9 -3
- package/src/cli/dev.ts +6 -5
- package/src/cli/init/createProjectFiles.ts +3 -0
- package/src/cli/init/doPostInitActions.ts +5 -2
- package/src/cli/kfc.ts +2 -2
- package/src/cli/monitor.ts +6 -6
- package/src/cli.ts +4 -4
- package/src/lib/assets/webhooks.ts +53 -1
- package/src/lib/assets/yaml/overridesFile.ts +23 -1
- package/src/lib/types.ts +7 -0
package/dist/cli/dev.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../../src/cli/dev.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../../src/cli/dev.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AASpC,MAAM,CAAC,OAAO,WAAW,OAAO,EAAE,OAAO,GAAG,IAAI,CA6G/C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createProjectFiles.d.ts","sourceRoot":"","sources":["../../../src/cli/init/createProjectFiles.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"createProjectFiles.d.ts","sourceRoot":"","sources":["../../../src/cli/init/createProjectFiles.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,eAAe,EAWhB,MAAM,aAAa,CAAC;AAGrB,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,eAAe,GAC3B,OAAO,CAAC,IAAI,CAAC,CAyBf"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"doPostInitActions.d.ts","sourceRoot":"","sources":["../../../src/cli/init/doPostInitActions.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"doPostInitActions.d.ts","sourceRoot":"","sources":["../../../src/cli/init/doPostInitActions.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,iBAAiB,GAAI,SAAS,MAAM,KAAG,IAoBnD,CAAC"}
|
|
@@ -4,6 +4,7 @@ import { OnError, RbacMode } from "./enums";
|
|
|
4
4
|
import { V1PolicyRule as PolicyRule } from "@kubernetes/client-node";
|
|
5
5
|
export declare const dependencies: {
|
|
6
6
|
"@types/ramda": string;
|
|
7
|
+
"command-line-args": string;
|
|
7
8
|
commander: string;
|
|
8
9
|
express: string;
|
|
9
10
|
"fast-json-patch": string;
|
|
@@ -14,17 +15,22 @@ export declare const dependencies: {
|
|
|
14
15
|
pino: string;
|
|
15
16
|
"pino-pretty": string;
|
|
16
17
|
"prom-client": string;
|
|
18
|
+
"quicktype-core": string;
|
|
17
19
|
ramda: string;
|
|
18
20
|
"ts-morph": string;
|
|
19
21
|
}, devDependencies: {
|
|
20
22
|
"@commitlint/cli": string;
|
|
21
23
|
"@commitlint/config-conventional": string;
|
|
22
24
|
"@fast-check/vitest": string;
|
|
25
|
+
"@types/command-line-args": string;
|
|
23
26
|
"@types/eslint": string;
|
|
24
27
|
"@types/express": string;
|
|
25
28
|
"@types/json-pointer": string;
|
|
29
|
+
"@types/json-schema": string;
|
|
26
30
|
"@types/node": string;
|
|
27
31
|
"@types/node-forge": string;
|
|
32
|
+
"@types/readable-stream": string;
|
|
33
|
+
"@types/urijs": string;
|
|
28
34
|
"@types/uuid": string;
|
|
29
35
|
"@types/ws": string;
|
|
30
36
|
"@vitest/coverage-v8": string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../../../src/cli/init/templates.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,YAAY,IAAI,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAIrE,eAAO,MAAQ,YAAY
|
|
1
|
+
{"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../../../src/cli/init/templates.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,YAAY,IAAI,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAIrE,eAAO,MAAQ,YAAY;;;;;;;;;;;;;;;;GAAE,eAAe;;;;;;;;;;;;;;;;;;;;;;;;GAAE,gBAAgB;;;;;;;;;;;GAAE,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAAE,OAAO,QAAgB,CAAC;AAEjG,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE;QACJ,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;QAChB,WAAW,EAAE,MAAM,CAAC;QACpB,QAAQ,EAAE,MAAM,EAAE,CAAC;QACnB,OAAO,EAAE;YAAE,IAAI,EAAE,MAA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AAEF,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;CAGpB,CAAC;AAEF,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;CAGpB,CAAC;AAEF,eAAO,MAAM,MAAM;;;CAgBlB,CAAC"}
|
package/dist/cli.js
CHANGED
|
@@ -8088,6 +8088,7 @@ function resolveIgnoreNamespaces(ignoredNSConfig = []) {
|
|
|
8088
8088
|
}
|
|
8089
8089
|
|
|
8090
8090
|
// src/lib/assets/yaml/overridesFile.ts
|
|
8091
|
+
var import_quicktype_core = require("quicktype-core");
|
|
8091
8092
|
async function overridesFile({ hash, name: name2, image, config, apiPath, capabilities }, path4, imagePullSecrets, controllerType = { admission: true, watcher: true }) {
|
|
8092
8093
|
const rbacOverrides = clusterRole(name2, capabilities, config.rbacMode, config.rbac).rules;
|
|
8093
8094
|
const overrides = {
|
|
@@ -8247,8 +8248,20 @@ async function overridesFile({ hash, name: name2, image, config, apiPath, capabi
|
|
|
8247
8248
|
}
|
|
8248
8249
|
}
|
|
8249
8250
|
};
|
|
8251
|
+
await writeSchemaYamlFromObject(JSON.stringify(overrides, null, 2), path4);
|
|
8250
8252
|
await import_fs2.promises.writeFile(path4, (0, import_client_node.dumpYaml)(overrides, { noRefs: true, forceQuotes: true }));
|
|
8251
8253
|
}
|
|
8254
|
+
async function writeSchemaYamlFromObject(valuesString, valuesFilePath) {
|
|
8255
|
+
const schemaPath = valuesFilePath.replace(/\.yaml$/, ".schema.json");
|
|
8256
|
+
const jsonInput = (0, import_quicktype_core.jsonInputForTargetLanguage)("schema");
|
|
8257
|
+
await jsonInput.addSource({ name: "Values", samples: [valuesString] });
|
|
8258
|
+
const inputData = new import_quicktype_core.InputData();
|
|
8259
|
+
inputData.addInput(jsonInput);
|
|
8260
|
+
const { lines } = await (0, import_quicktype_core.quicktype)({ inputData, lang: "schema" });
|
|
8261
|
+
const schemaJson = lines.join("\n");
|
|
8262
|
+
const schemaObj = JSON.parse(schemaJson);
|
|
8263
|
+
await import_fs2.promises.writeFile(schemaPath, JSON.stringify(schemaObj, null, 2), "utf8");
|
|
8264
|
+
}
|
|
8252
8265
|
|
|
8253
8266
|
// src/lib/assets/index.ts
|
|
8254
8267
|
var import_client_node2 = require("@kubernetes/client-node");
|
|
@@ -9068,7 +9081,7 @@ async function webhookConfigGenerator(assets, mutateOrValidate, timeoutSeconds =
|
|
|
9068
9081
|
if (rules.length < 1) {
|
|
9069
9082
|
return null;
|
|
9070
9083
|
}
|
|
9071
|
-
|
|
9084
|
+
const webhookConfig = {
|
|
9072
9085
|
apiVersion: "admissionregistration.k8s.io/v1",
|
|
9073
9086
|
kind: isMutate ? "MutatingWebhookConfiguration" : "ValidatingWebhookConfiguration",
|
|
9074
9087
|
metadata: { name: name2 },
|
|
@@ -9089,6 +9102,43 @@ async function webhookConfigGenerator(assets, mutateOrValidate, timeoutSeconds =
|
|
|
9089
9102
|
}
|
|
9090
9103
|
]
|
|
9091
9104
|
};
|
|
9105
|
+
if (config.additionalWebhooks) {
|
|
9106
|
+
return configureAdditionalWebhooks(webhookConfig, config.additionalWebhooks);
|
|
9107
|
+
}
|
|
9108
|
+
return webhookConfig;
|
|
9109
|
+
}
|
|
9110
|
+
function configureAdditionalWebhooks(webhookConfig, additionalWebhooks) {
|
|
9111
|
+
if (!additionalWebhooks || additionalWebhooks.length === 0) {
|
|
9112
|
+
return webhookConfig;
|
|
9113
|
+
}
|
|
9114
|
+
const webhooks = webhookConfig.webhooks ?? [];
|
|
9115
|
+
if (webhooks.length === 0) {
|
|
9116
|
+
return webhookConfig;
|
|
9117
|
+
}
|
|
9118
|
+
const expr = webhooks[0].namespaceSelector.matchExpressions[0];
|
|
9119
|
+
expr.values.push(...additionalWebhooks.map((w) => w.namespace));
|
|
9120
|
+
additionalWebhooks.forEach((additionalWebhook) => {
|
|
9121
|
+
webhooks.push({
|
|
9122
|
+
name: `${webhookConfig.metadata.name}-${additionalWebhook.namespace}.pepr.dev`,
|
|
9123
|
+
admissionReviewVersions: ["v1", "v1beta1"],
|
|
9124
|
+
clientConfig: webhooks[0].clientConfig,
|
|
9125
|
+
failurePolicy: additionalWebhook.failurePolicy,
|
|
9126
|
+
matchPolicy: "Equivalent",
|
|
9127
|
+
timeoutSeconds: webhooks[0].timeoutSeconds,
|
|
9128
|
+
namespaceSelector: {
|
|
9129
|
+
matchExpressions: [
|
|
9130
|
+
{
|
|
9131
|
+
key: "kubernetes.io/metadata.name",
|
|
9132
|
+
operator: "In",
|
|
9133
|
+
values: [additionalWebhook.namespace]
|
|
9134
|
+
}
|
|
9135
|
+
]
|
|
9136
|
+
},
|
|
9137
|
+
rules: webhooks[0].rules,
|
|
9138
|
+
sideEffects: "None"
|
|
9139
|
+
});
|
|
9140
|
+
});
|
|
9141
|
+
return webhookConfig;
|
|
9092
9142
|
}
|
|
9093
9143
|
|
|
9094
9144
|
// src/lib/assets/yaml/generateAllYaml.ts
|
|
@@ -9521,7 +9571,7 @@ var gitIgnore = "# Ignore node_modules and Pepr build artifacts\nnode_modules\nd
|
|
|
9521
9571
|
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```text\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';
|
|
9522
9572
|
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';
|
|
9523
9573
|
var helloPeprTS = 'import {\n Capability,\n K8s,\n Log,\n PeprMutateRequest,\n RegisterKind,\n a,\n fetch,\n fetchStatus,\n kind,\n} from "pepr";\nimport { MockAgent, setGlobalDispatcher } from "undici";\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.SetLabel("pepr", "was-here").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>): void {\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).IsCreated().InNamespace("pepr-demo-2").WithName("example-4a").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://icanhazdadjoke.com/");\n * const joke = await fetch("https://icanhazdadjoke.com/") as TheChuckNorrisJoke;\n * ```\n *\n * Alternatively, you can drop the type completely:\n *\n * ```ts\n * fetch("https://icanhazdadjoke.com")\n * ```\n */\ninterface TheChuckNorrisJoke {\n id: string;\n joke: string;\n status: number;\n}\n\nWhen(a.ConfigMap)\n .IsCreatedOrUpdated()\n .WithLabel("chuck-norris")\n .Mutate(cm => cm.SetLabel("got-jokes", "true"))\n .Watch(async cm => {\n const jokeURL = "https://icanhazdadjoke.com";\n\n const mockAgent: MockAgent = new MockAgent();\n setGlobalDispatcher(mockAgent);\n const mockClient = mockAgent.get(jokeURL);\n mockClient.intercept({ path: "/", method: "GET" }).reply(\n 200,\n {\n id: "R7UfaahVfFd",\n joke: "Funny joke goes here.",\n status: 200,\n },\n {\n headers: {\n "Content-Type": "application/json; charset=utf-8",\n },\n },\n );\n\n // Try/catch is not needed as a response object will always be returned\n const response = await fetch<TheChuckNorrisJoke>(jokeURL, {\n headers: {\n Accept: "application/json",\n },\n });\n\n // Instead, check the `response.ok` field\n if (response.ok) {\n const { joke } = response.data;\n // Add Joke to the Store\n await Store.setItemAndWait(jokeURL, joke);\n // Add the Chuck Norris joke to the configmap\n try {\n await K8s(kind.ConfigMap).Apply({\n metadata: {\n name: cm.metadata.name,\n namespace: cm.metadata.namespace,\n },\n data: {\n "chuck-says": Store.getItem(jokeURL),\n },\n });\n } catch (error) {\n Log.error(error, "Failed to apply ConfigMap using server-side apply.", {\n cm,\n });\n }\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';
|
|
9524
|
-
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" }, files: ["/dist", "/src", "!src/**/*.test.ts", "!src/fixtures/**", "!dist/**/*.test.d.ts*"], version: "0.
|
|
9574
|
+
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" }, files: ["/dist", "/src", "!src/**/*.test.ts", "!src/fixtures/**", "!dist/**/*.test.d.ts*"], version: "0.53.0", main: "dist/lib.js", types: "dist/lib.d.ts", scripts: { build: "tsc -p config/tsconfig.root.json && node build.mjs && npm pack", "build:image": "npm run build && docker buildx build --output type=docker --tag pepr:dev .", "build:image:unicorn": "npm run build && docker buildx build --output type=docker --tag pepr/private:dev $(node scripts/read-unicorn-build-args.mjs) .", ci: "npm ci", "cluster:k3d": "k3d cluster delete pepr-dev && k3d cluster create pepr-dev --k3s-arg '--debug@server:0' --wait && kubectl rollout status deployment -n kube-system", "cluster:k3d:import-upstream": "npm run build && docker buildx build --output type=docker --tag pepr:dev . && k3d image import pepr:dev -c pepr-dev", "cluster:k3d:import-unicorn": "npm run build && docker buildx build --output type=docker --tag pepr/private:dev $(node scripts/read-unicorn-build-args.mjs) . && k3d image import pepr/private:dev -c pepr-dev", "format:check": "npm run format:src && npm run format:tests && npm run format:markdown && npm run format:integration && npm run format:prettier -- --check", "format:fix": "npm run format:src -- --fix && npm run format:markdown -- --fix && npm run format:integration -- --fix && npm run format:prettier -- --write", "format:integration": "eslint --config config/eslint.integration.config.mjs integration/cli integration/helpers", "format:markdown": 'npx -y markdownlint-cli --config config/.markdownlint.json --ignore adr --ignore integration/testroot --ignore pepr-test-module --ignore node_modules "**/*.md"', "format:prettier": "prettier --config config/.prettierrc src integration/cli/**/*.ts integration/helpers/**/*.ts", "format:src": "eslint --config config/eslint.root.config.mjs 'src/**/*.ts' --ignore-pattern '**/*.test.ts' --ignore-pattern 'src/templates/**'", "format:tests": "eslint --config config/eslint.test.config.mjs 'src/**/*.test.ts'", "gen-data-json": "node hack/build-template-data.js", prebuild: "rm -fr dist/* && npm run gen-data-json", prepare: `if [ "$NODE_ENV" != 'production' ]; then husky; fi`, "set:version": "node scripts/set-version.js", test: "npm run test:unit && npm run test:integration", "test:artifacts": "npm run build && vitest run src/build-artifact.test.ts", "test:docs": "vitest run --config=config/vitest.integration.config.ts integration/cli/docs/*.test.ts", "test:integration": "npm run test:integration:prep && npm run test:integration:run", "test:integration:prep": "./integration/prep.sh", "test:integration:run": "vitest run --config=config/vitest.integration.config.ts integration", "test:unit": "npm run gen-data-json && NODE_OPTIONS=--no-deprecation vitest --config config/vitest.root.config.ts run --coverage", "test:upgrade:unicorn": "npm run cluster:k3d && npm run cluster:k3d:import-unicorn && vitest run integration/cluster/upgrade.test.ts", "test:upgrade:upstream": "npm run cluster:k3d && npm run cluster:k3d:import-upstream && vitest run integration/cluster/upgrade.test.ts" }, dependencies: { "@types/ramda": "0.31.0", "command-line-args": "^6.0.1", commander: "14.0.0", express: "5.1.0", "fast-json-patch": "3.1.1", heredoc: "^1.3.1", "http-status-codes": "^2.3.0", "json-pointer": "^0.6.2", "kubernetes-fluent-client": "3.10.1", pino: "9.7.0", "pino-pretty": "13.1.1", "prom-client": "15.1.3", "quicktype-core": "^23.2.6", ramda: "0.31.3", "ts-morph": "^26.0.0" }, devDependencies: { "@commitlint/cli": "19.8.1", "@commitlint/config-conventional": "19.8.1", "@fast-check/vitest": "^0.2.1", "@types/command-line-args": "^5.2.3", "@types/eslint": "9.6.1", "@types/express": "5.0.3", "@types/json-pointer": "^1.0.34", "@types/json-schema": "^7.0.15", "@types/node": "24.x.x", "@types/node-forge": "1.3.13", "@types/readable-stream": "^4.0.21", "@types/urijs": "^1.19.25", "@types/uuid": "10.0.0", "@types/ws": "^8.18.1", "@vitest/coverage-v8": "^3.2.3", "fast-check": "^4.0.0", globals: "^16.0.0", husky: "^9.1.6", "js-yaml": "^4.1.0", shellcheck: "^4.1.0", tsx: "^4.20.3", undici: "^7.0.1", vitest: "^3.2.3" }, overrides: { glob: "^9.0.0" }, peerDependencies: { "@types/prompts": "2.4.9", "@typescript-eslint/eslint-plugin": "8.38.0", "@typescript-eslint/parser": "8.38.0", esbuild: "0.25.8", eslint: "9.32.0", "node-forge": "1.3.1", prettier: "3.6.2", prompts: "2.4.2", typescript: "5.8.3", uuid: "11.1.0" } };
|
|
9525
9575
|
|
|
9526
9576
|
// src/cli/init/utils.ts
|
|
9527
9577
|
var import_fs7 = require("fs");
|
|
@@ -10317,12 +10367,12 @@ function dev_default(program2) {
|
|
|
10317
10367
|
const scheduleStore = `pepr-${cfg.pepr.uuid}-schedule`;
|
|
10318
10368
|
const store = `pepr-${cfg.pepr.uuid}-store`;
|
|
10319
10369
|
const runFork = async () => {
|
|
10320
|
-
|
|
10370
|
+
logger_default.info(`Running module ${path4}`);
|
|
10321
10371
|
await webhook.deploy(deployWebhook, false, 30);
|
|
10322
10372
|
try {
|
|
10323
10373
|
validateCapabilityNames(webhook.capabilities);
|
|
10324
10374
|
} catch (error) {
|
|
10325
|
-
|
|
10375
|
+
logger_default.error(
|
|
10326
10376
|
`CapabilityValidation Error - Unable to valide capability name(s) in: '${webhook.capabilities.map((item) => item.name)}'
|
|
10327
10377
|
${error}`
|
|
10328
10378
|
);
|
|
@@ -10349,12 +10399,12 @@ ${error}`
|
|
|
10349
10399
|
]);
|
|
10350
10400
|
});
|
|
10351
10401
|
process.on("SIGINT", () => {
|
|
10352
|
-
|
|
10402
|
+
logger_default.debug(`Received SIGINT, removing webhooks`);
|
|
10353
10403
|
});
|
|
10354
10404
|
};
|
|
10355
10405
|
await buildModule("dist", async (r) => {
|
|
10356
10406
|
if (r.errors.length > 0) {
|
|
10357
|
-
|
|
10407
|
+
logger_default.error(`Error compiling module: ${r.errors}`);
|
|
10358
10408
|
return;
|
|
10359
10409
|
}
|
|
10360
10410
|
if (program3) {
|
|
@@ -10365,7 +10415,7 @@ ${error}`
|
|
|
10365
10415
|
}
|
|
10366
10416
|
});
|
|
10367
10417
|
} catch (e) {
|
|
10368
|
-
|
|
10418
|
+
logger_default.error(`Error deploying module:`, e);
|
|
10369
10419
|
process.exit(1);
|
|
10370
10420
|
}
|
|
10371
10421
|
});
|
|
@@ -10381,7 +10431,7 @@ function monitor_default(program2) {
|
|
|
10381
10431
|
const pods = await (0, import_kubernetes_fluent_client6.K8s)(import_kubernetes_fluent_client6.kind.Pod).InNamespace("pepr-system").WithLabel(labels[0], labels[1]).Get();
|
|
10382
10432
|
const podNames = pods.items.flatMap((pod) => pod.metadata.name || "");
|
|
10383
10433
|
if (podNames.length < 1) {
|
|
10384
|
-
|
|
10434
|
+
logger_default.error(errorMessage);
|
|
10385
10435
|
process.exit(1);
|
|
10386
10436
|
}
|
|
10387
10437
|
const log = getK8sLogFromKubeConfig();
|
|
@@ -10443,20 +10493,20 @@ function processMutateLog(payload, name2, uid) {
|
|
|
10443
10493
|
const patch = plainPatch !== "" && JSON.stringify(JSON.parse(plainPatch), null, 2);
|
|
10444
10494
|
const patchType = payload.res.patchType || payload.res.warnings || "";
|
|
10445
10495
|
const allowOrDeny = payload.res.allowed ? "\u{1F500}" : "\u{1F6AB}";
|
|
10446
|
-
|
|
10496
|
+
logger_default.info(`
|
|
10447
10497
|
${allowOrDeny} MUTATE ${name2} (${uid})`);
|
|
10448
10498
|
if (patchType.length > 0) {
|
|
10449
|
-
|
|
10499
|
+
logger_default.info(`
|
|
10450
10500
|
\x1B[1;34m${patch}\x1B[0m`);
|
|
10451
10501
|
}
|
|
10452
10502
|
}
|
|
10453
10503
|
function processValidateLog(payload, name2, uid) {
|
|
10454
10504
|
const failures = Array.isArray(payload.res) ? payload.res : [payload.res];
|
|
10455
10505
|
const filteredFailures = failures.filter((r) => !r.allowed).map((r) => r.status?.message || "");
|
|
10456
|
-
|
|
10506
|
+
logger_default.info(`
|
|
10457
10507
|
${filteredFailures.length > 0 ? "\u274C" : "\u2705"} VALIDATE ${name2} (${uid})`);
|
|
10458
10508
|
if (filteredFailures.length > 0) {
|
|
10459
|
-
|
|
10509
|
+
logger_default.info(`\x1B[1;31m${filteredFailures}\x1B[0m`);
|
|
10460
10510
|
}
|
|
10461
10511
|
}
|
|
10462
10512
|
|
|
@@ -10632,7 +10682,7 @@ var doPostInitActions = (dirName) => {
|
|
|
10632
10682
|
stdio: "inherit"
|
|
10633
10683
|
});
|
|
10634
10684
|
} catch {
|
|
10635
|
-
|
|
10685
|
+
logger_default.warn("VSCode was not found, IDE will not automatically open.");
|
|
10636
10686
|
}
|
|
10637
10687
|
};
|
|
10638
10688
|
|
|
@@ -10828,7 +10878,7 @@ function kfc_default(program2) {
|
|
|
10828
10878
|
stdio: "inherit"
|
|
10829
10879
|
});
|
|
10830
10880
|
} catch (e) {
|
|
10831
|
-
|
|
10881
|
+
logger_default.error(`Error creating CRD generated class:`, e);
|
|
10832
10882
|
process.exit(1);
|
|
10833
10883
|
}
|
|
10834
10884
|
});
|
|
@@ -11191,7 +11241,7 @@ function crd_default() {
|
|
|
11191
11241
|
|
|
11192
11242
|
// src/cli.ts
|
|
11193
11243
|
if (process.env.npm_lifecycle_event !== "npx") {
|
|
11194
|
-
|
|
11244
|
+
logger_default.info("Pepr should be run via `npx pepr <command>` instead of `pepr <command>`.");
|
|
11195
11245
|
}
|
|
11196
11246
|
var program = new import_commander7.Command();
|
|
11197
11247
|
if (!process.env.PEPR_NODE_WARNINGS) {
|
|
@@ -11199,10 +11249,10 @@ if (!process.env.PEPR_NODE_WARNINGS) {
|
|
|
11199
11249
|
}
|
|
11200
11250
|
program.enablePositionalOptions().version(version).description(`Pepr (v${version}) - Type safe K8s middleware for humans`).addCommand(crd_default()).addCommand(init_default()).action(() => {
|
|
11201
11251
|
if (program.args.length < 1) {
|
|
11202
|
-
|
|
11252
|
+
logger_default.info(banner);
|
|
11203
11253
|
program.help();
|
|
11204
11254
|
} else {
|
|
11205
|
-
|
|
11255
|
+
logger_default.error(`Invalid command '${program.args.join(" ")}'
|
|
11206
11256
|
`);
|
|
11207
11257
|
program.outputHelp();
|
|
11208
11258
|
process.exitCode = 1;
|
package/dist/controller.js
CHANGED
|
@@ -60,7 +60,7 @@ if (process.env.LOG_LEVEL) {
|
|
|
60
60
|
var logger_default = Log;
|
|
61
61
|
|
|
62
62
|
// src/templates/data.json
|
|
63
|
-
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" }, files: ["/dist", "/src", "!src/**/*.test.ts", "!src/fixtures/**", "!dist/**/*.test.d.ts*"], version: "0.
|
|
63
|
+
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" }, files: ["/dist", "/src", "!src/**/*.test.ts", "!src/fixtures/**", "!dist/**/*.test.d.ts*"], version: "0.53.0", main: "dist/lib.js", types: "dist/lib.d.ts", scripts: { build: "tsc -p config/tsconfig.root.json && node build.mjs && npm pack", "build:image": "npm run build && docker buildx build --output type=docker --tag pepr:dev .", "build:image:unicorn": "npm run build && docker buildx build --output type=docker --tag pepr/private:dev $(node scripts/read-unicorn-build-args.mjs) .", ci: "npm ci", "cluster:k3d": "k3d cluster delete pepr-dev && k3d cluster create pepr-dev --k3s-arg '--debug@server:0' --wait && kubectl rollout status deployment -n kube-system", "cluster:k3d:import-upstream": "npm run build && docker buildx build --output type=docker --tag pepr:dev . && k3d image import pepr:dev -c pepr-dev", "cluster:k3d:import-unicorn": "npm run build && docker buildx build --output type=docker --tag pepr/private:dev $(node scripts/read-unicorn-build-args.mjs) . && k3d image import pepr/private:dev -c pepr-dev", "format:check": "npm run format:src && npm run format:tests && npm run format:markdown && npm run format:integration && npm run format:prettier -- --check", "format:fix": "npm run format:src -- --fix && npm run format:markdown -- --fix && npm run format:integration -- --fix && npm run format:prettier -- --write", "format:integration": "eslint --config config/eslint.integration.config.mjs integration/cli integration/helpers", "format:markdown": 'npx -y markdownlint-cli --config config/.markdownlint.json --ignore adr --ignore integration/testroot --ignore pepr-test-module --ignore node_modules "**/*.md"', "format:prettier": "prettier --config config/.prettierrc src integration/cli/**/*.ts integration/helpers/**/*.ts", "format:src": "eslint --config config/eslint.root.config.mjs 'src/**/*.ts' --ignore-pattern '**/*.test.ts' --ignore-pattern 'src/templates/**'", "format:tests": "eslint --config config/eslint.test.config.mjs 'src/**/*.test.ts'", "gen-data-json": "node hack/build-template-data.js", prebuild: "rm -fr dist/* && npm run gen-data-json", prepare: `if [ "$NODE_ENV" != 'production' ]; then husky; fi`, "set:version": "node scripts/set-version.js", test: "npm run test:unit && npm run test:integration", "test:artifacts": "npm run build && vitest run src/build-artifact.test.ts", "test:docs": "vitest run --config=config/vitest.integration.config.ts integration/cli/docs/*.test.ts", "test:integration": "npm run test:integration:prep && npm run test:integration:run", "test:integration:prep": "./integration/prep.sh", "test:integration:run": "vitest run --config=config/vitest.integration.config.ts integration", "test:unit": "npm run gen-data-json && NODE_OPTIONS=--no-deprecation vitest --config config/vitest.root.config.ts run --coverage", "test:upgrade:unicorn": "npm run cluster:k3d && npm run cluster:k3d:import-unicorn && vitest run integration/cluster/upgrade.test.ts", "test:upgrade:upstream": "npm run cluster:k3d && npm run cluster:k3d:import-upstream && vitest run integration/cluster/upgrade.test.ts" }, dependencies: { "@types/ramda": "0.31.0", "command-line-args": "^6.0.1", commander: "14.0.0", express: "5.1.0", "fast-json-patch": "3.1.1", heredoc: "^1.3.1", "http-status-codes": "^2.3.0", "json-pointer": "^0.6.2", "kubernetes-fluent-client": "3.10.1", pino: "9.7.0", "pino-pretty": "13.1.1", "prom-client": "15.1.3", "quicktype-core": "^23.2.6", ramda: "0.31.3", "ts-morph": "^26.0.0" }, devDependencies: { "@commitlint/cli": "19.8.1", "@commitlint/config-conventional": "19.8.1", "@fast-check/vitest": "^0.2.1", "@types/command-line-args": "^5.2.3", "@types/eslint": "9.6.1", "@types/express": "5.0.3", "@types/json-pointer": "^1.0.34", "@types/json-schema": "^7.0.15", "@types/node": "24.x.x", "@types/node-forge": "1.3.13", "@types/readable-stream": "^4.0.21", "@types/urijs": "^1.19.25", "@types/uuid": "10.0.0", "@types/ws": "^8.18.1", "@vitest/coverage-v8": "^3.2.3", "fast-check": "^4.0.0", globals: "^16.0.0", husky: "^9.1.6", "js-yaml": "^4.1.0", shellcheck: "^4.1.0", tsx: "^4.20.3", undici: "^7.0.1", vitest: "^3.2.3" }, overrides: { glob: "^9.0.0" }, peerDependencies: { "@types/prompts": "2.4.9", "@typescript-eslint/eslint-plugin": "8.38.0", "@typescript-eslint/parser": "8.38.0", esbuild: "0.25.8", eslint: "9.32.0", "node-forge": "1.3.1", prettier: "3.6.2", prompts: "2.4.2", typescript: "5.8.3", uuid: "11.1.0" } };
|
|
64
64
|
|
|
65
65
|
// src/lib/k8s.ts
|
|
66
66
|
var import_kubernetes_fluent_client = require("kubernetes-fluent-client");
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { V1RuleWithOperations } from "@kubernetes/client-node";
|
|
1
|
+
import { V1RuleWithOperations, V1MutatingWebhookConfiguration, V1ValidatingWebhookConfiguration } from "@kubernetes/client-node";
|
|
2
2
|
import { kind } from "kubernetes-fluent-client";
|
|
3
3
|
import { Assets } from "./assets";
|
|
4
4
|
import { WebhookType } from "../enums";
|
|
@@ -7,4 +7,8 @@ export declare const peprIgnoreNamespaces: string[];
|
|
|
7
7
|
export declare const validateRule: (binding: Binding, isMutateWebhook: boolean) => V1RuleWithOperations | undefined;
|
|
8
8
|
export declare function generateWebhookRules(assets: Assets, isMutateWebhook: boolean): Promise<V1RuleWithOperations[]>;
|
|
9
9
|
export declare function webhookConfigGenerator(assets: Assets, mutateOrValidate: WebhookType, timeoutSeconds?: number): Promise<kind.MutatingWebhookConfiguration | kind.ValidatingWebhookConfiguration | null>;
|
|
10
|
+
export declare function configureAdditionalWebhooks(webhookConfig: V1MutatingWebhookConfiguration | V1ValidatingWebhookConfiguration, additionalWebhooks: {
|
|
11
|
+
failurePolicy: "Fail" | "Ignore";
|
|
12
|
+
namespace: string;
|
|
13
|
+
}[]): V1MutatingWebhookConfiguration | V1ValidatingWebhookConfiguration;
|
|
10
14
|
//# 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,
|
|
1
|
+
{"version":3,"file":"webhooks.d.ts","sourceRoot":"","sources":["../../../src/lib/assets/webhooks.ts"],"names":[],"mappings":"AAGA,OAAO,EAGL,oBAAoB,EACpB,8BAA8B,EAC9B,gCAAgC,EACjC,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAGhD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAS,WAAW,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAEnC,eAAO,MAAM,oBAAoB,EAAE,MAAM,EAAmC,CAAC;AAE7E,eAAO,MAAM,YAAY,GACvB,SAAS,OAAO,EAChB,iBAAiB,OAAO,KACvB,oBAAoB,GAAG,SAsBzB,CAAC;AAEF,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,MAAM,EACd,eAAe,EAAE,OAAO,GACvB,OAAO,CAAC,oBAAoB,EAAE,CAAC,CAUjC;AAED,wBAAsB,sBAAsB,CAC1C,MAAM,EAAE,MAAM,EACd,gBAAgB,EAAE,WAAW,EAC7B,cAAc,SAAK,GAClB,OAAO,CAAC,IAAI,CAAC,4BAA4B,GAAG,IAAI,CAAC,8BAA8B,GAAG,IAAI,CAAC,CA6EzF;AAED,wBAAgB,2BAA2B,CACzC,aAAa,EAAE,8BAA8B,GAAG,gCAAgC,EAChF,kBAAkB,EAAE;IAClB,aAAa,EAAE,MAAM,GAAG,QAAQ,CAAC;IACjC,SAAS,EAAE,MAAM,CAAC;CACnB,EAAE,GACF,8BAA8B,GAAG,gCAAgC,CAmCnE"}
|
|
@@ -11,4 +11,5 @@ export declare function overridesFile({ hash, name, image, config, apiPath, capa
|
|
|
11
11
|
admission: boolean;
|
|
12
12
|
watcher: boolean;
|
|
13
13
|
}): Promise<void>;
|
|
14
|
+
export declare function writeSchemaYamlFromObject(valuesString: string, valuesFilePath: string): Promise<void>;
|
|
14
15
|
//# sourceMappingURL=overridesFile.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"overridesFile.d.ts","sourceRoot":"","sources":["../../../../src/lib/assets/yaml/overridesFile.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"overridesFile.d.ts","sourceRoot":"","sources":["../../../../src/lib/assets/yaml/overridesFile.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAO7D,MAAM,MAAM,cAAc,GAAG;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,gBAAgB,EAAE,CAAC;IACjC,MAAM,EAAE,YAAY,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAGF,wBAAsB,aAAa,CACjC,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,EAAE,cAAc,EACpE,IAAI,EAAE,MAAM,EACZ,gBAAgB,EAAE,MAAM,EAAE,EAC1B,cAAc,GAAE;IAAE,SAAS,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAuC,GAC5F,OAAO,CAAC,IAAI,CAAC,CAqKf;AAED,wBAAsB,yBAAyB,CAC7C,YAAY,EAAE,MAAM,EACpB,cAAc,EAAE,MAAM,GACrB,OAAO,CAAC,IAAI,CAAC,CAcf"}
|
package/dist/lib/types.d.ts
CHANGED
|
@@ -258,6 +258,13 @@ export type ModuleConfig = {
|
|
|
258
258
|
watch?: {
|
|
259
259
|
alwaysIgnore: WebhookIgnore;
|
|
260
260
|
};
|
|
261
|
+
/** Additional webhooks config to be used by the module */
|
|
262
|
+
additionalWebhooks?: [
|
|
263
|
+
{
|
|
264
|
+
failurePolicy: "Fail" | "Ignore";
|
|
265
|
+
namespace: string;
|
|
266
|
+
}
|
|
267
|
+
];
|
|
261
268
|
} & Partial<ModuleConfigOptions>;
|
|
262
269
|
export type PackageJSON = {
|
|
263
270
|
description: string;
|
package/dist/lib/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/lib/types.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EA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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;AACF,MAAM,MAAM,kBAAkB,GAAG,MAAM,GAAG,IAAI,CAAC"}
|
package/package.json
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"!src/fixtures/**",
|
|
17
17
|
"!dist/**/*.test.d.ts*"
|
|
18
18
|
],
|
|
19
|
-
"version": "0.
|
|
19
|
+
"version": "0.53.0",
|
|
20
20
|
"main": "dist/lib.js",
|
|
21
21
|
"types": "dist/lib.d.ts",
|
|
22
22
|
"scripts": {
|
|
@@ -50,16 +50,18 @@
|
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
52
|
"@types/ramda": "0.31.0",
|
|
53
|
+
"command-line-args": "^6.0.1",
|
|
53
54
|
"commander": "14.0.0",
|
|
54
55
|
"express": "5.1.0",
|
|
55
56
|
"fast-json-patch": "3.1.1",
|
|
56
57
|
"heredoc": "^1.3.1",
|
|
57
58
|
"http-status-codes": "^2.3.0",
|
|
58
59
|
"json-pointer": "^0.6.2",
|
|
59
|
-
"kubernetes-fluent-client": "3.10.
|
|
60
|
+
"kubernetes-fluent-client": "3.10.1",
|
|
60
61
|
"pino": "9.7.0",
|
|
61
62
|
"pino-pretty": "13.1.1",
|
|
62
63
|
"prom-client": "15.1.3",
|
|
64
|
+
"quicktype-core": "^23.2.6",
|
|
63
65
|
"ramda": "0.31.3",
|
|
64
66
|
"ts-morph": "^26.0.0"
|
|
65
67
|
},
|
|
@@ -67,11 +69,15 @@
|
|
|
67
69
|
"@commitlint/cli": "19.8.1",
|
|
68
70
|
"@commitlint/config-conventional": "19.8.1",
|
|
69
71
|
"@fast-check/vitest": "^0.2.1",
|
|
72
|
+
"@types/command-line-args": "^5.2.3",
|
|
70
73
|
"@types/eslint": "9.6.1",
|
|
71
74
|
"@types/express": "5.0.3",
|
|
72
75
|
"@types/json-pointer": "^1.0.34",
|
|
76
|
+
"@types/json-schema": "^7.0.15",
|
|
73
77
|
"@types/node": "24.x.x",
|
|
74
78
|
"@types/node-forge": "1.3.13",
|
|
79
|
+
"@types/readable-stream": "^4.0.21",
|
|
80
|
+
"@types/urijs": "^1.19.25",
|
|
75
81
|
"@types/uuid": "10.0.0",
|
|
76
82
|
"@types/ws": "^8.18.1",
|
|
77
83
|
"@vitest/coverage-v8": "^3.2.3",
|
|
@@ -99,4 +105,4 @@
|
|
|
99
105
|
"typescript": "5.8.3",
|
|
100
106
|
"uuid": "11.1.0"
|
|
101
107
|
}
|
|
102
|
-
}
|
|
108
|
+
}
|
package/src/cli/dev.ts
CHANGED
|
@@ -12,6 +12,7 @@ import { loadModule } from "./build/loadModule";
|
|
|
12
12
|
import { deployWebhook } from "../lib/assets/deploy";
|
|
13
13
|
import { promises as fs } from "fs";
|
|
14
14
|
import { validateCapabilityNames } from "../lib/helpers";
|
|
15
|
+
import Log from "../lib/telemetry/logger";
|
|
15
16
|
|
|
16
17
|
export default function (program: Command): void {
|
|
17
18
|
program
|
|
@@ -61,7 +62,7 @@ export default function (program: Command): void {
|
|
|
61
62
|
|
|
62
63
|
// Run the processed javascript file
|
|
63
64
|
const runFork = async (): Promise<void> => {
|
|
64
|
-
|
|
65
|
+
Log.info(`Running module ${path}`);
|
|
65
66
|
|
|
66
67
|
// Deploy the webhook with a 30 second timeout for debugging, don't force
|
|
67
68
|
await webhook.deploy(deployWebhook, false, 30);
|
|
@@ -70,7 +71,7 @@ export default function (program: Command): void {
|
|
|
70
71
|
// wait for capabilities to be loaded and test names
|
|
71
72
|
validateCapabilityNames(webhook.capabilities);
|
|
72
73
|
} catch (error) {
|
|
73
|
-
|
|
74
|
+
Log.error(
|
|
74
75
|
`CapabilityValidation Error - Unable to valide capability name(s) in: '${webhook.capabilities.map(item => item.name)}'\n${error}`,
|
|
75
76
|
);
|
|
76
77
|
process.exit(1);
|
|
@@ -100,13 +101,13 @@ export default function (program: Command): void {
|
|
|
100
101
|
|
|
101
102
|
// listen for CTRL+C and remove webhooks
|
|
102
103
|
process.on("SIGINT", () => {
|
|
103
|
-
|
|
104
|
+
Log.debug(`Received SIGINT, removing webhooks`);
|
|
104
105
|
});
|
|
105
106
|
};
|
|
106
107
|
|
|
107
108
|
await buildModule("dist", async r => {
|
|
108
109
|
if (r.errors.length > 0) {
|
|
109
|
-
|
|
110
|
+
Log.error(`Error compiling module: ${r.errors}`);
|
|
110
111
|
return;
|
|
111
112
|
}
|
|
112
113
|
|
|
@@ -118,7 +119,7 @@ export default function (program: Command): void {
|
|
|
118
119
|
}
|
|
119
120
|
});
|
|
120
121
|
} catch (e) {
|
|
121
|
-
|
|
122
|
+
Log.error(`Error deploying module:`, e);
|
|
122
123
|
process.exit(1);
|
|
123
124
|
}
|
|
124
125
|
});
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// SPDX-FileCopyrightText: 2023-Present The Pepr Authors
|
|
2
3
|
|
|
4
|
+
import { execSync } from "child_process";
|
|
5
|
+
import Log from "../../lib/telemetry/logger";
|
|
3
6
|
export const doPostInitActions = (dirName: string): void => {
|
|
4
7
|
// run npm install from the new directory
|
|
5
8
|
process.chdir(dirName);
|
|
@@ -18,6 +21,6 @@ export const doPostInitActions = (dirName: string): void => {
|
|
|
18
21
|
stdio: "inherit",
|
|
19
22
|
});
|
|
20
23
|
} catch {
|
|
21
|
-
|
|
24
|
+
Log.warn("VSCode was not found, IDE will not automatically open.");
|
|
22
25
|
}
|
|
23
26
|
};
|
package/src/cli/kfc.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
import { execSync } from "child_process";
|
|
5
5
|
import prompt from "prompts";
|
|
6
|
-
|
|
6
|
+
import Log from "../lib/telemetry/logger";
|
|
7
7
|
import { Command } from "commander";
|
|
8
8
|
|
|
9
9
|
export default function (program: Command): void {
|
|
@@ -42,7 +42,7 @@ export default function (program: Command): void {
|
|
|
42
42
|
stdio: "inherit",
|
|
43
43
|
});
|
|
44
44
|
} catch (e) {
|
|
45
|
-
|
|
45
|
+
Log.error(`Error creating CRD generated class:`, e);
|
|
46
46
|
process.exit(1);
|
|
47
47
|
}
|
|
48
48
|
});
|
package/src/cli/monitor.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { K8s, kind } from "kubernetes-fluent-client";
|
|
|
6
6
|
import stream from "stream";
|
|
7
7
|
import { ResponseItem } from "../lib/types";
|
|
8
8
|
import { Command } from "commander";
|
|
9
|
-
|
|
9
|
+
import Log from "../lib/telemetry/logger";
|
|
10
10
|
interface LogPayload {
|
|
11
11
|
namespace: string;
|
|
12
12
|
name: string;
|
|
@@ -39,7 +39,7 @@ export default function (program: Command): void {
|
|
|
39
39
|
const podNames: string[] = pods.items.flatMap(pod => pod.metadata!.name || "");
|
|
40
40
|
|
|
41
41
|
if (podNames.length < 1) {
|
|
42
|
-
|
|
42
|
+
Log.error(errorMessage);
|
|
43
43
|
process.exit(1);
|
|
44
44
|
}
|
|
45
45
|
|
|
@@ -122,9 +122,9 @@ export function processMutateLog(payload: LogPayload, name: string, uid: string)
|
|
|
122
122
|
const patchType = payload.res.patchType || payload.res.warnings || "";
|
|
123
123
|
const allowOrDeny = payload.res.allowed ? "🔀" : "🚫";
|
|
124
124
|
|
|
125
|
-
|
|
125
|
+
Log.info(`\n${allowOrDeny} MUTATE ${name} (${uid})`);
|
|
126
126
|
if (patchType.length > 0) {
|
|
127
|
-
|
|
127
|
+
Log.info(`\n\u001b[1;34m${patch}\u001b[0m`);
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
130
|
|
|
@@ -135,8 +135,8 @@ export function processValidateLog(payload: LogPayload, name: string, uid: strin
|
|
|
135
135
|
.filter((r: ResponseItem) => !r.allowed)
|
|
136
136
|
.map((r: ResponseItem) => r.status?.message || "");
|
|
137
137
|
|
|
138
|
-
|
|
138
|
+
Log.info(`\n${filteredFailures.length > 0 ? "❌" : "✅"} VALIDATE ${name} (${uid})`);
|
|
139
139
|
if (filteredFailures.length > 0) {
|
|
140
|
-
|
|
140
|
+
Log.info(`\u001b[1;31m${filteredFailures}\u001b[0m`);
|
|
141
141
|
}
|
|
142
142
|
}
|
package/src/cli.ts
CHANGED
|
@@ -16,9 +16,9 @@ import { Command } from "commander";
|
|
|
16
16
|
import update from "./cli/update";
|
|
17
17
|
import kfc from "./cli/kfc";
|
|
18
18
|
import crd from "./cli/crd";
|
|
19
|
-
|
|
19
|
+
import Log from "./lib/telemetry/logger";
|
|
20
20
|
if (process.env.npm_lifecycle_event !== "npx") {
|
|
21
|
-
|
|
21
|
+
Log.info("Pepr should be run via `npx pepr <command>` instead of `pepr <command>`.");
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
const program = new Command();
|
|
@@ -33,10 +33,10 @@ program
|
|
|
33
33
|
.addCommand(init())
|
|
34
34
|
.action(() => {
|
|
35
35
|
if (program.args.length < 1) {
|
|
36
|
-
|
|
36
|
+
Log.info(banner);
|
|
37
37
|
program.help();
|
|
38
38
|
} else {
|
|
39
|
-
|
|
39
|
+
Log.error(`Invalid command '${program.args.join(" ")}'\n`);
|
|
40
40
|
program.outputHelp();
|
|
41
41
|
process.exitCode = 1;
|
|
42
42
|
}
|
|
@@ -5,6 +5,8 @@ import {
|
|
|
5
5
|
AdmissionregistrationV1WebhookClientConfig as AdmissionRegnV1WebhookClientCfg,
|
|
6
6
|
V1LabelSelectorRequirement,
|
|
7
7
|
V1RuleWithOperations,
|
|
8
|
+
V1MutatingWebhookConfiguration,
|
|
9
|
+
V1ValidatingWebhookConfiguration,
|
|
8
10
|
} from "@kubernetes/client-node";
|
|
9
11
|
import { kind } from "kubernetes-fluent-client";
|
|
10
12
|
import { concat, equals, uniqWith } from "ramda";
|
|
@@ -110,7 +112,7 @@ export async function webhookConfigGenerator(
|
|
|
110
112
|
return null;
|
|
111
113
|
}
|
|
112
114
|
|
|
113
|
-
|
|
115
|
+
const webhookConfig = {
|
|
114
116
|
apiVersion: "admissionregistration.k8s.io/v1",
|
|
115
117
|
kind: isMutate ? "MutatingWebhookConfiguration" : "ValidatingWebhookConfiguration",
|
|
116
118
|
metadata: { name },
|
|
@@ -131,4 +133,54 @@ export async function webhookConfigGenerator(
|
|
|
131
133
|
},
|
|
132
134
|
],
|
|
133
135
|
};
|
|
136
|
+
|
|
137
|
+
// If additional webhooks are specified, add them to the config
|
|
138
|
+
if (config.additionalWebhooks) {
|
|
139
|
+
return configureAdditionalWebhooks(webhookConfig, config.additionalWebhooks);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
return webhookConfig;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export function configureAdditionalWebhooks(
|
|
146
|
+
webhookConfig: V1MutatingWebhookConfiguration | V1ValidatingWebhookConfiguration,
|
|
147
|
+
additionalWebhooks: {
|
|
148
|
+
failurePolicy: "Fail" | "Ignore";
|
|
149
|
+
namespace: string;
|
|
150
|
+
}[],
|
|
151
|
+
): V1MutatingWebhookConfiguration | V1ValidatingWebhookConfiguration {
|
|
152
|
+
if (!additionalWebhooks || additionalWebhooks.length === 0) {
|
|
153
|
+
return webhookConfig;
|
|
154
|
+
}
|
|
155
|
+
// set the ignored namespace to the additional webhook namespaces
|
|
156
|
+
const webhooks = webhookConfig.webhooks ?? [];
|
|
157
|
+
if (webhooks.length === 0) {
|
|
158
|
+
return webhookConfig;
|
|
159
|
+
}
|
|
160
|
+
const expr = webhooks[0]!.namespaceSelector!.matchExpressions![0]!;
|
|
161
|
+
expr.values!.push(...additionalWebhooks.map(w => w.namespace));
|
|
162
|
+
|
|
163
|
+
additionalWebhooks.forEach(additionalWebhook => {
|
|
164
|
+
webhooks.push({
|
|
165
|
+
name: `${webhookConfig.metadata!.name}-${additionalWebhook.namespace}.pepr.dev`,
|
|
166
|
+
admissionReviewVersions: ["v1", "v1beta1"],
|
|
167
|
+
clientConfig: webhooks[0]!.clientConfig,
|
|
168
|
+
failurePolicy: additionalWebhook.failurePolicy,
|
|
169
|
+
matchPolicy: "Equivalent",
|
|
170
|
+
timeoutSeconds: webhooks[0]!.timeoutSeconds,
|
|
171
|
+
namespaceSelector: {
|
|
172
|
+
matchExpressions: [
|
|
173
|
+
{
|
|
174
|
+
key: "kubernetes.io/metadata.name",
|
|
175
|
+
operator: "In",
|
|
176
|
+
values: [additionalWebhook.namespace],
|
|
177
|
+
},
|
|
178
|
+
],
|
|
179
|
+
},
|
|
180
|
+
rules: webhooks[0].rules,
|
|
181
|
+
sideEffects: "None",
|
|
182
|
+
});
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
return webhookConfig;
|
|
134
186
|
}
|
|
@@ -4,6 +4,8 @@ import { dumpYaml } from "@kubernetes/client-node";
|
|
|
4
4
|
import { clusterRole } from "../rbac";
|
|
5
5
|
import { promises as fs } from "fs";
|
|
6
6
|
import { resolveIgnoreNamespaces } from "../ignoredNamespaces";
|
|
7
|
+
import { quicktype, InputData, jsonInputForTargetLanguage } from "quicktype-core";
|
|
8
|
+
|
|
7
9
|
export type ChartOverrides = {
|
|
8
10
|
apiPath: string;
|
|
9
11
|
capabilities: CapabilityExport[];
|
|
@@ -181,6 +183,26 @@ export async function overridesFile(
|
|
|
181
183
|
},
|
|
182
184
|
},
|
|
183
185
|
};
|
|
184
|
-
|
|
186
|
+
/** write values.schema.yaml */
|
|
187
|
+
await writeSchemaYamlFromObject(JSON.stringify(overrides, null, 2), path);
|
|
185
188
|
await fs.writeFile(path, dumpYaml(overrides, { noRefs: true, forceQuotes: true }));
|
|
186
189
|
}
|
|
190
|
+
|
|
191
|
+
export async function writeSchemaYamlFromObject(
|
|
192
|
+
valuesString: string,
|
|
193
|
+
valuesFilePath: string,
|
|
194
|
+
): Promise<void> {
|
|
195
|
+
const schemaPath = valuesFilePath.replace(/\.yaml$/, ".schema.json");
|
|
196
|
+
const jsonInput = jsonInputForTargetLanguage("schema");
|
|
197
|
+
await jsonInput.addSource({ name: "Values", samples: [valuesString] });
|
|
198
|
+
|
|
199
|
+
const inputData = new InputData();
|
|
200
|
+
inputData.addInput(jsonInput);
|
|
201
|
+
|
|
202
|
+
const { lines } = await quicktype({ inputData, lang: "schema" });
|
|
203
|
+
|
|
204
|
+
const schemaJson = lines.join("\n");
|
|
205
|
+
const schemaObj = JSON.parse(schemaJson);
|
|
206
|
+
|
|
207
|
+
await fs.writeFile(schemaPath, JSON.stringify(schemaObj, null, 2), "utf8");
|
|
208
|
+
}
|
package/src/lib/types.ts
CHANGED
|
@@ -296,6 +296,13 @@ export type ModuleConfig = {
|
|
|
296
296
|
watch?: {
|
|
297
297
|
alwaysIgnore: WebhookIgnore;
|
|
298
298
|
};
|
|
299
|
+
/** Additional webhooks config to be used by the module */
|
|
300
|
+
additionalWebhooks?: [
|
|
301
|
+
{
|
|
302
|
+
failurePolicy: "Fail" | "Ignore";
|
|
303
|
+
namespace: string;
|
|
304
|
+
},
|
|
305
|
+
];
|
|
299
306
|
} & Partial<ModuleConfigOptions>;
|
|
300
307
|
|
|
301
308
|
export type PackageJSON = {
|