pepr 0.42.3 → 0.44.0-nightly.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/dist/cli/build.d.ts +25 -11
  2. package/dist/cli/build.d.ts.map +1 -1
  3. package/dist/cli/build.helpers.d.ts +13 -14
  4. package/dist/cli/build.helpers.d.ts.map +1 -1
  5. package/dist/cli/deploy.d.ts.map +1 -1
  6. package/dist/cli/dev.d.ts.map +1 -1
  7. package/dist/cli/init/templates.d.ts +7 -5
  8. package/dist/cli/init/templates.d.ts.map +1 -1
  9. package/dist/cli.js +786 -739
  10. package/dist/controller.js +1 -1
  11. package/dist/fixtures/loader.d.ts.map +1 -1
  12. package/dist/lib/assets/assets.d.ts +15 -12
  13. package/dist/lib/assets/assets.d.ts.map +1 -1
  14. package/dist/lib/assets/deploy.d.ts +1 -1
  15. package/dist/lib/assets/deploy.d.ts.map +1 -1
  16. package/dist/lib/assets/helm.d.ts.map +1 -1
  17. package/dist/lib/assets/index.d.ts.map +1 -1
  18. package/dist/lib/assets/webhooks.d.ts +4 -1
  19. package/dist/lib/assets/webhooks.d.ts.map +1 -1
  20. package/dist/lib/assets/yaml/generateAllYaml.d.ts +9 -0
  21. package/dist/lib/assets/yaml/generateAllYaml.d.ts.map +1 -0
  22. package/dist/lib/assets/yaml/generateZarfYaml.d.ts +5 -0
  23. package/dist/lib/assets/yaml/generateZarfYaml.d.ts.map +1 -0
  24. package/dist/lib/assets/yaml/overridesFile.d.ts +15 -0
  25. package/dist/lib/assets/yaml/overridesFile.d.ts.map +1 -0
  26. package/dist/lib/core/module.d.ts +23 -20
  27. package/dist/lib/core/module.d.ts.map +1 -1
  28. package/dist/lib/enums.d.ts +4 -0
  29. package/dist/lib/enums.d.ts.map +1 -1
  30. package/dist/lib/processors/mutate-processor.d.ts +2 -0
  31. package/dist/lib/processors/mutate-processor.d.ts.map +1 -1
  32. package/dist/lib/processors/validate-processor.d.ts.map +1 -1
  33. package/dist/lib/telemetry/timeUtils.d.ts +2 -0
  34. package/dist/lib/telemetry/timeUtils.d.ts.map +1 -0
  35. package/dist/lib/telemetry/webhookTimeouts.d.ts +9 -0
  36. package/dist/lib/telemetry/webhookTimeouts.d.ts.map +1 -0
  37. package/dist/lib.js +79 -22
  38. package/dist/lib.js.map +4 -4
  39. package/package.json +7 -4
  40. package/src/cli/build.helpers.ts +35 -35
  41. package/src/cli/build.ts +126 -70
  42. package/src/cli/deploy.ts +7 -6
  43. package/src/cli/dev.ts +9 -6
  44. package/src/cli/init/templates.ts +6 -5
  45. package/src/fixtures/loader.ts +2 -2
  46. package/src/lib/assets/assets.ts +66 -53
  47. package/src/lib/assets/deploy.ts +32 -30
  48. package/src/lib/assets/helm.ts +22 -4
  49. package/src/lib/assets/index.ts +33 -9
  50. package/src/lib/assets/pods.ts +2 -2
  51. package/src/lib/assets/webhooks.ts +21 -6
  52. package/src/lib/assets/yaml/generateAllYaml.ts +50 -0
  53. package/src/lib/assets/yaml/generateZarfYaml.ts +38 -0
  54. package/src/lib/assets/{yaml.ts → yaml/overridesFile.ts} +8 -120
  55. package/src/lib/core/module.ts +26 -21
  56. package/src/lib/enums.ts +6 -0
  57. package/src/lib/processors/mutate-processor.ts +15 -7
  58. package/src/lib/processors/validate-processor.ts +13 -4
  59. package/src/lib/telemetry/timeUtils.ts +1 -0
  60. package/src/lib/telemetry/webhookTimeouts.ts +34 -0
  61. package/dist/lib/assets/yaml.d.ts +0 -32
  62. package/dist/lib/assets/yaml.d.ts.map +0 -1
package/package.json CHANGED
@@ -15,18 +15,21 @@
15
15
  "!src/**/*.test.ts",
16
16
  "!dist/**/*.test.d.ts*"
17
17
  ],
18
- "version": "0.42.3",
18
+ "version": "0.44.0-nightly.0",
19
19
  "main": "dist/lib.js",
20
20
  "types": "dist/lib.d.ts",
21
21
  "scripts": {
22
22
  "ci": "npm ci",
23
23
  "gen-data-json": "node hack/build-template-data.js",
24
24
  "prebuild": "rm -fr dist/* && npm run gen-data-json",
25
- "version": "node scripts/set-version.js",
26
25
  "build": "tsc && node build.mjs && npm pack",
27
26
  "build:image": "npm run build && docker buildx build --output type=docker --tag pepr:dev .",
27
+ "set:version": "node scripts/set-version.js",
28
28
  "test": "npm run test:unit && npm run test:journey",
29
29
  "test:unit": "npm run gen-data-json && jest src --coverage --detectOpenHandles --coverageDirectory=./coverage --testPathIgnorePatterns='cosign.e2e.test.ts'",
30
+ "test:integration": "npm run test:integration:prep && npm run test:integration:run",
31
+ "test:integration:prep": "./integration/prep.sh",
32
+ "test:integration:run": "jest --maxWorkers=4 integration",
30
33
  "test:journey": "npm run test:journey:k3d && npm run build && npm run test:journey:image && npm run test:journey:run",
31
34
  "test:journey:prep": "if [ ! -d ./pepr-upgrade-test ]; then git clone https://github.com/defenseunicorns/pepr-upgrade-test.git ; fi",
32
35
  "test:journey-wasm": "npm run test:journey:k3d && npm run build && npm run test:journey:image && npm run test:journey:run-wasm",
@@ -46,7 +49,7 @@
46
49
  "follow-redirects": "1.15.9",
47
50
  "http-status-codes": "^2.3.0",
48
51
  "json-pointer": "^0.6.2",
49
- "kubernetes-fluent-client": "3.3.7",
52
+ "kubernetes-fluent-client": "3.3.8",
50
53
  "pino": "9.6.0",
51
54
  "pino-pretty": "13.0.0",
52
55
  "prom-client": "15.1.3",
@@ -85,4 +88,4 @@
85
88
  "typescript": "^5.3.3",
86
89
  "uuid": "11.0.3"
87
90
  }
88
- }
91
+ }
@@ -8,6 +8,37 @@ import { BuildOptions, BuildResult, context, BuildContext } from "esbuild";
8
8
  import { Assets } from "../lib/assets/assets";
9
9
  import { resolve } from "path";
10
10
  import { promises as fs } from "fs";
11
+ import { generateAllYaml } from "../lib/assets/yaml/generateAllYaml";
12
+ import { webhookConfigGenerator } from "../lib/assets/webhooks";
13
+ import { generateZarfYamlGeneric } from "../lib/assets/yaml/generateZarfYaml";
14
+
15
+ interface ImageOptions {
16
+ customImage?: string;
17
+ registryInfo?: string;
18
+ peprVersion?: string;
19
+ registry?: string;
20
+ }
21
+ /**
22
+ * Assign image string
23
+ * @param imageOptions CLI options for image
24
+ * @returns image string
25
+ */
26
+ export function assignImage(imageOptions: ImageOptions): string {
27
+ const { customImage, registryInfo, peprVersion, registry } = imageOptions;
28
+ if (customImage) {
29
+ return customImage;
30
+ }
31
+
32
+ if (registryInfo) {
33
+ return `${registryInfo}/custom-pepr-controller:${peprVersion}`;
34
+ }
35
+
36
+ if (registry) {
37
+ return checkIronBankImage(registry, "", peprVersion!);
38
+ }
39
+
40
+ return "";
41
+ }
11
42
 
12
43
  export type Reloader = (opts: BuildResult<BuildOptions>) => void | Promise<void>;
13
44
  /**
@@ -89,24 +120,6 @@ export function validImagePullSecret(imagePullSecretName: string): void {
89
120
  }
90
121
  }
91
122
 
92
- /**
93
- * Constraint to majke sure customImage and registry are not both used
94
- * @param customImage
95
- * @param registry
96
- * @returns
97
- */
98
- export function handleCustomImage(customImage: string, registry: string): string {
99
- let defaultImage = "";
100
- if (customImage) {
101
- if (registry) {
102
- console.error(`Custom Image and registry cannot be used together.`);
103
- process.exit(1);
104
- }
105
- defaultImage = customImage;
106
- }
107
- return defaultImage;
108
- }
109
-
110
123
  /**
111
124
  * Creates and pushes a custom image for WASM or any other included files
112
125
  * @param includedFiles
@@ -129,19 +142,6 @@ export async function handleCustomImageBuild(
129
142
  }
130
143
  }
131
144
 
132
- /**
133
- * Disables embedding of deployment files into output module
134
- * @param embed
135
- * @param path
136
- * @returns
137
- */
138
- export function handleEmbedding(embed: boolean, path: string): void {
139
- if (!embed) {
140
- console.info(`✅ Module built successfully at ${path}`);
141
- return;
142
- }
143
- }
144
-
145
145
  /**
146
146
  * Check if the capability names are valid
147
147
  * @param capabilities The capabilities to check
@@ -191,18 +191,18 @@ export async function generateYamlAndWriteToDisk(obj: {
191
191
  const yamlFile = `pepr-module-${uuid}.yaml`;
192
192
  const chartPath = `${uuid}-chart`;
193
193
  const yamlPath = resolve(outputDir, yamlFile);
194
- const yaml = await assets.allYaml(imagePullSecret);
194
+ const yaml = await assets.allYaml(generateAllYaml, imagePullSecret);
195
195
  const zarfPath = resolve(outputDir, "zarf.yaml");
196
196
 
197
197
  let localZarf = "";
198
198
  if (zarf === "chart") {
199
- localZarf = assets.zarfYamlChart(chartPath);
199
+ localZarf = assets.zarfYamlChart(generateZarfYamlGeneric, chartPath);
200
200
  } else {
201
- localZarf = assets.zarfYaml(yamlFile);
201
+ localZarf = assets.zarfYaml(generateZarfYamlGeneric, yamlFile);
202
202
  }
203
203
  await fs.writeFile(yamlPath, yaml);
204
204
  await fs.writeFile(zarfPath, localZarf);
205
205
 
206
- await assets.generateHelmChart(outputDir);
206
+ await assets.generateHelmChart(webhookConfigGenerator, outputDir);
207
207
  console.info(`✅ K8s resource for the module saved to ${yamlPath}`);
208
208
  }
package/src/cli/build.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  // SPDX-FileCopyrightText: 2023-Present The Pepr Authors
3
3
 
4
4
  import { execFileSync } from "child_process";
5
- import { BuildOptions, BuildResult, analyzeMetafile } from "esbuild";
5
+ import { BuildContext, BuildOptions, BuildResult, analyzeMetafile } from "esbuild";
6
6
  import { promises as fs } from "fs";
7
7
  import { basename, dirname, extname, resolve } from "path";
8
8
  import { Assets } from "../lib/assets/assets";
@@ -11,15 +11,14 @@ import { RootCmd } from "./root";
11
11
  import { Option } from "commander";
12
12
  import { parseTimeout } from "../lib/helpers";
13
13
  import { peprFormat } from "./format";
14
+ import { ModuleConfig } from "../lib/core/module";
14
15
  import {
15
16
  watchForChanges,
16
17
  determineRbacMode,
17
- handleEmbedding,
18
+ assignImage,
18
19
  handleCustomOutputDir,
19
20
  handleValidCapabilityNames,
20
- handleCustomImage,
21
21
  handleCustomImageBuild,
22
- checkIronBankImage,
23
22
  validImagePullSecret,
24
23
  generateYamlAndWriteToDisk,
25
24
  } from "./build.helpers";
@@ -27,6 +26,43 @@ import {
27
26
  const peprTS = "pepr.ts";
28
27
  let outputDir: string = "dist";
29
28
  export type Reloader = (opts: BuildResult<BuildOptions>) => void | Promise<void>;
29
+ export type PeprNestedFields = Pick<
30
+ ModuleConfig,
31
+ | "uuid"
32
+ | "onError"
33
+ | "webhookTimeout"
34
+ | "customLabels"
35
+ | "alwaysIgnore"
36
+ | "env"
37
+ | "rbac"
38
+ | "rbacMode"
39
+ > & {
40
+ peprVersion: string;
41
+ };
42
+
43
+ export type PeprConfig = Omit<ModuleConfig, keyof PeprNestedFields> & {
44
+ pepr: PeprNestedFields & {
45
+ includedFiles: string[];
46
+ };
47
+ description: string;
48
+ version: string;
49
+ };
50
+
51
+ type LoadModuleReturn = {
52
+ cfg: PeprConfig;
53
+ entryPointPath: string;
54
+ modulePath: string;
55
+ name: string;
56
+ path: string;
57
+ uuid: string;
58
+ };
59
+
60
+ type BuildModuleReturn = {
61
+ ctx: BuildContext<BuildOptions>;
62
+ path: string;
63
+ cfg: PeprConfig;
64
+ uuid: string;
65
+ };
30
66
 
31
67
  export default function (program: RootCmd): void {
32
68
  program
@@ -37,34 +73,44 @@ export default function (program: RootCmd): void {
37
73
  "-n, --no-embed",
38
74
  "Disables embedding of deployment files into output module. Useful when creating library modules intended solely for reuse/distribution via NPM.",
39
75
  )
40
- .option(
41
- "-i, --custom-image <custom-image>",
42
- "Custom Image: Use custom image for Admission and Watch Deployments.",
76
+ .addOption(
77
+ new Option(
78
+ "-i, --custom-image <custom-image>",
79
+ "Specify a custom image (including version) for Admission and Watch Deployments. Example: 'docker.io/username/custom-pepr-controller:v1.0.0'",
80
+ ).conflicts(["version", "registryInfo", "registry"]),
43
81
  )
44
- .option(
45
- "-r, --registry-info [<registry>/<username>]",
46
- "Registry Info: Image registry and username. Note: You must be signed into the registry",
82
+ .addOption(
83
+ new Option(
84
+ "-r, --registry-info [<registry>/<username>]",
85
+ "Provide the image registry and username for building and pushing a custom WASM container. Requires authentication. Builds and pushes 'registry/username/custom-pepr-controller:<current-version>'.",
86
+ ).conflicts(["customImage", "version", "registry"]),
47
87
  )
88
+
48
89
  .option("-o, --output-dir <output directory>", "Define where to place build output")
49
90
  .option(
50
91
  "--timeout <timeout>",
51
92
  "How long the API server should wait for a webhook to respond before treating the call as a failure",
52
93
  parseTimeout,
53
94
  )
54
- .option(
55
- "-v, --version <version>. Example: '0.27.3'",
56
- "The version of the Pepr image to use in the deployment manifests.",
95
+ .addOption(
96
+ new Option(
97
+ "-v, --version <version>",
98
+ "The version of the Pepr image to use in the deployment manifests. Example: '0.27.3'.",
99
+ ).conflicts(["customImage", "registryInfo"]),
57
100
  )
58
101
  .option(
59
102
  "--withPullSecret <imagePullSecret>",
60
103
  "Image Pull Secret: Use image pull secret for controller Deployment.",
104
+ "",
61
105
  )
62
106
 
63
107
  .addOption(
64
108
  new Option(
65
109
  "--registry <GitHub|Iron Bank>",
66
110
  "Container registry: Choose container registry for deployment manifests. Can't be used with --custom-image.",
67
- ).choices(["GitHub", "Iron Bank"]),
111
+ )
112
+ .conflicts(["customImage", "registryInfo"])
113
+ .choices(["GitHub", "Iron Bank"]),
68
114
  )
69
115
 
70
116
  .addOption(
@@ -86,64 +132,70 @@ export default function (program: RootCmd): void {
86
132
 
87
133
  // Build the module
88
134
  const buildModuleResult = await buildModule(undefined, opts.entryPoint, opts.embed);
89
- if (buildModuleResult?.cfg && buildModuleResult.path && buildModuleResult.uuid) {
90
- const { cfg, path, uuid } = buildModuleResult;
91
- // Files to include in controller image for WASM support
92
- const { includedFiles } = cfg.pepr;
93
-
94
- let image = handleCustomImage(opts.customImage, opts.registry);
95
-
96
- // Check if there is a custom timeout defined
97
- if (opts.timeout !== undefined) {
98
- cfg.pepr.webhookTimeout = opts.timeout;
99
- }
100
-
101
- if (opts.registryInfo !== undefined) {
102
- console.info(`Including ${includedFiles.length} files in controller image.`);
103
-
104
- // for journey test to make sure the image is built
105
- image = `${opts.registryInfo}/custom-pepr-controller:${cfg.pepr.peprVersion}`;
106
-
107
- // only actually build/push if there are files to include
108
- await handleCustomImageBuild(includedFiles, cfg.pepr.peprVersion, cfg.description, image);
109
- }
110
-
111
- // If building without embedding, exit after building
112
- handleEmbedding(opts.embed, path);
113
-
114
- // set the image version if provided
115
- opts.version ? (cfg.pepr.peprVersion = opts.version) : null;
116
-
117
- // Generate a secret for the module
118
- const assets = new Assets(
119
- {
120
- ...cfg.pepr,
121
- appVersion: cfg.version,
122
- description: cfg.description,
123
- // Can override the rbacMode with the CLI option
124
- rbacMode: determineRbacMode(opts, cfg),
125
- },
126
- path,
127
- );
128
135
 
129
- // If registry is set to Iron Bank, use Iron Bank image
130
- image = checkIronBankImage(opts.registry, image, cfg.pepr.peprVersion);
136
+ const { cfg, path, uuid } = buildModuleResult!;
137
+ const image = assignImage({
138
+ customImage: opts.customImage,
139
+ registryInfo: opts.registryInfo,
140
+ peprVersion: cfg.pepr.peprVersion,
141
+ registry: opts.registry,
142
+ });
143
+
144
+ // Check if there is a custom timeout defined
145
+ if (opts.timeout !== undefined) {
146
+ cfg.pepr.webhookTimeout = opts.timeout;
147
+ }
131
148
 
132
- // if image is a custom image, use that instead of the default
133
- image !== "" ? (assets.image = image) : null;
149
+ if (opts.registryInfo !== undefined) {
150
+ console.info(`Including ${cfg.pepr.includedFiles.length} files in controller image.`);
151
+ // for journey test to make sure the image is built
134
152
 
135
- // Ensure imagePullSecret is valid
136
- validImagePullSecret(opts.withPullSecret);
153
+ // only actually build/push if there are files to include
154
+ await handleCustomImageBuild(
155
+ cfg.pepr.includedFiles,
156
+ cfg.pepr.peprVersion,
157
+ cfg.description,
158
+ image,
159
+ );
160
+ }
137
161
 
138
- handleValidCapabilityNames(assets.capabilities);
139
- await generateYamlAndWriteToDisk({
140
- uuid,
141
- outputDir,
142
- imagePullSecret: opts.withPullSecret,
143
- zarf: opts.zarf,
144
- assets,
145
- });
162
+ // If building without embedding, exit after building
163
+ if (!opts.embed) {
164
+ console.info(`✅ Module built successfully at ${path}`);
165
+ return;
146
166
  }
167
+ // set the image version if provided
168
+ opts.version ? (cfg.pepr.peprVersion = opts.version) : null;
169
+
170
+ // Generate a secret for the module
171
+ const assets = new Assets(
172
+ {
173
+ ...cfg.pepr,
174
+ appVersion: cfg.version,
175
+ description: cfg.description,
176
+ alwaysIgnore: {
177
+ namespaces: cfg.pepr.alwaysIgnore?.namespaces,
178
+ },
179
+ // Can override the rbacMode with the CLI option
180
+ rbacMode: determineRbacMode(opts, cfg),
181
+ },
182
+ path,
183
+ opts.withPullSecret === "" ? [] : [opts.withPullSecret],
184
+ );
185
+
186
+ image !== "" ? (assets.image = image) : null;
187
+
188
+ // Ensure imagePullSecret is valid
189
+ validImagePullSecret(opts.withPullSecret);
190
+
191
+ handleValidCapabilityNames(assets.capabilities);
192
+ await generateYamlAndWriteToDisk({
193
+ uuid,
194
+ outputDir,
195
+ imagePullSecret: opts.withPullSecret,
196
+ zarf: opts.zarf,
197
+ assets,
198
+ });
147
199
  });
148
200
  }
149
201
 
@@ -156,7 +208,7 @@ externalLibs.push("pepr");
156
208
  // Add the kubernetes client to the list of external libraries as it is pulled in by kubernetes-fluent-client
157
209
  externalLibs.push("@kubernetes/client-node");
158
210
 
159
- export async function loadModule(entryPoint = peprTS) {
211
+ export async function loadModule(entryPoint = peprTS): Promise<LoadModuleReturn> {
160
212
  // Resolve path to the module / files
161
213
  const entryPointPath = resolve(".", entryPoint);
162
214
  const modulePath = dirname(entryPointPath);
@@ -197,7 +249,11 @@ export async function loadModule(entryPoint = peprTS) {
197
249
  };
198
250
  }
199
251
 
200
- export async function buildModule(reloader?: Reloader, entryPoint = peprTS, embed = true) {
252
+ export async function buildModule(
253
+ reloader?: Reloader,
254
+ entryPoint = peprTS,
255
+ embed = true,
256
+ ): Promise<BuildModuleReturn | void> {
201
257
  try {
202
258
  const { cfg, modulePath, path, uuid } = await loadModule(entryPoint);
203
259
 
@@ -314,7 +370,7 @@ function handleModuleBuildError(e: BuildModuleResult): void {
314
370
  }
315
371
  }
316
372
 
317
- export async function checkFormat() {
373
+ export async function checkFormat(): Promise<void> {
318
374
  const validFormat = await peprFormat(true);
319
375
 
320
376
  if (!validFormat) {
package/src/cli/deploy.ts CHANGED
@@ -4,13 +4,13 @@
4
4
  import prompt from "prompts";
5
5
 
6
6
  import { Assets } from "../lib/assets/assets";
7
- import { buildModule } from "./build";
8
- import { RootCmd } from "./root";
9
- import { validateCapabilityNames } from "../lib/helpers";
10
7
  import { ImagePullSecret } from "../lib/types";
11
- import { sanitizeName } from "./init/utils";
12
- import { deployImagePullSecret } from "../lib/assets/deploy";
8
+ import { RootCmd } from "./root";
9
+ import { buildModule } from "./build";
10
+ import { deployImagePullSecret, deployWebhook } from "../lib/assets/deploy";
13
11
  import { namespaceDeploymentsReady } from "../lib/deploymentChecks";
12
+ import { sanitizeName } from "./init/utils";
13
+ import { validateCapabilityNames } from "../lib/helpers";
14
14
 
15
15
  export interface ImagePullSecretDetails {
16
16
  pullSecret?: string;
@@ -128,11 +128,12 @@ export default function (program: RootCmd): void {
128
128
  const webhook = new Assets(
129
129
  { ...builtModule.cfg.pepr, description: builtModule.cfg.description },
130
130
  builtModule.path,
131
+ [],
131
132
  );
132
133
  webhook.image = opts.image ?? webhook.image;
133
134
 
134
135
  try {
135
- await webhook.deploy(opts.force, builtModule.cfg.pepr.webhookTimeout ?? 10);
136
+ await webhook.deploy(deployWebhook, opts.force, builtModule.cfg.pepr.webhookTimeout ?? 10);
136
137
 
137
138
  // wait for capabilities to be loaded and test names
138
139
  validateCapabilityNames(webhook.capabilities);
package/src/cli/dev.ts CHANGED
@@ -1,15 +1,17 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  // SPDX-FileCopyrightText: 2023-Present The Pepr Authors
3
3
 
4
- import { ChildProcess, fork } from "child_process";
5
- import { promises as fs } from "fs";
6
4
  import prompt from "prompts";
7
- import { validateCapabilityNames } from "../lib/helpers";
8
5
  import { Assets } from "../lib/assets/assets";
9
- import { buildModule, loadModule } from "./build";
10
- import { RootCmd } from "./root";
6
+ import { ChildProcess, fork } from "child_process";
11
7
  import { K8s, kind } from "kubernetes-fluent-client";
8
+ import { RootCmd } from "./root";
12
9
  import { Store } from "../lib/k8s";
10
+ import { buildModule, loadModule } from "./build";
11
+ import { deployWebhook } from "../lib/assets/deploy";
12
+ import { promises as fs } from "fs";
13
+ import { validateCapabilityNames } from "../lib/helpers";
14
+
13
15
  export default function (program: RootCmd): void {
14
16
  program
15
17
  .command("dev")
@@ -41,6 +43,7 @@ export default function (program: RootCmd): void {
41
43
  description: cfg.description,
42
44
  },
43
45
  path,
46
+ [],
44
47
  opts.host,
45
48
  );
46
49
 
@@ -59,7 +62,7 @@ export default function (program: RootCmd): void {
59
62
  console.info(`Running module ${path}`);
60
63
 
61
64
  // Deploy the webhook with a 30 second timeout for debugging, don't force
62
- await webhook.deploy(false, 30);
65
+ await webhook.deploy(deployWebhook, false, 30);
63
66
 
64
67
  try {
65
68
  // wait for capabilities to be loaded and test names
@@ -6,16 +6,17 @@ import { inspect } from "util";
6
6
  import { v4 as uuidv4, v5 as uuidv5 } from "uuid";
7
7
 
8
8
  import eslintJSON from "../../templates/.eslintrc.template.json";
9
+ import peprSnippetsJSON from "../../templates/pepr.code-snippets.json";
9
10
  import prettierJSON from "../../templates/.prettierrc.json";
10
11
  import samplesJSON from "../../templates/capabilities/hello-pepr.samples.json";
11
- import { gitIgnore, helloPeprTS, packageJSON, peprTS, readmeMd } from "../../templates/data.json";
12
- import peprSnippetsJSON from "../../templates/pepr.code-snippets.json";
13
12
  import settingsJSON from "../../templates/settings.json";
14
13
  import tsConfigJSON from "../../templates/tsconfig.module.json";
15
- import { sanitizeName } from "./utils";
14
+ import { CustomLabels } from "../../lib/core/module";
16
15
  import { InitOptions } from "../types";
17
- import { V1PolicyRule as PolicyRule } from "@kubernetes/client-node";
18
16
  import { OnError, RbacMode } from "./enums";
17
+ import { V1PolicyRule as PolicyRule } from "@kubernetes/client-node";
18
+ import { gitIgnore, helloPeprTS, packageJSON, peprTS, readmeMd } from "../../templates/data.json";
19
+ import { sanitizeName } from "./utils";
19
20
 
20
21
  export const { dependencies, devDependencies, peerDependencies, scripts, version } = packageJSON;
21
22
 
@@ -30,7 +31,7 @@ type peprPackageJSON = {
30
31
  uuid: string;
31
32
  onError: OnError;
32
33
  webhookTimeout: number;
33
- customLabels: { namespace: Record<string, string> };
34
+ customLabels: CustomLabels;
34
35
  alwaysIgnore: { namespaces: string[] };
35
36
  includedFiles: string[];
36
37
  env: object;
@@ -6,11 +6,11 @@ import admissionRequestDeletePod from "./data/admission-delete-pod.json";
6
6
  import admissionRequestCreateClusterRole from "./data/admission-create-clusterrole.json";
7
7
  import admissionRequestCreateDeployment from "./data/admission-create-deployment.json";
8
8
 
9
- export function AdmissionRequestCreateDeployment() {
9
+ export function AdmissionRequestCreateDeployment(): AdmissionRequest<kind.Deployment> {
10
10
  return cloneObject<kind.Deployment>(admissionRequestCreateDeployment);
11
11
  }
12
12
 
13
- export function AdmissionRequestCreatePod() {
13
+ export function AdmissionRequestCreatePod(): AdmissionRequest<kind.Pod> {
14
14
  return cloneObject<kind.Pod>(admissionRequestCreatePod);
15
15
  }
16
16