pepr 0.48.1 → 0.49.0-nightly.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/build.d.ts.map +1 -1
- package/dist/cli/build.helpers.d.ts.map +1 -1
- package/dist/cli/crd/create.d.ts +11 -0
- package/dist/cli/crd/create.d.ts.map +1 -0
- package/dist/cli/crd/generate.d.ts +49 -0
- package/dist/cli/crd/generate.d.ts.map +1 -0
- package/dist/cli/crd/index.d.ts +3 -0
- package/dist/cli/crd/index.d.ts.map +1 -0
- package/dist/cli/crd/messages.d.ts +11 -0
- package/dist/cli/crd/messages.d.ts.map +1 -0
- package/dist/cli/init/templates.d.ts +1 -0
- package/dist/cli/init/templates.d.ts.map +1 -1
- package/dist/cli.js +7738 -66
- package/dist/controller.js +1 -1
- package/dist/lib/assets/assets.d.ts.map +1 -1
- package/dist/lib/assets/helm.d.ts +3 -1
- package/dist/lib/assets/helm.d.ts.map +1 -1
- package/dist/lib/assets/pods.d.ts.map +1 -1
- package/dist/lib/assets/yaml/generateZarfYaml.d.ts.map +1 -1
- package/dist/lib/assets/yaml/overridesFile.d.ts.map +1 -1
- package/dist/lib/controller/createHooks.d.ts +13 -0
- package/dist/lib/controller/createHooks.d.ts.map +1 -0
- package/dist/lib/core/module.d.ts.map +1 -1
- package/dist/lib.js +25 -17
- package/dist/lib.js.map +3 -3
- package/package.json +6 -5
- package/src/cli/build.helpers.ts +17 -12
- package/src/cli/build.ts +13 -2
- package/src/cli/crd/create.ts +134 -0
- package/src/cli/crd/generate.ts +318 -0
- package/src/cli/crd/index.ts +15 -0
- package/src/cli/crd/messages.ts +15 -0
- package/src/cli.ts +3 -0
- package/src/lib/assets/assets.ts +16 -2
- package/src/lib/assets/helm.ts +19 -6
- package/src/lib/assets/pods.ts +1 -2
- package/src/lib/assets/yaml/generateZarfYaml.ts +4 -3
- package/src/lib/assets/yaml/overridesFile.ts +1 -0
- package/src/lib/controller/createHooks.ts +34 -0
- package/src/lib/controller/index.ts +3 -3
- package/src/lib/core/module.ts +8 -20
package/src/lib/assets/helm.ts
CHANGED
|
@@ -179,6 +179,18 @@ export function admissionDeployTemplate(buildTimestamp: string): string {
|
|
|
179
179
|
app: {{ .Values.uuid }}
|
|
180
180
|
pepr.dev/controller: admission
|
|
181
181
|
spec:
|
|
182
|
+
{{- if .Values.admission.antiAffinity }}
|
|
183
|
+
affinity:
|
|
184
|
+
podAntiAffinity:
|
|
185
|
+
requiredDuringSchedulingIgnoredDuringExecution:
|
|
186
|
+
- labelSelector:
|
|
187
|
+
matchExpressions:
|
|
188
|
+
- key: pepr.dev/controller
|
|
189
|
+
operator: In
|
|
190
|
+
values:
|
|
191
|
+
- admission
|
|
192
|
+
topologyKey: "kubernetes.io/hostname"
|
|
193
|
+
{{- end }}
|
|
182
194
|
terminationGracePeriodSeconds: {{ .Values.admission.terminationGracePeriodSeconds }}
|
|
183
195
|
priorityClassName: system-node-critical
|
|
184
196
|
serviceAccountName: {{ .Values.uuid }}
|
|
@@ -245,22 +257,23 @@ export function admissionDeployTemplate(buildTimestamp: string): string {
|
|
|
245
257
|
{{- end }}
|
|
246
258
|
`;
|
|
247
259
|
}
|
|
248
|
-
|
|
249
|
-
export function serviceMonitorTemplate(name: string): string {
|
|
260
|
+
type ControllerType = "admission" | "watcher";
|
|
261
|
+
export function serviceMonitorTemplate(name: string, type: ControllerType): string {
|
|
250
262
|
return `
|
|
251
|
-
{{- if .Values.${
|
|
263
|
+
{{- if .Values.${type}.serviceMonitor.enabled }}
|
|
252
264
|
apiVersion: monitoring.coreos.com/v1
|
|
253
265
|
kind: ServiceMonitor
|
|
254
266
|
metadata:
|
|
255
267
|
name: ${name}
|
|
268
|
+
namespace: pepr-system
|
|
256
269
|
annotations:
|
|
257
|
-
{{- toYaml .Values.${
|
|
270
|
+
{{- toYaml .Values.${type}.serviceMonitor.annotations | nindent 4 }}
|
|
258
271
|
labels:
|
|
259
|
-
{{- toYaml .Values.${
|
|
272
|
+
{{- toYaml .Values.${type}.serviceMonitor.labels | nindent 4 }}
|
|
260
273
|
spec:
|
|
261
274
|
selector:
|
|
262
275
|
matchLabels:
|
|
263
|
-
pepr.dev/controller: ${
|
|
276
|
+
pepr.dev/controller: ${type}
|
|
264
277
|
namespaceSelector:
|
|
265
278
|
matchNames:
|
|
266
279
|
- pepr-system
|
package/src/lib/assets/pods.ts
CHANGED
|
@@ -348,8 +348,7 @@ export function getModuleSecret(name: string, data: Buffer, hash: string): kind.
|
|
|
348
348
|
const compressedData = compressed.toString("base64");
|
|
349
349
|
if (secretOverLimit(compressedData)) {
|
|
350
350
|
const error = new Error(`Module secret for ${name} is over the 1MB limit`);
|
|
351
|
-
|
|
352
|
-
process.exit(1);
|
|
351
|
+
throw error;
|
|
353
352
|
} else {
|
|
354
353
|
return {
|
|
355
354
|
apiVersion: "v1",
|
|
@@ -4,20 +4,21 @@ import { Assets } from "../assets";
|
|
|
4
4
|
type ConfigType = "manifests" | "charts";
|
|
5
5
|
|
|
6
6
|
export function generateZarfYamlGeneric(assets: Assets, path: string, type: ConfigType): string {
|
|
7
|
+
const zarfComponentName = process.env.PEPR_CUSTOM_BUILD_NAME ?? "module";
|
|
7
8
|
const manifestSettings = {
|
|
8
|
-
name:
|
|
9
|
+
name: zarfComponentName,
|
|
9
10
|
namespace: "pepr-system",
|
|
10
11
|
files: [path],
|
|
11
12
|
};
|
|
12
13
|
const chartSettings = {
|
|
13
|
-
name:
|
|
14
|
+
name: zarfComponentName,
|
|
14
15
|
namespace: "pepr-system",
|
|
15
16
|
version: `${assets.config.appVersion || "0.0.1"}`,
|
|
16
17
|
localPath: path,
|
|
17
18
|
};
|
|
18
19
|
|
|
19
20
|
const component = {
|
|
20
|
-
name:
|
|
21
|
+
name: zarfComponentName,
|
|
21
22
|
required: true,
|
|
22
23
|
images: [assets.image],
|
|
23
24
|
[type]: [type === "manifests" ? manifestSettings : chartSettings],
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { ControllerHooks } from ".";
|
|
2
|
+
import { resolveIgnoreNamespaces } from "../assets/webhooks";
|
|
3
|
+
import { Capability } from "../core/capability";
|
|
4
|
+
import { isWatchMode, isDevMode } from "../core/envChecks";
|
|
5
|
+
import { setupWatch } from "../processors/watch-processor";
|
|
6
|
+
import { PeprModuleOptions } from "../types";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Creates controller hooks with proper handling of watch setup
|
|
10
|
+
*
|
|
11
|
+
* @param opts Module options including hooks
|
|
12
|
+
* @param capabilities List of capabilities
|
|
13
|
+
* @param ignoreNamespaces Namespaces to ignore
|
|
14
|
+
* @returns Controller hooks configuration
|
|
15
|
+
*/
|
|
16
|
+
export function createControllerHooks(
|
|
17
|
+
opts: PeprModuleOptions,
|
|
18
|
+
capabilities: Capability[],
|
|
19
|
+
ignoreNamespaces: string[] = [],
|
|
20
|
+
): ControllerHooks {
|
|
21
|
+
return {
|
|
22
|
+
beforeHook: opts.beforeHook,
|
|
23
|
+
afterHook: opts.afterHook,
|
|
24
|
+
onReady: async (): Promise<void> => {
|
|
25
|
+
if (isWatchMode() || isDevMode()) {
|
|
26
|
+
try {
|
|
27
|
+
setupWatch(capabilities, resolveIgnoreNamespaces(ignoreNamespaces));
|
|
28
|
+
} catch (error) {
|
|
29
|
+
throw new Error(`WatchError: Could not set up watch.`, { cause: error });
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
}
|
|
@@ -132,10 +132,10 @@ export class Controller {
|
|
|
132
132
|
|
|
133
133
|
// Listen for the SIGTERM signal and gracefully close the server
|
|
134
134
|
process.on("SIGTERM", () => {
|
|
135
|
-
Log.info("Received SIGTERM, closing server");
|
|
135
|
+
Log.info("Received SIGTERM, closing server.");
|
|
136
136
|
server.close(() => {
|
|
137
|
-
Log.info("Server closed");
|
|
138
|
-
process.exit(
|
|
137
|
+
Log.info("Server closed.");
|
|
138
|
+
process.exit(143);
|
|
139
139
|
});
|
|
140
140
|
});
|
|
141
141
|
};
|
package/src/lib/core/module.ts
CHANGED
|
@@ -2,14 +2,12 @@
|
|
|
2
2
|
// SPDX-FileCopyrightText: 2023-Present The Pepr Authors
|
|
3
3
|
import { clone } from "ramda";
|
|
4
4
|
import { Capability } from "./capability";
|
|
5
|
-
import { Controller
|
|
5
|
+
import { Controller } from "../controller";
|
|
6
6
|
import { ValidateError } from "../errors";
|
|
7
7
|
import { CapabilityExport } from "../types";
|
|
8
|
-
import {
|
|
9
|
-
import Log from "../../lib/telemetry/logger";
|
|
10
|
-
import { resolveIgnoreNamespaces } from "../assets/webhooks";
|
|
11
|
-
import { isBuildMode, isDevMode, isWatchMode } from "./envChecks";
|
|
8
|
+
import { isBuildMode } from "./envChecks";
|
|
12
9
|
import { PackageJSON, PeprModuleOptions, ModuleConfig } from "../types";
|
|
10
|
+
import { createControllerHooks } from "../controller/createHooks";
|
|
13
11
|
|
|
14
12
|
export class PeprModule {
|
|
15
13
|
#controller!: Controller;
|
|
@@ -59,21 +57,11 @@ export class PeprModule {
|
|
|
59
57
|
return;
|
|
60
58
|
}
|
|
61
59
|
|
|
62
|
-
const controllerHooks
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
if (isWatchMode() || isDevMode()) {
|
|
68
|
-
try {
|
|
69
|
-
setupWatch(capabilities, resolveIgnoreNamespaces(pepr?.alwaysIgnore?.namespaces));
|
|
70
|
-
} catch (e) {
|
|
71
|
-
Log.error(e, "Error setting up watch");
|
|
72
|
-
process.exit(1);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
},
|
|
76
|
-
};
|
|
60
|
+
const controllerHooks = createControllerHooks(
|
|
61
|
+
opts,
|
|
62
|
+
capabilities,
|
|
63
|
+
pepr?.alwaysIgnore?.namespaces,
|
|
64
|
+
);
|
|
77
65
|
|
|
78
66
|
this.#controller = new Controller(config, capabilities, controllerHooks);
|
|
79
67
|
|