pepr 0.52.3-nightly.1 → 0.52.3-nightly.11
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/build/index.d.ts.map +1 -1
- package/dist/cli/init/createProjectFiles.d.ts +3 -0
- package/dist/cli/init/createProjectFiles.d.ts.map +1 -0
- package/dist/cli/init/doPostInitActions.d.ts +2 -0
- package/dist/cli/init/doPostInitActions.d.ts.map +1 -0
- package/dist/cli/init/index.d.ts +1 -1
- package/dist/cli/init/index.d.ts.map +1 -1
- package/dist/cli/init/setupProjectStructure.d.ts +2 -0
- package/dist/cli/init/setupProjectStructure.d.ts.map +1 -0
- package/dist/cli/init/templates.d.ts +3 -9
- package/dist/cli/init/templates.d.ts.map +1 -1
- package/dist/cli/init/walkthrough.d.ts.map +1 -1
- package/dist/cli.js +101 -88
- package/dist/controller.js +1 -1
- package/dist/lib/controller/index.d.ts.map +1 -1
- package/dist/lib.js +1 -0
- package/dist/lib.js.map +2 -2
- package/package.json +8 -14
- package/src/cli/build/index.ts +0 -1
- package/src/cli/init/createProjectFiles.ts +45 -0
- package/src/cli/init/doPostInitActions.ts +23 -0
- package/src/cli/init/index.ts +18 -84
- package/src/cli/init/setupProjectStructure.ts +8 -0
- package/src/cli/init/templates.ts +2 -4
- package/src/cli/init/walkthrough.ts +3 -0
- package/src/cli.ts +1 -1
- package/src/lib/assets/k8sObjects.ts +6 -6
- package/src/lib/assets/yaml/overridesFile.ts +6 -6
- package/src/lib/controller/index.ts +1 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cli/build/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAepC,MAAM,CAAC,OAAO,WAAW,OAAO,EAAE,OAAO,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cli/build/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAepC,MAAM,CAAC,OAAO,WAAW,OAAO,EAAE,OAAO,GAAG,IAAI,CAsI/C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createProjectFiles.d.ts","sourceRoot":"","sources":["../../../src/cli/init/createProjectFiles.ts"],"names":[],"mappings":"AACA,OAAO,EACL,eAAe,EAWhB,MAAM,aAAa,CAAC;AAGrB,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,eAAe,GAC3B,OAAO,CAAC,IAAI,CAAC,CAyBf"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"doPostInitActions.d.ts","sourceRoot":"","sources":["../../../src/cli/init/doPostInitActions.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,iBAAiB,GAAI,SAAS,MAAM,KAAG,IAoBnD,CAAC"}
|
package/dist/cli/init/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cli/init/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cli/init/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAapC,MAAM,CAAC,OAAO,cAAc,OAAO,CAsDlC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setupProjectStructure.d.ts","sourceRoot":"","sources":["../../../src/cli/init/setupProjectStructure.ts"],"names":[],"mappings":"AAGA,wBAAsB,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAI1E"}
|
|
@@ -52,6 +52,9 @@ export declare const dependencies: {
|
|
|
52
52
|
"build:image": string;
|
|
53
53
|
"build:image:unicorn": string;
|
|
54
54
|
ci: string;
|
|
55
|
+
"cluster:k3d": string;
|
|
56
|
+
"cluster:k3d:import-upstream": string;
|
|
57
|
+
"cluster:k3d:import-unicorn": string;
|
|
55
58
|
"format:check": string;
|
|
56
59
|
"format:fix": string;
|
|
57
60
|
"format:integration": string;
|
|
@@ -69,15 +72,6 @@ export declare const dependencies: {
|
|
|
69
72
|
"test:integration": string;
|
|
70
73
|
"test:integration:prep": string;
|
|
71
74
|
"test:integration:run": string;
|
|
72
|
-
"test:journey": string;
|
|
73
|
-
"test:journey-wasm": string;
|
|
74
|
-
"test:journey-wasm:unicorn": string;
|
|
75
|
-
"test:journey:image": string;
|
|
76
|
-
"test:journey:image:unicorn": string;
|
|
77
|
-
"test:journey:k3d": string;
|
|
78
|
-
"test:journey:run": string;
|
|
79
|
-
"test:journey:run-wasm": string;
|
|
80
|
-
"test:journey:unicorn": string;
|
|
81
75
|
"test:unit": string;
|
|
82
76
|
"test:upgrade:unicorn": string;
|
|
83
77
|
"test:upgrade:upstream": string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../../../src/cli/init/templates.ts"],"names":[],"mappings":"
|
|
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,MAAM,CAAA;SAAE,CAAC;QAC1B,IAAI,EAAE;YACJ,IAAI,EAAE,MAAM,CAAC;YACb,OAAO,EAAE,OAAO,CAAC;YACjB,cAAc,EAAE,MAAM,CAAC;YACvB,YAAY,EAAE,YAAY,CAAC;YAC3B,YAAY,EAAE;gBAAE,UAAU,EAAE,MAAM,EAAE,CAAA;aAAE,CAAC;YACvC,SAAS,EAAE;gBAAE,YAAY,EAAE;oBAAE,UAAU,EAAE,MAAM,EAAE,CAAA;iBAAE,CAAA;aAAE,CAAC;YACtD,KAAK,EAAE;gBAAE,YAAY,EAAE;oBAAE,UAAU,EAAE,MAAM,EAAE,CAAA;iBAAE,CAAA;aAAE,CAAC;YAClD,aAAa,EAAE,MAAM,EAAE,CAAC;YACxB,GAAG,EAAE,MAAM,CAAC;YACZ,IAAI,CAAC,EAAE,UAAU,EAAE,CAAC;YACpB,QAAQ,CAAC,EAAE,QAAQ,CAAC;SACrB,CAAC;QACF,OAAO,EAAE;YAAE,WAAW,EAAE,MAAM,CAAA;SAAE,CAAC;QACjC,YAAY,EAAE;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,MAAM,EAAE,MAAM,CAAA;SAAE,CAAC;QAC/C,eAAe,EAAE;YAAE,UAAU,EAAE,MAAM,CAAA;SAAE,CAAC;KACzC,CAAC;IACF,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,wBAAgB,UAAU,CAAC,IAAI,EAAE,WAAW,GAAG,eAAe,CA4D7D;AAED,eAAO,MAAM,cAAc;;;CAG1B,CAAC;AAEF,eAAO,MAAM,MAAM;;;CAGlB,CAAC;AAEF,eAAO,MAAM,SAAS;;;CAGrB,CAAC;AAEF,eAAO,MAAM,SAAS;;;CAGrB,CAAC;AAEF,eAAO,MAAM,WAAW;;;CAGvB,CAAC;AAEF,eAAO,MAAM,OAAO;;;;;;;;;CAGnB,CAAC;AAEF,eAAO,MAAM,YAAY;;;;;;;;CAGxB,CAAC;AAEF,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;CAGpB,CAAC;AAEF,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;CAGpB,CAAC;AAEF,eAAO,MAAM,MAAM;;;CAgBlB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"walkthrough.d.ts","sourceRoot":"","sources":["../../../src/cli/init/walkthrough.ts"],"names":[],"mappings":"AAIA,OAAe,EAAE,OAAO,EAAgB,MAAM,SAAS,CAAC;AAIxD,OAAO,EAAE,OAAO,EAAqB,MAAM,SAAS,CAAC;AAGrD,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,OAAO,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;AAE1D,wBAAsB,WAAW,CAAC,IAAI,CAAC,EAAE,oBAAoB,GAAG,OAAO,CAAC,aAAa,CAAC,CAQrF;
|
|
1
|
+
{"version":3,"file":"walkthrough.d.ts","sourceRoot":"","sources":["../../../src/cli/init/walkthrough.ts"],"names":[],"mappings":"AAIA,OAAe,EAAE,OAAO,EAAgB,MAAM,SAAS,CAAC;AAIxD,OAAO,EAAE,OAAO,EAAqB,MAAM,SAAS,CAAC;AAGrD,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,OAAO,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;AAE1D,wBAAsB,WAAW,CAAC,IAAI,CAAC,EAAE,oBAAoB,GAAG,OAAO,CAAC,aAAa,CAAC,CAQrF;AAuBD,wBAAsB,OAAO,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CA6BrE;AAgBD,wBAAsB,gBAAgB,CAAC,aAAa,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAoCxF;AAED,wBAAsB,OAAO,CAC3B,OAAO,EAAE,MAAM,EACf,WAAW,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,EAC5C,UAAU,EAAE,MAAM,EAClB,UAAU,CAAC,EAAE,OAAO,GACnB,OAAO,CAAC,OAAO,CAAC,CA+BlB"}
|
package/dist/cli.js
CHANGED
|
@@ -8126,9 +8126,9 @@ async function overridesFile({ hash, name: name2, image, config, apiPath, capabi
|
|
|
8126
8126
|
},
|
|
8127
8127
|
securityContext: {
|
|
8128
8128
|
runAsUser: image.includes("private") ? 1e3 : 65532,
|
|
8129
|
-
runAsGroup: 65532,
|
|
8129
|
+
runAsGroup: image.includes("private") ? 1e3 : 65532,
|
|
8130
8130
|
runAsNonRoot: true,
|
|
8131
|
-
fsGroup: 65532
|
|
8131
|
+
fsGroup: image.includes("private") ? 1e3 : 65532
|
|
8132
8132
|
},
|
|
8133
8133
|
readinessProbe: {
|
|
8134
8134
|
httpGet: {
|
|
@@ -8158,7 +8158,7 @@ async function overridesFile({ hash, name: name2, image, config, apiPath, capabi
|
|
|
8158
8158
|
},
|
|
8159
8159
|
containerSecurityContext: {
|
|
8160
8160
|
runAsUser: image.includes("private") ? 1e3 : 65532,
|
|
8161
|
-
runAsGroup: 65532,
|
|
8161
|
+
runAsGroup: image.includes("private") ? 1e3 : 65532,
|
|
8162
8162
|
runAsNonRoot: true,
|
|
8163
8163
|
allowPrivilegeEscalation: false,
|
|
8164
8164
|
capabilities: {
|
|
@@ -8194,9 +8194,9 @@ async function overridesFile({ hash, name: name2, image, config, apiPath, capabi
|
|
|
8194
8194
|
},
|
|
8195
8195
|
securityContext: {
|
|
8196
8196
|
runAsUser: image.includes("private") ? 1e3 : 65532,
|
|
8197
|
-
runAsGroup: 65532,
|
|
8197
|
+
runAsGroup: image.includes("private") ? 1e3 : 65532,
|
|
8198
8198
|
runAsNonRoot: true,
|
|
8199
|
-
fsGroup: 65532
|
|
8199
|
+
fsGroup: image.includes("private") ? 1e3 : 65532
|
|
8200
8200
|
},
|
|
8201
8201
|
readinessProbe: {
|
|
8202
8202
|
httpGet: {
|
|
@@ -8226,7 +8226,7 @@ async function overridesFile({ hash, name: name2, image, config, apiPath, capabi
|
|
|
8226
8226
|
},
|
|
8227
8227
|
containerSecurityContext: {
|
|
8228
8228
|
runAsUser: image.includes("private") ? 1e3 : 65532,
|
|
8229
|
-
runAsGroup: 65532,
|
|
8229
|
+
runAsGroup: image.includes("private") ? 1e3 : 65532,
|
|
8230
8230
|
runAsNonRoot: true,
|
|
8231
8231
|
allowPrivilegeEscalation: false,
|
|
8232
8232
|
capabilities: {
|
|
@@ -8333,7 +8333,7 @@ function helmLayout(basePath, unique) {
|
|
|
8333
8333
|
// src/lib/assets/loader.ts
|
|
8334
8334
|
var import_child_process = require("child_process");
|
|
8335
8335
|
function loadCapabilities(path4) {
|
|
8336
|
-
return new Promise((
|
|
8336
|
+
return new Promise((resolve8, reject) => {
|
|
8337
8337
|
const program2 = (0, import_child_process.fork)(path4, {
|
|
8338
8338
|
env: {
|
|
8339
8339
|
...process.env,
|
|
@@ -8344,7 +8344,7 @@ function loadCapabilities(path4) {
|
|
|
8344
8344
|
});
|
|
8345
8345
|
program2.on("message", (message) => {
|
|
8346
8346
|
const capabilities = message.valueOf();
|
|
8347
|
-
|
|
8347
|
+
resolve8(capabilities);
|
|
8348
8348
|
});
|
|
8349
8349
|
program2.on("error", (error) => {
|
|
8350
8350
|
reject(error);
|
|
@@ -8695,9 +8695,9 @@ function getWatcher(assets, hash, buildTimestamp, imagePullSecret) {
|
|
|
8695
8695
|
serviceAccountName: name2,
|
|
8696
8696
|
securityContext: {
|
|
8697
8697
|
runAsUser: image.includes("private") ? 1e3 : 65532,
|
|
8698
|
-
runAsGroup: 65532,
|
|
8698
|
+
runAsGroup: image.includes("private") ? 1e3 : 65532,
|
|
8699
8699
|
runAsNonRoot: true,
|
|
8700
|
-
fsGroup: 65532
|
|
8700
|
+
fsGroup: image.includes("private") ? 1e3 : 65532
|
|
8701
8701
|
},
|
|
8702
8702
|
containers: [
|
|
8703
8703
|
{
|
|
@@ -8738,7 +8738,7 @@ function getWatcher(assets, hash, buildTimestamp, imagePullSecret) {
|
|
|
8738
8738
|
},
|
|
8739
8739
|
securityContext: {
|
|
8740
8740
|
runAsUser: image.includes("private") ? 1e3 : 65532,
|
|
8741
|
-
runAsGroup: 65532,
|
|
8741
|
+
runAsGroup: image.includes("private") ? 1e3 : 65532,
|
|
8742
8742
|
runAsNonRoot: true,
|
|
8743
8743
|
allowPrivilegeEscalation: false,
|
|
8744
8744
|
capabilities: {
|
|
@@ -8828,9 +8828,9 @@ function getDeployment(assets, hash, buildTimestamp, imagePullSecret) {
|
|
|
8828
8828
|
serviceAccountName: name2,
|
|
8829
8829
|
securityContext: {
|
|
8830
8830
|
runAsUser: image.includes("private") ? 1e3 : 65532,
|
|
8831
|
-
runAsGroup: 65532,
|
|
8831
|
+
runAsGroup: image.includes("private") ? 1e3 : 65532,
|
|
8832
8832
|
runAsNonRoot: true,
|
|
8833
|
-
fsGroup: 65532
|
|
8833
|
+
fsGroup: image.includes("private") ? 1e3 : 65532
|
|
8834
8834
|
},
|
|
8835
8835
|
containers: [
|
|
8836
8836
|
{
|
|
@@ -8872,7 +8872,7 @@ function getDeployment(assets, hash, buildTimestamp, imagePullSecret) {
|
|
|
8872
8872
|
env: genEnv(config),
|
|
8873
8873
|
securityContext: {
|
|
8874
8874
|
runAsUser: image.includes("private") ? 1e3 : 65532,
|
|
8875
|
-
runAsGroup: 65532,
|
|
8875
|
+
runAsGroup: image.includes("private") ? 1e3 : 65532,
|
|
8876
8876
|
runAsNonRoot: true,
|
|
8877
8877
|
allowPrivilegeEscalation: false,
|
|
8878
8878
|
capabilities: {
|
|
@@ -9279,7 +9279,6 @@ var import_path4 = require("path");
|
|
|
9279
9279
|
// src/cli/init/templates.ts
|
|
9280
9280
|
var import_client_node5 = require("@kubernetes/client-node");
|
|
9281
9281
|
var import_util = require("util");
|
|
9282
|
-
var import_uuid = require("uuid");
|
|
9283
9282
|
var import_fs8 = require("fs");
|
|
9284
9283
|
var import_path3 = __toESM(require("path"));
|
|
9285
9284
|
|
|
@@ -9522,7 +9521,7 @@ var gitIgnore = "# Ignore node_modules and Pepr build artifacts\nnode_modules\nd
|
|
|
9522
9521
|
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';
|
|
9523
9522
|
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';
|
|
9524
9523
|
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';
|
|
9525
|
-
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.52.3-nightly.
|
|
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.52.3-nightly.11", 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", 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.0", pino: "9.7.0", "pino-pretty": "13.1.1", "prom-client": "15.1.3", 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/eslint": "9.6.1", "@types/express": "5.0.3", "@types/json-pointer": "^1.0.34", "@types/node": "24.x.x", "@types/node-forge": "1.3.13", "@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" } };
|
|
9526
9525
|
|
|
9527
9526
|
// src/cli/init/utils.ts
|
|
9528
9527
|
var import_fs7 = require("fs");
|
|
@@ -9558,7 +9557,7 @@ function write(path4, data) {
|
|
|
9558
9557
|
// src/cli/init/templates.ts
|
|
9559
9558
|
var { dependencies, devDependencies, peerDependencies, scripts, version } = packageJSON;
|
|
9560
9559
|
function genPkgJSON(opts) {
|
|
9561
|
-
const uuid =
|
|
9560
|
+
const uuid = opts.uuid;
|
|
9562
9561
|
const name2 = sanitizeName(opts.name);
|
|
9563
9562
|
const { typescript } = peerDependencies;
|
|
9564
9563
|
const data = {
|
|
@@ -9595,7 +9594,7 @@ function genPkgJSON(opts) {
|
|
|
9595
9594
|
env: {}
|
|
9596
9595
|
},
|
|
9597
9596
|
scripts: {
|
|
9598
|
-
"k3d-setup": scripts["
|
|
9597
|
+
"k3d-setup": scripts["cluster:k3d"]
|
|
9599
9598
|
},
|
|
9600
9599
|
dependencies: {
|
|
9601
9600
|
pepr: version,
|
|
@@ -10222,7 +10221,7 @@ async function namespaceDeploymentsReady(namespace = "pepr-system") {
|
|
|
10222
10221
|
if (ready) {
|
|
10223
10222
|
return ready;
|
|
10224
10223
|
}
|
|
10225
|
-
await new Promise((
|
|
10224
|
+
await new Promise((resolve8) => setTimeout(resolve8, 1e3));
|
|
10226
10225
|
}
|
|
10227
10226
|
logger_default.info(`All ${namespace} deployments are ready`);
|
|
10228
10227
|
}
|
|
@@ -10462,8 +10461,7 @@ ${filteredFailures.length > 0 ? "\u274C" : "\u2705"} VALIDATE ${name2} (${uid
|
|
|
10462
10461
|
}
|
|
10463
10462
|
|
|
10464
10463
|
// src/cli/init/index.ts
|
|
10465
|
-
var
|
|
10466
|
-
var import_path5 = require("path");
|
|
10464
|
+
var import_commander2 = require("commander");
|
|
10467
10465
|
|
|
10468
10466
|
// src/cli/init/walkthrough.ts
|
|
10469
10467
|
var import_fs12 = require("fs");
|
|
@@ -10497,6 +10495,9 @@ async function setUUID(uuid) {
|
|
|
10497
10495
|
name: "uuid",
|
|
10498
10496
|
message: "Enter a unique identifier for the new Pepr module.\n",
|
|
10499
10497
|
validate: (val) => {
|
|
10498
|
+
if (typeof val === "undefined" || val === "") {
|
|
10499
|
+
return "The UUID must be at least 1 character long";
|
|
10500
|
+
}
|
|
10500
10501
|
return val.length <= UUID_LENGTH_LIMIT || `The UUID must be ${UUID_LENGTH_LIMIT} characters or fewer.`;
|
|
10501
10502
|
}
|
|
10502
10503
|
};
|
|
@@ -10606,15 +10607,75 @@ ${packageJSON2.print.replace(/^/gm, " \u2502 ")}
|
|
|
10606
10607
|
}
|
|
10607
10608
|
|
|
10608
10609
|
// src/cli/init/index.ts
|
|
10609
|
-
var
|
|
10610
|
-
|
|
10610
|
+
var import_commander3 = require("commander");
|
|
10611
|
+
|
|
10612
|
+
// src/cli/init/setupProjectStructure.ts
|
|
10613
|
+
var import_path5 = require("path");
|
|
10614
|
+
async function setupProjectStructure(dirName) {
|
|
10615
|
+
await createDir(dirName);
|
|
10616
|
+
await createDir((0, import_path5.resolve)(dirName, ".vscode"));
|
|
10617
|
+
await createDir((0, import_path5.resolve)(dirName, "capabilities"));
|
|
10618
|
+
}
|
|
10619
|
+
|
|
10620
|
+
// src/cli/init/doPostInitActions.ts
|
|
10621
|
+
var import_child_process5 = require("child_process");
|
|
10622
|
+
var doPostInitActions = (dirName) => {
|
|
10623
|
+
process.chdir(dirName);
|
|
10624
|
+
(0, import_child_process5.execSync)("npm install", {
|
|
10625
|
+
stdio: "inherit"
|
|
10626
|
+
});
|
|
10627
|
+
(0, import_child_process5.execSync)("git init --initial-branch=main", {
|
|
10628
|
+
stdio: "inherit"
|
|
10629
|
+
});
|
|
10630
|
+
try {
|
|
10631
|
+
(0, import_child_process5.execSync)("code .", {
|
|
10632
|
+
stdio: "inherit"
|
|
10633
|
+
});
|
|
10634
|
+
} catch {
|
|
10635
|
+
console.warn("VSCode was not found, IDE will not automatically open.");
|
|
10636
|
+
}
|
|
10637
|
+
};
|
|
10638
|
+
|
|
10639
|
+
// src/cli/init/createProjectFiles.ts
|
|
10640
|
+
var import_posix2 = require("path/posix");
|
|
10641
|
+
async function createProjectFiles(dirName, packageJSON2) {
|
|
10642
|
+
const files = [
|
|
10643
|
+
{ path: gitignore.path, data: gitignore.data },
|
|
10644
|
+
{ path: eslint.path, data: eslint.data },
|
|
10645
|
+
{ path: prettier.path, data: prettier.data },
|
|
10646
|
+
{ path: packageJSON2.path, data: packageJSON2.data },
|
|
10647
|
+
{ path: readme.path, data: readme.data },
|
|
10648
|
+
{ path: tsConfig.path, data: tsConfig.data },
|
|
10649
|
+
{ path: peprTSTemplate.path, data: peprTSTemplate.data }
|
|
10650
|
+
];
|
|
10651
|
+
const nestedFiles = [
|
|
10652
|
+
{ dir: ".vscode", path: snippet.path, data: snippet.data },
|
|
10653
|
+
{ dir: ".vscode", path: codeSettings.path, data: codeSettings.data },
|
|
10654
|
+
{ dir: "capabilities", path: samplesYaml.path, data: samplesYaml.data },
|
|
10655
|
+
{ dir: "capabilities", path: helloPepr.path, data: helloPepr.data }
|
|
10656
|
+
];
|
|
10657
|
+
for (const file of files) {
|
|
10658
|
+
await write((0, import_posix2.resolve)(dirName, file.path), file.data);
|
|
10659
|
+
}
|
|
10660
|
+
for (const file of nestedFiles) {
|
|
10661
|
+
await write((0, import_posix2.resolve)(dirName, file.dir, file.path), file.data);
|
|
10662
|
+
}
|
|
10663
|
+
}
|
|
10664
|
+
|
|
10665
|
+
// src/cli/init/index.ts
|
|
10666
|
+
var import_uuid = require("uuid");
|
|
10667
|
+
function init_default() {
|
|
10611
10668
|
let response = {};
|
|
10612
|
-
|
|
10613
|
-
new
|
|
10669
|
+
return new import_commander2.Command("init").description("Initialize a new Pepr Module").option("-d, --description <string>", "Explain the purpose of the new module.").addOption(
|
|
10670
|
+
new import_commander3.Option("-e, --error-behavior <behavior>", "Set an error behavior.").choices(ErrorList)
|
|
10614
10671
|
).option("-n, --name <string>", "Set the name of the new module.").option("-s, --skip-post-init", "Skip npm install, git init, and VSCode launch.").option(
|
|
10615
10672
|
"-u, --uuid <string>",
|
|
10616
10673
|
"Unique identifier for your module with a max length of 36 characters.",
|
|
10617
10674
|
(uuid) => {
|
|
10675
|
+
if (typeof uuid === "undefined" || uuid === "") {
|
|
10676
|
+
uuid = (0, import_uuid.v4)();
|
|
10677
|
+
logger_default.warn(`The UUID was empty. Generated new UUID: '${uuid}'`);
|
|
10678
|
+
}
|
|
10618
10679
|
if (uuid.length > UUID_LENGTH_LIMIT) {
|
|
10619
10680
|
throw new Error("The UUID must be 36 characters or fewer.");
|
|
10620
10681
|
}
|
|
@@ -10628,68 +10689,21 @@ function init_default(program2) {
|
|
|
10628
10689
|
const packageJSON2 = genPkgJSON(response);
|
|
10629
10690
|
const confirmed = await confirm(dirName, packageJSON2, peprTSTemplate.path, opts.yes);
|
|
10630
10691
|
if (confirmed) {
|
|
10631
|
-
|
|
10692
|
+
logger_default.info("Creating new Pepr module...");
|
|
10632
10693
|
try {
|
|
10633
10694
|
await setupProjectStructure(dirName);
|
|
10634
10695
|
await createProjectFiles(dirName, packageJSON2);
|
|
10635
10696
|
if (!opts.skipPostInit) {
|
|
10636
10697
|
doPostInitActions(dirName);
|
|
10637
10698
|
}
|
|
10638
|
-
|
|
10639
|
-
|
|
10640
|
-
} catch (
|
|
10641
|
-
|
|
10642
|
-
console.error(`Error creating Pepr module:`, e);
|
|
10643
|
-
}
|
|
10644
|
-
process.exit(1);
|
|
10699
|
+
logger_default.info(`New Pepr module created at ${dirName}`);
|
|
10700
|
+
logger_default.info(`Open VSCode or your editor of choice in ${dirName} to get started!`);
|
|
10701
|
+
} catch (error) {
|
|
10702
|
+
throw new Error(`Error creating Pepr module:`, { cause: error });
|
|
10645
10703
|
}
|
|
10646
10704
|
}
|
|
10647
10705
|
});
|
|
10648
10706
|
}
|
|
10649
|
-
async function setupProjectStructure(dirName) {
|
|
10650
|
-
await createDir(dirName);
|
|
10651
|
-
await createDir((0, import_path5.resolve)(dirName, ".vscode"));
|
|
10652
|
-
await createDir((0, import_path5.resolve)(dirName, "capabilities"));
|
|
10653
|
-
}
|
|
10654
|
-
async function createProjectFiles(dirName, packageJSON2) {
|
|
10655
|
-
const files = [
|
|
10656
|
-
{ path: gitignore.path, data: gitignore.data },
|
|
10657
|
-
{ path: eslint.path, data: eslint.data },
|
|
10658
|
-
{ path: prettier.path, data: prettier.data },
|
|
10659
|
-
{ path: packageJSON2.path, data: packageJSON2.data },
|
|
10660
|
-
{ path: readme.path, data: readme.data },
|
|
10661
|
-
{ path: tsConfig.path, data: tsConfig.data },
|
|
10662
|
-
{ path: peprTSTemplate.path, data: peprTSTemplate.data }
|
|
10663
|
-
];
|
|
10664
|
-
const nestedFiles = [
|
|
10665
|
-
{ dir: ".vscode", path: snippet.path, data: snippet.data },
|
|
10666
|
-
{ dir: ".vscode", path: codeSettings.path, data: codeSettings.data },
|
|
10667
|
-
{ dir: "capabilities", path: samplesYaml.path, data: samplesYaml.data },
|
|
10668
|
-
{ dir: "capabilities", path: helloPepr.path, data: helloPepr.data }
|
|
10669
|
-
];
|
|
10670
|
-
for (const file of files) {
|
|
10671
|
-
await write((0, import_path5.resolve)(dirName, file.path), file.data);
|
|
10672
|
-
}
|
|
10673
|
-
for (const file of nestedFiles) {
|
|
10674
|
-
await write((0, import_path5.resolve)(dirName, file.dir, file.path), file.data);
|
|
10675
|
-
}
|
|
10676
|
-
}
|
|
10677
|
-
var doPostInitActions = (dirName) => {
|
|
10678
|
-
process.chdir(dirName);
|
|
10679
|
-
(0, import_child_process5.execSync)("npm install", {
|
|
10680
|
-
stdio: "inherit"
|
|
10681
|
-
});
|
|
10682
|
-
(0, import_child_process5.execSync)("git init --initial-branch=main", {
|
|
10683
|
-
stdio: "inherit"
|
|
10684
|
-
});
|
|
10685
|
-
try {
|
|
10686
|
-
(0, import_child_process5.execSync)("code .", {
|
|
10687
|
-
stdio: "inherit"
|
|
10688
|
-
});
|
|
10689
|
-
} catch {
|
|
10690
|
-
console.warn("VSCode was not found, IDE will not automatically open.");
|
|
10691
|
-
}
|
|
10692
|
-
};
|
|
10693
10707
|
|
|
10694
10708
|
// src/cli/uuid.ts
|
|
10695
10709
|
var import_kubernetes_fluent_client7 = require("kubernetes-fluent-client");
|
|
@@ -10730,7 +10744,7 @@ function buildUUIDTable(deployments) {
|
|
|
10730
10744
|
}
|
|
10731
10745
|
|
|
10732
10746
|
// src/cli.ts
|
|
10733
|
-
var
|
|
10747
|
+
var import_commander7 = require("commander");
|
|
10734
10748
|
|
|
10735
10749
|
// src/cli/update/index.ts
|
|
10736
10750
|
var import_child_process6 = require("child_process");
|
|
@@ -10821,10 +10835,10 @@ function kfc_default(program2) {
|
|
|
10821
10835
|
}
|
|
10822
10836
|
|
|
10823
10837
|
// src/cli/crd/index.ts
|
|
10824
|
-
var
|
|
10838
|
+
var import_commander6 = require("commander");
|
|
10825
10839
|
|
|
10826
10840
|
// src/cli/crd/generate/index.ts
|
|
10827
|
-
var
|
|
10841
|
+
var import_commander4 = require("commander");
|
|
10828
10842
|
|
|
10829
10843
|
// src/cli/crd/generate/generators.ts
|
|
10830
10844
|
var import_fs14 = __toESM(require("fs"));
|
|
@@ -11060,13 +11074,13 @@ function buildCRD(config) {
|
|
|
11060
11074
|
|
|
11061
11075
|
// src/cli/crd/generate/index.ts
|
|
11062
11076
|
function generate_default() {
|
|
11063
|
-
return new
|
|
11077
|
+
return new import_commander4.Command("generate").description(
|
|
11064
11078
|
"Generate CRD manifests from TypeScript definitions stored in 'api/' of the current directory."
|
|
11065
11079
|
).option("-o, --output <directory>", "Output directory for generated CRDs", "./crds").action((options) => generateCRDs(options));
|
|
11066
11080
|
}
|
|
11067
11081
|
|
|
11068
11082
|
// src/cli/crd/create/index.ts
|
|
11069
|
-
var
|
|
11083
|
+
var import_commander5 = require("commander");
|
|
11070
11084
|
var import_fs15 = require("fs");
|
|
11071
11085
|
|
|
11072
11086
|
// src/cli/crd/create/createCRDscaffold.ts
|
|
@@ -11153,8 +11167,8 @@ type ${kind8}StatusCondition = {
|
|
|
11153
11167
|
// src/cli/crd/create/index.ts
|
|
11154
11168
|
var import_path8 = __toESM(require("path"));
|
|
11155
11169
|
function create_default() {
|
|
11156
|
-
return new
|
|
11157
|
-
new
|
|
11170
|
+
return new import_commander5.Command("create").description("Create a new CRD TypeScript definition").addOption(
|
|
11171
|
+
new import_commander5.Option(
|
|
11158
11172
|
"-S, --scope <scope>",
|
|
11159
11173
|
"Whether the resulting custom resource is cluster- or namespace-scoped"
|
|
11160
11174
|
).choices(["Namespaced", "Cluster"]).default("Namespaced")
|
|
@@ -11172,18 +11186,18 @@ function create_default() {
|
|
|
11172
11186
|
|
|
11173
11187
|
// src/cli/crd/index.ts
|
|
11174
11188
|
function crd_default() {
|
|
11175
|
-
return new
|
|
11189
|
+
return new import_commander6.Command("crd").description("Scaffold and generate Kubernetes CRDs from structured TypeScript definitions").addCommand(create_default()).addCommand(generate_default());
|
|
11176
11190
|
}
|
|
11177
11191
|
|
|
11178
11192
|
// src/cli.ts
|
|
11179
11193
|
if (process.env.npm_lifecycle_event !== "npx") {
|
|
11180
11194
|
console.info("Pepr should be run via `npx pepr <command>` instead of `pepr <command>`.");
|
|
11181
11195
|
}
|
|
11182
|
-
var program = new
|
|
11196
|
+
var program = new import_commander7.Command();
|
|
11183
11197
|
if (!process.env.PEPR_NODE_WARNINGS) {
|
|
11184
11198
|
process.removeAllListeners("warning");
|
|
11185
11199
|
}
|
|
11186
|
-
program.enablePositionalOptions().version(version).description(`Pepr (v${version}) - Type safe K8s middleware for humans`).addCommand(crd_default()).action(() => {
|
|
11200
|
+
program.enablePositionalOptions().version(version).description(`Pepr (v${version}) - Type safe K8s middleware for humans`).addCommand(crd_default()).addCommand(init_default()).action(() => {
|
|
11187
11201
|
if (program.args.length < 1) {
|
|
11188
11202
|
console.log(banner);
|
|
11189
11203
|
program.help();
|
|
@@ -11194,7 +11208,6 @@ program.enablePositionalOptions().version(version).description(`Pepr (v${version
|
|
|
11194
11208
|
process.exitCode = 1;
|
|
11195
11209
|
}
|
|
11196
11210
|
});
|
|
11197
|
-
init_default(program);
|
|
11198
11211
|
build_default(program);
|
|
11199
11212
|
deploy_default(program);
|
|
11200
11213
|
dev_default(program);
|
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.52.3-nightly.
|
|
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.52.3-nightly.11", 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", 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.0", pino: "9.7.0", "pino-pretty": "13.1.1", "prom-client": "15.1.3", 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/eslint": "9.6.1", "@types/express": "5.0.3", "@types/json-pointer": "^1.0.34", "@types/node": "24.x.x", "@types/node-forge": "1.3.13", "@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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/controller/index.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AAI1D,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAKxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEnD,MAAM,WAAW,eAAe;IAC9B,UAAU,CAAC,EAAE,CAAC,GAAG,EAAE,gBAAgB,KAAK,IAAI,CAAC;IAC7C,SAAS,CAAC,EAAE,CAAC,GAAG,EAAE,cAAc,GAAG,gBAAgB,KAAK,IAAI,CAAC;IAC7D,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB;AAMD,qBAAa,UAAU;;gBAmBT,MAAM,EAAE,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,EAAE,KAAK,GAAE,eAAoB;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/controller/index.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AAI1D,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAKxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEnD,MAAM,WAAW,eAAe;IAC9B,UAAU,CAAC,EAAE,CAAC,GAAG,EAAE,gBAAgB,KAAK,IAAI,CAAC;IAC7C,SAAS,CAAC,EAAE,CAAC,GAAG,EAAE,cAAc,GAAG,gBAAgB,KAAK,IAAI,CAAC;IAC7D,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB;AAMD,qBAAa,UAAU;;gBAmBT,MAAM,EAAE,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,EAAE,KAAK,GAAE,eAAoB;IAoCzF,+BAA+B;IAC/B,WAAW,GAAI,MAAM,MAAM,KAAG,IAAI,CAwDhC;CA8KH"}
|
package/dist/lib.js
CHANGED
|
@@ -1981,6 +1981,7 @@ var Controller = class _Controller {
|
|
|
1981
1981
|
const { beforeHook, afterHook, onReady } = hooks;
|
|
1982
1982
|
this.#config = config;
|
|
1983
1983
|
this.#capabilities = capabilities;
|
|
1984
|
+
logger_default.info({ config }, "Controller configuration");
|
|
1984
1985
|
new StoreController(capabilities, `pepr-${config.uuid}-store`, () => {
|
|
1985
1986
|
this.#bindEndpoints();
|
|
1986
1987
|
if (typeof onReady === "function") {
|