pepr 0.42.2 → 0.42.3
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.helpers.d.ts +1 -1
- package/dist/cli/build.helpers.d.ts.map +1 -1
- package/dist/cli.js +1492 -1478
- package/dist/controller.js +1 -1
- package/dist/lib/assets/assets.d.ts +27 -0
- package/dist/lib/assets/assets.d.ts.map +1 -0
- package/dist/lib/assets/deploy.d.ts +1 -1
- package/dist/lib/assets/deploy.d.ts.map +1 -1
- package/dist/lib/assets/index.d.ts +4 -23
- package/dist/lib/assets/index.d.ts.map +1 -1
- package/dist/lib/assets/pods.d.ts +1 -1
- package/dist/lib/assets/pods.d.ts.map +1 -1
- package/dist/lib/assets/webhooks.d.ts +1 -1
- package/dist/lib/assets/webhooks.d.ts.map +1 -1
- package/dist/lib/assets/yaml.d.ts +31 -5
- package/dist/lib/assets/yaml.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/cli/build.helpers.ts +1 -1
- package/src/cli/build.ts +1 -1
- package/src/cli/deploy.ts +1 -1
- package/src/cli/dev.ts +1 -1
- package/src/lib/assets/assets.ts +176 -0
- package/src/lib/assets/deploy.ts +1 -1
- package/src/lib/assets/index.ts +10 -144
- package/src/lib/assets/pods.ts +1 -1
- package/src/lib/assets/webhooks.ts +2 -11
- package/src/lib/assets/yaml.ts +47 -25
|
@@ -9,16 +9,10 @@ import {
|
|
|
9
9
|
import { kind } from "kubernetes-fluent-client";
|
|
10
10
|
import { concat, equals, uniqWith } from "ramda";
|
|
11
11
|
|
|
12
|
-
import { Assets } from "
|
|
12
|
+
import { Assets } from "./assets";
|
|
13
13
|
import { Event } from "../enums";
|
|
14
14
|
import { Binding } from "../types";
|
|
15
15
|
|
|
16
|
-
const peprIgnoreLabel: V1LabelSelectorRequirement = {
|
|
17
|
-
key: "pepr.dev",
|
|
18
|
-
operator: "NotIn",
|
|
19
|
-
values: ["ignore"],
|
|
20
|
-
};
|
|
21
|
-
|
|
22
16
|
const peprIgnoreNamespaces: string[] = ["kube-system", "pepr-system"];
|
|
23
17
|
|
|
24
18
|
const validateRule = (binding: Binding, isMutateWebhook: boolean): V1RuleWithOperations | undefined => {
|
|
@@ -64,7 +58,7 @@ export async function webhookConfig(
|
|
|
64
58
|
mutateOrValidate: "mutate" | "validate",
|
|
65
59
|
timeoutSeconds = 10,
|
|
66
60
|
): Promise<kind.MutatingWebhookConfiguration | kind.ValidatingWebhookConfiguration | null> {
|
|
67
|
-
const ignore = [
|
|
61
|
+
const ignore: V1LabelSelectorRequirement[] = [];
|
|
68
62
|
|
|
69
63
|
const { name, tls, config, apiToken, host } = assets;
|
|
70
64
|
const ignoreNS = concat(peprIgnoreNamespaces, config?.alwaysIgnore?.namespaces || []);
|
|
@@ -120,9 +114,6 @@ export async function webhookConfig(
|
|
|
120
114
|
namespaceSelector: {
|
|
121
115
|
matchExpressions: ignore,
|
|
122
116
|
},
|
|
123
|
-
objectSelector: {
|
|
124
|
-
matchExpressions: ignore,
|
|
125
|
-
},
|
|
126
117
|
rules,
|
|
127
118
|
// @todo: track side effects state
|
|
128
119
|
sideEffects: "None",
|
package/src/lib/assets/yaml.ts
CHANGED
|
@@ -1,19 +1,41 @@
|
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
2
|
// SPDX-FileCopyrightText: 2023-Present The Pepr Authors
|
|
3
3
|
|
|
4
|
-
import {
|
|
5
|
-
|
|
4
|
+
import {
|
|
5
|
+
dumpYaml,
|
|
6
|
+
V1Deployment,
|
|
7
|
+
V1MutatingWebhookConfiguration,
|
|
8
|
+
V1ValidatingWebhookConfiguration,
|
|
9
|
+
} from "@kubernetes/client-node";
|
|
6
10
|
import { promises as fs } from "fs";
|
|
7
|
-
import { Assets } from ".";
|
|
8
11
|
import { apiTokenSecret, service, tlsSecret, watcherService } from "./networking";
|
|
9
|
-
import {
|
|
12
|
+
import { getModuleSecret, getNamespace } from "./pods";
|
|
10
13
|
import { clusterRole, clusterRoleBinding, serviceAccount, storeRole, storeRoleBinding } from "./rbac";
|
|
11
|
-
import { webhookConfig } from "./webhooks";
|
|
12
14
|
import { genEnv } from "./pods";
|
|
15
|
+
import { ModuleConfig } from "../core/module";
|
|
16
|
+
import { CapabilityExport } from "../types";
|
|
17
|
+
import { TLSOut } from "../tls";
|
|
18
|
+
|
|
19
|
+
type CommonOverrideValues = {
|
|
20
|
+
apiToken: string;
|
|
21
|
+
capabilities: CapabilityExport[];
|
|
22
|
+
config: ModuleConfig;
|
|
23
|
+
hash: string;
|
|
24
|
+
name: string;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
type ChartOverrides = CommonOverrideValues & {
|
|
28
|
+
image: string;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
type ResourceOverrides = CommonOverrideValues & {
|
|
32
|
+
path: string;
|
|
33
|
+
tls: TLSOut;
|
|
34
|
+
};
|
|
13
35
|
|
|
14
36
|
// Helm Chart overrides file (values.yaml) generated from assets
|
|
15
37
|
export async function overridesFile(
|
|
16
|
-
{ hash, name, image, config, apiToken, capabilities }:
|
|
38
|
+
{ hash, name, image, config, apiToken, capabilities }: ChartOverrides,
|
|
17
39
|
path: string,
|
|
18
40
|
): Promise<void> {
|
|
19
41
|
const rbacOverrides = clusterRole(name, capabilities, config.rbacMode, config.rbac).rules;
|
|
@@ -169,7 +191,7 @@ export async function overridesFile(
|
|
|
169
191
|
|
|
170
192
|
await fs.writeFile(path, dumpYaml(overrides, { noRefs: true, forceQuotes: true }));
|
|
171
193
|
}
|
|
172
|
-
export function
|
|
194
|
+
export function generateZarfYaml(name: string, image: string, config: ModuleConfig, path: string): string {
|
|
173
195
|
const zarfCfg = {
|
|
174
196
|
kind: "ZarfPackageConfig",
|
|
175
197
|
metadata: {
|
|
@@ -197,7 +219,7 @@ export function zarfYaml({ name, image, config }: Assets, path: string): string
|
|
|
197
219
|
return dumpYaml(zarfCfg, { noRefs: true });
|
|
198
220
|
}
|
|
199
221
|
|
|
200
|
-
export function
|
|
222
|
+
export function generateZarfYamlChart(name: string, image: string, config: ModuleConfig, path: string): string {
|
|
201
223
|
const zarfCfg = {
|
|
202
224
|
kind: "ZarfPackageConfig",
|
|
203
225
|
metadata: {
|
|
@@ -226,16 +248,16 @@ export function zarfYamlChart({ name, image, config }: Assets, path: string): st
|
|
|
226
248
|
return dumpYaml(zarfCfg, { noRefs: true });
|
|
227
249
|
}
|
|
228
250
|
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
const code = await fs.readFile(path);
|
|
232
|
-
|
|
233
|
-
// Generate a hash of the code
|
|
234
|
-
assets.hash = crypto.createHash("sha256").update(code).digest("hex");
|
|
251
|
+
type webhooks = { validate: V1ValidatingWebhookConfiguration | null; mutate: V1MutatingWebhookConfiguration | null };
|
|
252
|
+
type deployments = { default: V1Deployment; watch: V1Deployment | null };
|
|
235
253
|
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
254
|
+
export async function generateAllYaml(
|
|
255
|
+
webhooks: webhooks,
|
|
256
|
+
deployments: deployments,
|
|
257
|
+
assets: ResourceOverrides,
|
|
258
|
+
): Promise<string> {
|
|
259
|
+
const { name, tls, hash, apiToken, path, config } = assets;
|
|
260
|
+
const code = await fs.readFile(path);
|
|
239
261
|
|
|
240
262
|
const resources = [
|
|
241
263
|
getNamespace(assets.config.customLabels?.namespace),
|
|
@@ -244,24 +266,24 @@ export async function allYaml(assets: Assets, imagePullSecret?: string): Promise
|
|
|
244
266
|
serviceAccount(name),
|
|
245
267
|
apiTokenSecret(name, apiToken),
|
|
246
268
|
tlsSecret(name, tls),
|
|
247
|
-
|
|
269
|
+
deployments.default,
|
|
248
270
|
service(name),
|
|
249
271
|
watcherService(name),
|
|
250
|
-
getModuleSecret(name, code,
|
|
272
|
+
getModuleSecret(name, code, hash),
|
|
251
273
|
storeRole(name),
|
|
252
274
|
storeRoleBinding(name),
|
|
253
275
|
];
|
|
254
276
|
|
|
255
|
-
if (
|
|
256
|
-
resources.push(
|
|
277
|
+
if (webhooks.mutate) {
|
|
278
|
+
resources.push(webhooks.mutate);
|
|
257
279
|
}
|
|
258
280
|
|
|
259
|
-
if (
|
|
260
|
-
resources.push(
|
|
281
|
+
if (webhooks.validate) {
|
|
282
|
+
resources.push(webhooks.validate);
|
|
261
283
|
}
|
|
262
284
|
|
|
263
|
-
if (
|
|
264
|
-
resources.push(
|
|
285
|
+
if (deployments.watch) {
|
|
286
|
+
resources.push(deployments.watch);
|
|
265
287
|
}
|
|
266
288
|
|
|
267
289
|
// Convert the resources to a single YAML string
|