pepr 0.51.6-nightly.13 → 0.51.6-nightly.14
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.d.ts.map +1 -1
- package/dist/cli/build.helpers.d.ts +1 -1
- package/dist/cli/build.helpers.d.ts.map +1 -1
- package/dist/cli/crd/generate.d.ts.map +1 -1
- package/dist/cli/format/index.d.ts.map +1 -1
- package/dist/cli/kfc.d.ts.map +1 -1
- package/dist/cli/update/index.d.ts.map +1 -1
- package/dist/cli.js +48 -44
- package/dist/controller.js +1 -1
- package/package.json +1 -1
- package/src/cli/build.helpers.ts +9 -12
- package/src/cli/build.ts +11 -9
- package/src/cli/crd/create.ts +2 -2
- package/src/cli/crd/generate.ts +8 -5
- package/src/cli/deploy.ts +1 -1
- package/src/cli/format/index.ts +2 -1
- package/src/cli/kfc.ts +15 -11
- package/src/cli/update/index.ts +8 -7
package/dist/cli/build.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../src/cli/build.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,WAAW,EAAmB,MAAM,SAAS,CAAC;AAKnF,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIpC,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAc5C,MAAM,MAAM,QAAQ,GAAG,CAAC,IAAI,EAAE,WAAW,CAAC,YAAY,CAAC,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AACjF,MAAM,MAAM,gBAAgB,GAAG,IAAI,CACjC,YAAY,EACV,MAAM,GACN,SAAS,GACT,gBAAgB,GAChB,cAAc,GACd,cAAc,GACd,KAAK,GACL,MAAM,GACN,UAAU,CACb,GAAG;IACF,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,IAAI,CAAC,YAAY,EAAE,MAAM,gBAAgB,CAAC,GAAG;IACpE,IAAI,EAAE,gBAAgB,GAAG;QACvB,aAAa,EAAE,MAAM,EAAE,CAAC;KACzB,CAAC;IACF,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,KAAK,gBAAgB,GAAG;IACtB,GAAG,EAAE,UAAU,CAAC;IAChB,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,KAAK,iBAAiB,GAAG;IACvB,GAAG,EAAE,YAAY,CAAC,YAAY,CAAC,CAAC;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,UAAU,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,CAAC,OAAO,WAAW,OAAO,EAAE,OAAO,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../src/cli/build.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,WAAW,EAAmB,MAAM,SAAS,CAAC;AAKnF,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIpC,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAc5C,MAAM,MAAM,QAAQ,GAAG,CAAC,IAAI,EAAE,WAAW,CAAC,YAAY,CAAC,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AACjF,MAAM,MAAM,gBAAgB,GAAG,IAAI,CACjC,YAAY,EACV,MAAM,GACN,SAAS,GACT,gBAAgB,GAChB,cAAc,GACd,cAAc,GACd,KAAK,GACL,MAAM,GACN,UAAU,CACb,GAAG;IACF,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,IAAI,CAAC,YAAY,EAAE,MAAM,gBAAgB,CAAC,GAAG;IACpE,IAAI,EAAE,gBAAgB,GAAG;QACvB,aAAa,EAAE,MAAM,EAAE,CAAC;KACzB,CAAC;IACF,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,KAAK,gBAAgB,GAAG;IACtB,GAAG,EAAE,UAAU,CAAC;IAChB,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,KAAK,iBAAiB,GAAG;IACvB,GAAG,EAAE,YAAY,CAAC,YAAY,CAAC,CAAC;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,UAAU,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,CAAC,OAAO,WAAW,OAAO,EAAE,OAAO,GAAG,IAAI,CA8H/C;AAWD,wBAAsB,UAAU,CAAC,UAAU,SAAS,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAuC/E;AAED,wBAAsB,WAAW,CAC/B,QAAQ,CAAC,EAAE,QAAQ,EACnB,UAAU,SAAS,EACnB,KAAK,UAAO,GACX,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC,CAwEnC;AA6CD,wBAAsB,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC,CASjD"}
|
|
@@ -37,7 +37,7 @@ export declare function determineRbacMode(opts: {
|
|
|
37
37
|
* @param outputDir the desired output directory
|
|
38
38
|
* @returns The desired output directory or the default one
|
|
39
39
|
*/
|
|
40
|
-
export declare function
|
|
40
|
+
export declare function createOutputDirectory(outputDir: string): Promise<string>;
|
|
41
41
|
/**
|
|
42
42
|
* Check if the image is from Iron Bank and return the correct image
|
|
43
43
|
* @param registry The registry of the image
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.helpers.d.ts","sourceRoot":"","sources":["../../src/cli/build.helpers.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhD,OAAO,EAAE,YAAY,EAAE,WAAW,EAAW,YAAY,EAAE,MAAM,SAAS,CAAC;AAC3E,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAc9C,UAAU,YAAY;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AACD;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,YAAY,EAAE,YAAY,GAAG,MAAM,CAe9D;AAED,MAAM,MAAM,QAAQ,GAAG,CAAC,IAAI,EAAE,WAAW,CAAC,YAAY,CAAC,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AACjF;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,EAC3B,GAAG,EAAE;IAAE,IAAI,EAAE;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,GACnC,MAAM,CAaR;AAED;;;;GAIG;AAEH,wBAAsB,qBAAqB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"build.helpers.d.ts","sourceRoot":"","sources":["../../src/cli/build.helpers.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhD,OAAO,EAAE,YAAY,EAAE,WAAW,EAAW,YAAY,EAAE,MAAM,SAAS,CAAC;AAC3E,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAc9C,UAAU,YAAY;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AACD;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,YAAY,EAAE,YAAY,GAAG,MAAM,CAe9D;AAED,MAAM,MAAM,QAAQ,GAAG,CAAC,IAAI,EAAE,WAAW,CAAC,YAAY,CAAC,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AACjF;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,EAC3B,GAAG,EAAE;IAAE,IAAI,EAAE;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,GACnC,MAAM,CAaR;AAED;;;;GAIG;AAEH,wBAAsB,qBAAqB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAS9E;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,CAI/F;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,mBAAmB,EAAE,MAAM,GAAG,IAAI,CAStE;AAED;;;;;;GAMG;AACH,wBAAsB,sBAAsB,CAC1C,aAAa,EAAE,MAAM,EAAE,EACvB,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,IAAI,CAAC,CAQf;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,CAAC,YAAY,EAAE,gBAAgB,EAAE,GAAG,IAAI,CAQjF;AAED;;;;;GAKG;AACH,wBAAsB,eAAe,CACnC,MAAM,EAAE,YAAY,EACpB,QAAQ,EAAE,QAAQ,GAAG,SAAS,GAC7B,OAAO,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC,CAarC;AAED,wBAAsB,0BAA0B,CAAC,GAAG,EAAE;IACpD,IAAI,EAAE,MAAM,CAAC;IACb,eAAe,EAAE,MAAM,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd,GAAG,OAAO,CAAC,IAAI,CAAC,CAiChB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../../src/cli/crd/generate.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../../src/cli/crd/generate.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAKpC,OAAO,EACL,OAAO,EACP,oBAAoB,EACpB,oBAAoB,EAEpB,IAAI,EACJ,UAAU,EACV,IAAI,EACL,MAAM,UAAU,CAAC;AAElB,OAAO,EAAE,IAAI,IAAI,CAAC,EAAE,MAAM,0BAA0B,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;;AAG5D,wBAKwB;AAExB,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,UAAU,GACrB;IACD,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,SAAS,GAAG,YAAY,CAAC;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;CACvB,CAYA;AAED,wBAAsB,YAAY,CAAC,OAAO,EAAE;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAe7E;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAExD;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,GAAG,UAAU,EAAE,CAInF;AAED,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,UAAU,EACtB,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,GAChB,IAAI,CAiCN;AAGD,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAI3F;AAED,wBAAgB,cAAc,CAAC,UAAU,EAAE,UAAU,GAAG;IACtD,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,SAAS,GAAG,YAAY,CAAC;IAChC,SAAS,EAAE,MAAM,CAAC;CACnB,CA2BA;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAQtD;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,oBAAoB,GAAG,oBAAoB,GAAG;IACpF,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;IAC9C,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB,CAuBA;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,IAAI,GAAG,iBAAiB,CAc7D;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,IAAI,GAAG,iBAAiB,CA0B/D;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED,wBAAgB,WAAW,IAAI;IAC7B,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;IAC9C,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB,CAEA;AAED,UAAU,SAAS;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,SAAS,GAAG,YAAY,CAAC;IAChC,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,UAAU,EAAE,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAC;IACjD,eAAe,EAAE,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAC;CACvD;AAED,wBAAgB,QAAQ,CAAC,MAAM,EAAE,SAAS,GAAG,CAAC,CAAC,wBAAwB,CA0DtE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cli/format/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cli/format/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,MAAM,CAAC,OAAO,WAAW,OAAO,EAAE,OAAO,GAAG,IAAI,CAc/C;AAED;;;;GAIG;AACH,wBAAsB,UAAU,CAAC,YAAY,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAoCxE"}
|
package/dist/cli/kfc.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kfc.d.ts","sourceRoot":"","sources":["../../src/cli/kfc.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,MAAM,CAAC,OAAO,WAAW,OAAO,EAAE,OAAO,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"kfc.d.ts","sourceRoot":"","sources":["../../src/cli/kfc.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,MAAM,CAAC,OAAO,WAAW,OAAO,EAAE,OAAO,GAAG,IAAI,CAwC/C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cli/update/index.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cli/update/index.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,MAAM,CAAC,OAAO,WAAW,OAAO,EAAE,OAAO,GAAG,IAAI,CA2E/C"}
|
package/dist/cli.js
CHANGED
|
@@ -8867,7 +8867,7 @@ var gitIgnore = "# Ignore node_modules and Pepr build artifacts\nnode_modules\nd
|
|
|
8867
8867
|
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';
|
|
8868
8868
|
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';
|
|
8869
8869
|
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';
|
|
8870
|
-
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.51.6-nightly.
|
|
8870
|
+
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.51.6-nightly.14", 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", "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:journey && npm run test:journey-wasm", "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:journey": "npm run test:journey:k3d && npm run build && npm run test:journey:image && npm run test:journey:run", "test:journey-wasm": "npm run test:journey:k3d && npm run build && npm run test:journey:image && npm run test:journey:run-wasm", "test:journey-wasm:unicorn": "npm run test:journey:k3d && npm run build && npm run test:journey:image:unicorn && npm run test:journey:run-wasm", "test:journey:image": "npm run build && docker buildx build --output type=docker --tag pepr:dev . && k3d image import pepr:dev -c pepr-dev", "test:journey:image: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", "test:journey:k3d": "k3d cluster delete pepr-dev && k3d cluster create pepr-dev --k3s-arg '--debug@server:0' --wait && kubectl rollout status deployment -n kube-system", "test:journey:run": "vitest run --config=config/vitest.journey.config.ts journey/entrypoint.test.ts", "test:journey:run-wasm": "vitest run --config=config/vitest.journey.config.ts journey/entrypoint-wasm.test.ts", "test:journey:unicorn": "npm run test:journey:k3d && npm run test:journey:image:unicorn && npm run test:journey:run", "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 test:journey:k3d && npm run test:journey:image:unicorn && vitest run integration/cluster/upgrade.test.ts", "test:upgrade:upstream": "npm run test:journey:k3d && npm run test:journey:image && vitest run integration/cluster/upgrade.test.ts" }, dependencies: { "@types/ramda": "0.30.2", 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.8.1", pino: "9.7.0", "pino-pretty": "13.0.0", "prom-client": "15.1.3", ramda: "0.31.3", sigstore: "3.1.0", "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: "^3.0.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.33.0", "@typescript-eslint/parser": "8.33.0", esbuild: "0.25.5", eslint: "^9.26.0", "node-forge": "1.3.1", prettier: "3.5.3", prompts: "2.4.2", typescript: "5.8.3", uuid: "11.1.0" } };
|
|
8871
8871
|
|
|
8872
8872
|
// src/cli/init/utils.ts
|
|
8873
8873
|
var import_fs4 = require("fs");
|
|
@@ -9066,7 +9066,7 @@ async function peprFormat(validateOnly) {
|
|
|
9066
9066
|
const formatter = await eslint2.loadFormatter("stylish");
|
|
9067
9067
|
const resultText = await formatter.format(results, {});
|
|
9068
9068
|
if (resultText) {
|
|
9069
|
-
|
|
9069
|
+
logger_default.info(resultText);
|
|
9070
9070
|
}
|
|
9071
9071
|
if (!validateOnly) {
|
|
9072
9072
|
await import_eslint.ESLint.outputFixes(results);
|
|
@@ -9676,18 +9676,15 @@ function determineRbacMode(opts, cfg) {
|
|
|
9676
9676
|
}
|
|
9677
9677
|
return cfg.pepr.rbacMode || "admin";
|
|
9678
9678
|
}
|
|
9679
|
-
async function
|
|
9680
|
-
|
|
9681
|
-
|
|
9682
|
-
|
|
9683
|
-
|
|
9684
|
-
|
|
9685
|
-
|
|
9686
|
-
|
|
9687
|
-
process.exit(1);
|
|
9688
|
-
}
|
|
9679
|
+
async function createOutputDirectory(outputDir2) {
|
|
9680
|
+
try {
|
|
9681
|
+
const dir = outputDir2 === "" ? "dist" : outputDir2;
|
|
9682
|
+
await createDirectoryIfNotExists(dir);
|
|
9683
|
+
return dir;
|
|
9684
|
+
} catch (error) {
|
|
9685
|
+
console.error(`Error creating output directory: ${error.message}`);
|
|
9686
|
+
process.exit(1);
|
|
9689
9687
|
}
|
|
9690
|
-
return defaultOutputDir;
|
|
9691
9688
|
}
|
|
9692
9689
|
function checkIronBankImage(registry, image, peprVersion) {
|
|
9693
9690
|
return registry === "Iron Bank" ? `registry1.dso.mil/ironbank/opensource/defenseunicorns/pepr/controller:v${peprVersion}` : image;
|
|
@@ -9754,7 +9751,7 @@ async function generateYamlAndWriteToDisk(obj) {
|
|
|
9754
9751
|
await import_fs9.promises.writeFile(yamlPath, yaml);
|
|
9755
9752
|
await import_fs9.promises.writeFile(zarfPath, localZarf);
|
|
9756
9753
|
await assets.generateHelmChart(webhookConfigGenerator, getWatcher, getModuleSecret, outputDir2);
|
|
9757
|
-
console.info(
|
|
9754
|
+
console.info(`K8s resource for the module saved to ${yamlPath}`);
|
|
9758
9755
|
} catch (error) {
|
|
9759
9756
|
console.error(`Error generating YAML: ${error}`);
|
|
9760
9757
|
process.exit(1);
|
|
@@ -9766,7 +9763,10 @@ var peprTS2 = "pepr.ts";
|
|
|
9766
9763
|
var outputDir = "dist";
|
|
9767
9764
|
function build_default(program2) {
|
|
9768
9765
|
program2.command("build").description("Build a Pepr Module for deployment").addOption(
|
|
9769
|
-
new import_commander.Option("-M, --rbac-mode <
|
|
9766
|
+
new import_commander.Option("-M, --rbac-mode <mode>", "Override module config and set RBAC mode.").choices([
|
|
9767
|
+
"admin",
|
|
9768
|
+
"scoped"
|
|
9769
|
+
])
|
|
9770
9770
|
).addOption(
|
|
9771
9771
|
new import_commander.Option(
|
|
9772
9772
|
"-I, --registry-info <registry/username>",
|
|
@@ -9785,7 +9785,7 @@ function build_default(program2) {
|
|
|
9785
9785
|
).option(
|
|
9786
9786
|
"-n, --no-embed",
|
|
9787
9787
|
"Disable embedding of deployment files into output module. Useful when creating library modules intended solely for reuse/distribution via NPM."
|
|
9788
|
-
).option("-o, --output <directory>", "Set output directory.").addOption(
|
|
9788
|
+
).option("-o, --output <directory>", "Set output directory.", "dist").addOption(
|
|
9789
9789
|
new import_commander.Option(
|
|
9790
9790
|
"-r, --registry <GitHub|Iron Bank>",
|
|
9791
9791
|
"Container registry: Choose container registry for deployment manifests. Conflicts with --custom-image and --registry-info."
|
|
@@ -9797,7 +9797,7 @@ function build_default(program2) {
|
|
|
9797
9797
|
).addOption(
|
|
9798
9798
|
new import_commander.Option("-z, --zarf <manifest|chart>", "Set Zarf package type").choices(["manifest", "chart"]).default("manifest")
|
|
9799
9799
|
).action(async (opts) => {
|
|
9800
|
-
outputDir = await
|
|
9800
|
+
outputDir = await createOutputDirectory(opts.output);
|
|
9801
9801
|
const buildModuleResult = await buildModule(void 0, opts.entryPoint, opts.embed);
|
|
9802
9802
|
const { cfg, path: path4 } = buildModuleResult;
|
|
9803
9803
|
if (opts.customName) {
|
|
@@ -9822,7 +9822,7 @@ function build_default(program2) {
|
|
|
9822
9822
|
);
|
|
9823
9823
|
}
|
|
9824
9824
|
if (!opts.embed) {
|
|
9825
|
-
console.info(
|
|
9825
|
+
console.info(`Module built successfully at ${path4}`);
|
|
9826
9826
|
return;
|
|
9827
9827
|
}
|
|
9828
9828
|
const assets = new Assets(
|
|
@@ -9907,7 +9907,7 @@ async function buildModule(reloader, entryPoint = peprTS2, embed = true) {
|
|
|
9907
9907
|
setup(build) {
|
|
9908
9908
|
build.onEnd(async (r) => {
|
|
9909
9909
|
if (r?.metafile) {
|
|
9910
|
-
console.
|
|
9910
|
+
console.info(await (0, import_esbuild2.analyzeMetafile)(r.metafile));
|
|
9911
9911
|
}
|
|
9912
9912
|
if (reloader) {
|
|
9913
9913
|
await reloader(r);
|
|
@@ -9940,7 +9940,7 @@ function handleModuleBuildError(e) {
|
|
|
9940
9940
|
if (!e.stdout) process.exit(1);
|
|
9941
9941
|
const out = e.stdout.toString();
|
|
9942
9942
|
const err = e.stderr.toString();
|
|
9943
|
-
console.
|
|
9943
|
+
console.info(out);
|
|
9944
9944
|
console.error(err);
|
|
9945
9945
|
if (out.includes("Types have separate declarations of a private property '_name'.")) {
|
|
9946
9946
|
const pgkErrMatch = /error TS2322: .*? 'import\("\/.*?\/node_modules\/(.*?)\/node_modules/g;
|
|
@@ -9967,7 +9967,7 @@ function handleModuleBuildError(e) {
|
|
|
9967
9967
|
async function checkFormat() {
|
|
9968
9968
|
const validFormat = await peprFormat(true);
|
|
9969
9969
|
if (!validFormat) {
|
|
9970
|
-
console.
|
|
9970
|
+
console.info(
|
|
9971
9971
|
"\x1B[33m%s\x1B[0m",
|
|
9972
9972
|
"Formatting errors were found. The build will continue, but you may want to run `npx pepr format` to address any issues."
|
|
9973
9973
|
);
|
|
@@ -10212,7 +10212,7 @@ function validateImagePullSecretDetails(details) {
|
|
|
10212
10212
|
if (missing.length > 0) {
|
|
10213
10213
|
return {
|
|
10214
10214
|
valid: false,
|
|
10215
|
-
error: `Error: Must provide ${missing.join(", ")} when providing --
|
|
10215
|
+
error: `Error: Must provide ${missing.join(", ")} when providing --pull-secret`
|
|
10216
10216
|
};
|
|
10217
10217
|
}
|
|
10218
10218
|
return { valid: true };
|
|
@@ -10764,7 +10764,7 @@ function update_default(program2) {
|
|
|
10764
10764
|
return;
|
|
10765
10765
|
}
|
|
10766
10766
|
}
|
|
10767
|
-
|
|
10767
|
+
logger_default.info("Updating the Pepr module...");
|
|
10768
10768
|
try {
|
|
10769
10769
|
(0, import_child_process6.execSync)("npm install pepr@latest", {
|
|
10770
10770
|
stdio: "inherit"
|
|
@@ -10774,14 +10774,14 @@ function update_default(program2) {
|
|
|
10774
10774
|
stdio: "inherit"
|
|
10775
10775
|
});
|
|
10776
10776
|
}
|
|
10777
|
-
|
|
10778
|
-
} catch (
|
|
10779
|
-
|
|
10777
|
+
logger_default.info(`\u2705 Module updated successfully`);
|
|
10778
|
+
} catch (error) {
|
|
10779
|
+
logger_default.error(error, `Error updating Pepr module:`);
|
|
10780
10780
|
process.exitCode = 1;
|
|
10781
10781
|
}
|
|
10782
10782
|
});
|
|
10783
10783
|
program2.command("update-templates", { hidden: true }).description("Perform template updates").action(async (opts) => {
|
|
10784
|
-
|
|
10784
|
+
logger_default.info("Updating Pepr config and template files...");
|
|
10785
10785
|
try {
|
|
10786
10786
|
if (!opts.skipTemplateUpdate) {
|
|
10787
10787
|
await write((0, import_path6.resolve)(prettier.path), prettier.data);
|
|
@@ -10798,8 +10798,8 @@ function update_default(program2) {
|
|
|
10798
10798
|
await write(tsPath, helloPepr.data);
|
|
10799
10799
|
}
|
|
10800
10800
|
}
|
|
10801
|
-
} catch (
|
|
10802
|
-
|
|
10801
|
+
} catch (error) {
|
|
10802
|
+
logger_default.error(error, `Error updating template files:`);
|
|
10803
10803
|
process.exitCode = 1;
|
|
10804
10804
|
}
|
|
10805
10805
|
});
|
|
@@ -10809,14 +10809,16 @@ function update_default(program2) {
|
|
|
10809
10809
|
var import_child_process7 = require("child_process");
|
|
10810
10810
|
var import_prompts6 = __toESM(require("prompts"));
|
|
10811
10811
|
function kfc_default(program2) {
|
|
10812
|
-
program2.command("kfc [args...]").description("Execute Kubernetes Fluent Client commands").action(async (args) => {
|
|
10813
|
-
|
|
10814
|
-
|
|
10815
|
-
|
|
10816
|
-
|
|
10817
|
-
|
|
10818
|
-
|
|
10819
|
-
|
|
10812
|
+
program2.command("kfc [args...]").description("Execute Kubernetes Fluent Client commands").option("-y, --yes", "Skip confirmation prompt.").action(async (args, options) => {
|
|
10813
|
+
if (!options.yes) {
|
|
10814
|
+
const { confirm: confirm2 } = await (0, import_prompts6.default)({
|
|
10815
|
+
type: "confirm",
|
|
10816
|
+
name: "confirm",
|
|
10817
|
+
message: "For commands that generate files, this may overwrite any previously generated files.\nAre you sure you want to continue?"
|
|
10818
|
+
});
|
|
10819
|
+
if (!confirm2) {
|
|
10820
|
+
return;
|
|
10821
|
+
}
|
|
10820
10822
|
}
|
|
10821
10823
|
try {
|
|
10822
10824
|
if (args.length === 0) {
|
|
@@ -10842,8 +10844,8 @@ var create = new import_commander3.Command("create").description("Create a new C
|
|
|
10842
10844
|
"-S, --scope <scope>",
|
|
10843
10845
|
"Whether the resulting custom resource is cluster- or namespace-scoped"
|
|
10844
10846
|
).choices(["Namespaced", "Cluster"]).default("Namespaced")
|
|
10845
|
-
).option("-d, --domain <domain>", "Optional domain for CRD (e.g. pepr.dev)", "pepr.dev").requiredOption("-g, --group <group>", "API group (e.g. cache)").requiredOption("-k, --kind <kind>", "Kind name (e.g. memcached)").option("-p, --plural <plural>", "Plural name for CRD (e.g. memcacheds)").
|
|
10846
|
-
console.log("This feature is currently in alpha
|
|
10847
|
+
).option("-d, --domain <domain>", "Optional domain for CRD (e.g. pepr.dev)", "pepr.dev").requiredOption("-g, --group <group>", "API group (e.g. cache)").requiredOption("-k, --kind <kind>", "Kind name (e.g. memcached)").option("-p, --plural <plural>", "Plural name for CRD (e.g. memcacheds)").requiredOption("-s, --short-name <name>", "Short name for CRD (e.g. mc)", "").requiredOption("-v, --version <version>", "API version (e.g. v1alpha1)").action(async ({ group: group2, version: version3, kind: kind8, domain, scope, plural: plural2, shortName }) => {
|
|
10848
|
+
console.log("This feature is currently in alpha.");
|
|
10847
10849
|
const outputDir2 = import_path7.default.resolve(`./api/${version3}`);
|
|
10848
10850
|
await createDirectoryIfNotExists(outputDir2);
|
|
10849
10851
|
await import_fs15.promises.writeFile(
|
|
@@ -10953,7 +10955,9 @@ var WarningMessages = {
|
|
|
10953
10955
|
};
|
|
10954
10956
|
|
|
10955
10957
|
// src/cli/crd/generate.ts
|
|
10956
|
-
var generate_default = new import_commander4.Command("generate").description(
|
|
10958
|
+
var generate_default = new import_commander4.Command("generate").description(
|
|
10959
|
+
"Generate CRD manifests from TypeScript definitions stored in 'api/' of the current directory."
|
|
10960
|
+
).option("-o, --output <directory>", "Output directory for generated CRDs", "./crds").action(generateCRDs);
|
|
10957
10961
|
function extractCRDDetails(content, sourceFile) {
|
|
10958
10962
|
const kind8 = extractSingleLineComment(content, "Kind");
|
|
10959
10963
|
const group2 = extractSingleLineComment(content, "Group") ?? "example";
|
|
@@ -10965,7 +10969,7 @@ function extractCRDDetails(content, sourceFile) {
|
|
|
10965
10969
|
return { kind: kind8, plural: plural2, scope, shortNames, fqdn };
|
|
10966
10970
|
}
|
|
10967
10971
|
async function generateCRDs(options) {
|
|
10968
|
-
|
|
10972
|
+
logger_default.warn("This feature is currently in alpha.\n");
|
|
10969
10973
|
const outputDir2 = import_path8.default.resolve(options.output);
|
|
10970
10974
|
await createDirectoryIfNotExists(outputDir2);
|
|
10971
10975
|
const project = new import_ts_morph.Project();
|
|
@@ -10990,12 +10994,12 @@ function processSourceFile(sourceFile, version3, outputDir2) {
|
|
|
10990
10994
|
const content = sourceFile.getFullText();
|
|
10991
10995
|
const { kind: kind8, fqdn, scope, plural: plural2, shortNames } = extractCRDDetails(content, sourceFile);
|
|
10992
10996
|
if (!kind8) {
|
|
10993
|
-
|
|
10997
|
+
logger_default.warn(WarningMessages.MISSING_KIND_COMMENT(sourceFile.getBaseName()));
|
|
10994
10998
|
return;
|
|
10995
10999
|
}
|
|
10996
11000
|
const spec = sourceFile.getInterface(`${kind8}Spec`);
|
|
10997
11001
|
if (!spec) {
|
|
10998
|
-
|
|
11002
|
+
logger_default.warn(WarningMessages.MISSING_INTERFACE(sourceFile.getBaseName(), kind8));
|
|
10999
11003
|
return;
|
|
11000
11004
|
}
|
|
11001
11005
|
const condition = sourceFile.getTypeAlias(`${kind8}StatusCondition`);
|
|
@@ -11013,7 +11017,7 @@ function processSourceFile(sourceFile, version3, outputDir2) {
|
|
|
11013
11017
|
});
|
|
11014
11018
|
const outPath = import_path8.default.join(outputDir2, `${kind8.toLowerCase()}.yaml`);
|
|
11015
11019
|
import_fs16.default.writeFileSync(outPath, (0, import_yaml.stringify)(crd), "utf8");
|
|
11016
|
-
|
|
11020
|
+
logger_default.info(`\u2714 Created ${outPath}`);
|
|
11017
11021
|
}
|
|
11018
11022
|
function extractSingleLineComment(content, label) {
|
|
11019
11023
|
const match = content.match(new RegExp(`//\\s+${label}:\\s+(.*)`));
|
package/dist/controller.js
CHANGED
|
@@ -50,7 +50,7 @@ if (process.env.LOG_LEVEL) {
|
|
|
50
50
|
var logger_default = Log;
|
|
51
51
|
|
|
52
52
|
// src/templates/data.json
|
|
53
|
-
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.51.6-nightly.
|
|
53
|
+
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.51.6-nightly.14", 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", "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:journey && npm run test:journey-wasm", "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:journey": "npm run test:journey:k3d && npm run build && npm run test:journey:image && npm run test:journey:run", "test:journey-wasm": "npm run test:journey:k3d && npm run build && npm run test:journey:image && npm run test:journey:run-wasm", "test:journey-wasm:unicorn": "npm run test:journey:k3d && npm run build && npm run test:journey:image:unicorn && npm run test:journey:run-wasm", "test:journey:image": "npm run build && docker buildx build --output type=docker --tag pepr:dev . && k3d image import pepr:dev -c pepr-dev", "test:journey:image: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", "test:journey:k3d": "k3d cluster delete pepr-dev && k3d cluster create pepr-dev --k3s-arg '--debug@server:0' --wait && kubectl rollout status deployment -n kube-system", "test:journey:run": "vitest run --config=config/vitest.journey.config.ts journey/entrypoint.test.ts", "test:journey:run-wasm": "vitest run --config=config/vitest.journey.config.ts journey/entrypoint-wasm.test.ts", "test:journey:unicorn": "npm run test:journey:k3d && npm run test:journey:image:unicorn && npm run test:journey:run", "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 test:journey:k3d && npm run test:journey:image:unicorn && vitest run integration/cluster/upgrade.test.ts", "test:upgrade:upstream": "npm run test:journey:k3d && npm run test:journey:image && vitest run integration/cluster/upgrade.test.ts" }, dependencies: { "@types/ramda": "0.30.2", 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.8.1", pino: "9.7.0", "pino-pretty": "13.0.0", "prom-client": "15.1.3", ramda: "0.31.3", sigstore: "3.1.0", "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: "^3.0.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.33.0", "@typescript-eslint/parser": "8.33.0", esbuild: "0.25.5", eslint: "^9.26.0", "node-forge": "1.3.1", prettier: "3.5.3", prompts: "2.4.2", typescript: "5.8.3", uuid: "11.1.0" } };
|
|
54
54
|
|
|
55
55
|
// src/lib/k8s.ts
|
|
56
56
|
var import_kubernetes_fluent_client = require("kubernetes-fluent-client");
|
package/package.json
CHANGED
package/src/cli/build.helpers.ts
CHANGED
|
@@ -83,18 +83,15 @@ export function determineRbacMode(
|
|
|
83
83
|
* @returns The desired output directory or the default one
|
|
84
84
|
*/
|
|
85
85
|
|
|
86
|
-
export async function
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
process.exit(1);
|
|
95
|
-
}
|
|
86
|
+
export async function createOutputDirectory(outputDir: string): Promise<string> {
|
|
87
|
+
try {
|
|
88
|
+
const dir = outputDir === "" ? "dist" : outputDir;
|
|
89
|
+
await createDirectoryIfNotExists(dir);
|
|
90
|
+
return dir;
|
|
91
|
+
} catch (error) {
|
|
92
|
+
console.error(`Error creating output directory: ${error.message}`);
|
|
93
|
+
process.exit(1);
|
|
96
94
|
}
|
|
97
|
-
return defaultOutputDir;
|
|
98
95
|
}
|
|
99
96
|
|
|
100
97
|
/**
|
|
@@ -221,7 +218,7 @@ export async function generateYamlAndWriteToDisk(obj: {
|
|
|
221
218
|
await fs.writeFile(zarfPath, localZarf);
|
|
222
219
|
|
|
223
220
|
await assets.generateHelmChart(webhookConfigGenerator, getWatcher, getModuleSecret, outputDir);
|
|
224
|
-
console.info(
|
|
221
|
+
console.info(`K8s resource for the module saved to ${yamlPath}`);
|
|
225
222
|
} catch (error) {
|
|
226
223
|
console.error(`Error generating YAML: ${error}`);
|
|
227
224
|
process.exit(1);
|
package/src/cli/build.ts
CHANGED
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
watchForChanges,
|
|
17
17
|
determineRbacMode,
|
|
18
18
|
assignImage,
|
|
19
|
-
|
|
19
|
+
createOutputDirectory,
|
|
20
20
|
handleValidCapabilityNames,
|
|
21
21
|
handleCustomImageBuild,
|
|
22
22
|
validImagePullSecret,
|
|
@@ -69,7 +69,10 @@ export default function (program: Command): void {
|
|
|
69
69
|
.command("build")
|
|
70
70
|
.description("Build a Pepr Module for deployment")
|
|
71
71
|
.addOption(
|
|
72
|
-
new Option("-M, --rbac-mode <
|
|
72
|
+
new Option("-M, --rbac-mode <mode>", "Override module config and set RBAC mode.").choices([
|
|
73
|
+
"admin",
|
|
74
|
+
"scoped",
|
|
75
|
+
]),
|
|
73
76
|
)
|
|
74
77
|
.addOption(
|
|
75
78
|
new Option(
|
|
@@ -95,7 +98,7 @@ export default function (program: Command): void {
|
|
|
95
98
|
"-n, --no-embed",
|
|
96
99
|
"Disable embedding of deployment files into output module. Useful when creating library modules intended solely for reuse/distribution via NPM.",
|
|
97
100
|
)
|
|
98
|
-
.option("-o, --output <directory>", "Set output directory.")
|
|
101
|
+
.option("-o, --output <directory>", "Set output directory.", "dist")
|
|
99
102
|
.addOption(
|
|
100
103
|
new Option(
|
|
101
104
|
"-r, --registry <GitHub|Iron Bank>",
|
|
@@ -115,8 +118,7 @@ export default function (program: Command): void {
|
|
|
115
118
|
.default("manifest"),
|
|
116
119
|
)
|
|
117
120
|
.action(async opts => {
|
|
118
|
-
|
|
119
|
-
outputDir = await handleCustomOutputDir(opts.output);
|
|
121
|
+
outputDir = await createOutputDirectory(opts.output);
|
|
120
122
|
|
|
121
123
|
// Build the module
|
|
122
124
|
const buildModuleResult = await buildModule(undefined, opts.entryPoint, opts.embed);
|
|
@@ -154,7 +156,7 @@ export default function (program: Command): void {
|
|
|
154
156
|
|
|
155
157
|
// If building without embedding, exit after building
|
|
156
158
|
if (!opts.embed) {
|
|
157
|
-
console.info(
|
|
159
|
+
console.info(`Module built successfully at ${path}`);
|
|
158
160
|
return;
|
|
159
161
|
}
|
|
160
162
|
|
|
@@ -274,7 +276,7 @@ export async function buildModule(
|
|
|
274
276
|
build.onEnd(async r => {
|
|
275
277
|
// Print the build size analysis
|
|
276
278
|
if (r?.metafile) {
|
|
277
|
-
console.
|
|
279
|
+
console.info(await analyzeMetafile(r.metafile));
|
|
278
280
|
}
|
|
279
281
|
|
|
280
282
|
// If we're in dev mode, call the reloader function
|
|
@@ -331,7 +333,7 @@ function handleModuleBuildError(e: BuildModuleResult): void {
|
|
|
331
333
|
const out = e.stdout.toString() as string;
|
|
332
334
|
const err = e.stderr.toString();
|
|
333
335
|
|
|
334
|
-
console.
|
|
336
|
+
console.info(out);
|
|
335
337
|
console.error(err);
|
|
336
338
|
|
|
337
339
|
// Check for version conflicts
|
|
@@ -365,7 +367,7 @@ export async function checkFormat(): Promise<void> {
|
|
|
365
367
|
const validFormat = await peprFormat(true);
|
|
366
368
|
|
|
367
369
|
if (!validFormat) {
|
|
368
|
-
console.
|
|
370
|
+
console.info(
|
|
369
371
|
"\x1b[33m%s\x1b[0m",
|
|
370
372
|
"Formatting errors were found. The build will continue, but you may want to run `npx pepr format` to address any issues.",
|
|
371
373
|
);
|
package/src/cli/crd/create.ts
CHANGED
|
@@ -21,10 +21,10 @@ const create = new Command("create")
|
|
|
21
21
|
.requiredOption("-g, --group <group>", "API group (e.g. cache)")
|
|
22
22
|
.requiredOption("-k, --kind <kind>", "Kind name (e.g. memcached)")
|
|
23
23
|
.option("-p, --plural <plural>", "Plural name for CRD (e.g. memcacheds)")
|
|
24
|
-
.
|
|
24
|
+
.requiredOption("-s, --short-name <name>", "Short name for CRD (e.g. mc)", "")
|
|
25
25
|
.requiredOption("-v, --version <version>", "API version (e.g. v1alpha1)")
|
|
26
26
|
.action(async ({ group, version, kind, domain, scope, plural, shortName }) => {
|
|
27
|
-
console.log("This feature is currently in alpha
|
|
27
|
+
console.log("This feature is currently in alpha.");
|
|
28
28
|
const outputDir = path.resolve(`./api/${version}`);
|
|
29
29
|
await createDirectoryIfNotExists(outputDir);
|
|
30
30
|
|
package/src/cli/crd/generate.ts
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import { Command } from "commander";
|
|
5
5
|
import fs from "fs";
|
|
6
6
|
import path from "path";
|
|
7
|
+
import Log from "../../lib/telemetry/logger";
|
|
7
8
|
import { stringify } from "yaml";
|
|
8
9
|
import {
|
|
9
10
|
Project,
|
|
@@ -20,7 +21,9 @@ import { V1JSONSchemaProps } from "@kubernetes/client-node";
|
|
|
20
21
|
import { WarningMessages, ErrorMessages } from "./messages";
|
|
21
22
|
|
|
22
23
|
export default new Command("generate")
|
|
23
|
-
.description(
|
|
24
|
+
.description(
|
|
25
|
+
"Generate CRD manifests from TypeScript definitions stored in 'api/' of the current directory.",
|
|
26
|
+
)
|
|
24
27
|
.option("-o, --output <directory>", "Output directory for generated CRDs", "./crds")
|
|
25
28
|
.action(generateCRDs);
|
|
26
29
|
|
|
@@ -48,7 +51,7 @@ export function extractCRDDetails(
|
|
|
48
51
|
}
|
|
49
52
|
|
|
50
53
|
export async function generateCRDs(options: { output: string }): Promise<void> {
|
|
51
|
-
|
|
54
|
+
Log.warn("This feature is currently in alpha.\n");
|
|
52
55
|
const outputDir = path.resolve(options.output);
|
|
53
56
|
await createDirectoryIfNotExists(outputDir);
|
|
54
57
|
|
|
@@ -83,13 +86,13 @@ export function processSourceFile(
|
|
|
83
86
|
const { kind, fqdn, scope, plural, shortNames } = extractCRDDetails(content, sourceFile);
|
|
84
87
|
|
|
85
88
|
if (!kind) {
|
|
86
|
-
|
|
89
|
+
Log.warn(WarningMessages.MISSING_KIND_COMMENT(sourceFile.getBaseName()));
|
|
87
90
|
return;
|
|
88
91
|
}
|
|
89
92
|
|
|
90
93
|
const spec = sourceFile.getInterface(`${kind}Spec`);
|
|
91
94
|
if (!spec) {
|
|
92
|
-
|
|
95
|
+
Log.warn(WarningMessages.MISSING_INTERFACE(sourceFile.getBaseName(), kind));
|
|
93
96
|
return;
|
|
94
97
|
}
|
|
95
98
|
|
|
@@ -110,7 +113,7 @@ export function processSourceFile(
|
|
|
110
113
|
|
|
111
114
|
const outPath = path.join(outputDir, `${kind.toLowerCase()}.yaml`);
|
|
112
115
|
fs.writeFileSync(outPath, stringify(crd), "utf8");
|
|
113
|
-
|
|
116
|
+
Log.info(`✔ Created ${outPath}`);
|
|
114
117
|
}
|
|
115
118
|
|
|
116
119
|
// Extracts a comment from the content of a file based on a label.
|
package/src/cli/deploy.ts
CHANGED
|
@@ -54,7 +54,7 @@ export function validateImagePullSecretDetails(details: ImagePullSecretDetails):
|
|
|
54
54
|
if (missing.length > 0) {
|
|
55
55
|
return {
|
|
56
56
|
valid: false,
|
|
57
|
-
error: `Error: Must provide ${missing.join(", ")} when providing --
|
|
57
|
+
error: `Error: Must provide ${missing.join(", ")} when providing --pull-secret`,
|
|
58
58
|
};
|
|
59
59
|
}
|
|
60
60
|
|
package/src/cli/format/index.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { ESLint } from "eslint";
|
|
|
5
5
|
import { formatWithPrettier } from "./format.helpers";
|
|
6
6
|
|
|
7
7
|
import { Command } from "commander";
|
|
8
|
+
import Log from "../../lib/telemetry/logger";
|
|
8
9
|
|
|
9
10
|
export default function (program: Command): void {
|
|
10
11
|
program
|
|
@@ -47,7 +48,7 @@ export async function peprFormat(validateOnly: boolean): Promise<boolean> {
|
|
|
47
48
|
const resultText = await formatter.format(results, {} as ESLint.LintResultData);
|
|
48
49
|
|
|
49
50
|
if (resultText) {
|
|
50
|
-
|
|
51
|
+
Log.info(resultText);
|
|
51
52
|
}
|
|
52
53
|
|
|
53
54
|
// Write the fixes if not in validate-only mode
|
package/src/cli/kfc.ts
CHANGED
|
@@ -10,18 +10,22 @@ export default function (program: Command): void {
|
|
|
10
10
|
program
|
|
11
11
|
.command("kfc [args...]")
|
|
12
12
|
.description("Execute Kubernetes Fluent Client commands")
|
|
13
|
-
.
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
"
|
|
19
|
-
|
|
20
|
-
|
|
13
|
+
.option("-y, --yes", "Skip confirmation prompt.")
|
|
14
|
+
.action(async (args: string[], options) => {
|
|
15
|
+
// Skip confirmation if yes flag is provided
|
|
16
|
+
if (!options.yes) {
|
|
17
|
+
const { confirm } = await prompt({
|
|
18
|
+
type: "confirm",
|
|
19
|
+
name: "confirm",
|
|
20
|
+
message:
|
|
21
|
+
"For commands that generate files, this may overwrite any previously generated files.\n" +
|
|
22
|
+
"Are you sure you want to continue?",
|
|
23
|
+
});
|
|
21
24
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
+
// If the user doesn't confirm, exit
|
|
26
|
+
if (!confirm) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
25
29
|
}
|
|
26
30
|
|
|
27
31
|
try {
|
package/src/cli/update/index.ts
CHANGED
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
} from "../init/templates";
|
|
17
17
|
import { write } from "../init/utils";
|
|
18
18
|
import { Command } from "commander";
|
|
19
|
+
import Log from "../../lib/telemetry/logger";
|
|
19
20
|
|
|
20
21
|
export default function (program: Command): void {
|
|
21
22
|
program
|
|
@@ -38,7 +39,7 @@ export default function (program: Command): void {
|
|
|
38
39
|
}
|
|
39
40
|
}
|
|
40
41
|
|
|
41
|
-
|
|
42
|
+
Log.info("Updating the Pepr module...");
|
|
42
43
|
|
|
43
44
|
try {
|
|
44
45
|
// Update Pepr for the module
|
|
@@ -53,9 +54,9 @@ export default function (program: Command): void {
|
|
|
53
54
|
});
|
|
54
55
|
}
|
|
55
56
|
|
|
56
|
-
|
|
57
|
-
} catch (
|
|
58
|
-
|
|
57
|
+
Log.info(`✅ Module updated successfully`);
|
|
58
|
+
} catch (error) {
|
|
59
|
+
Log.error(error, `Error updating Pepr module:`);
|
|
59
60
|
process.exitCode = 1;
|
|
60
61
|
}
|
|
61
62
|
});
|
|
@@ -64,7 +65,7 @@ export default function (program: Command): void {
|
|
|
64
65
|
.command("update-templates", { hidden: true })
|
|
65
66
|
.description("Perform template updates")
|
|
66
67
|
.action(async opts => {
|
|
67
|
-
|
|
68
|
+
Log.info("Updating Pepr config and template files...");
|
|
68
69
|
|
|
69
70
|
try {
|
|
70
71
|
// Don't update the template files if the user specified the --skip-template-update flag
|
|
@@ -87,8 +88,8 @@ export default function (program: Command): void {
|
|
|
87
88
|
await write(tsPath, helloPepr.data);
|
|
88
89
|
}
|
|
89
90
|
}
|
|
90
|
-
} catch (
|
|
91
|
-
|
|
91
|
+
} catch (error) {
|
|
92
|
+
Log.error(error, `Error updating template files:`);
|
|
92
93
|
process.exitCode = 1;
|
|
93
94
|
}
|
|
94
95
|
});
|