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
package/dist/controller.js
CHANGED
|
@@ -51,7 +51,7 @@ if (process.env.LOG_LEVEL) {
|
|
|
51
51
|
var logger_default = Log;
|
|
52
52
|
|
|
53
53
|
// src/templates/data.json
|
|
54
|
-
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", "!dist/**/*.test.d.ts*"], version: "0.42.
|
|
54
|
+
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", "!dist/**/*.test.d.ts*"], version: "0.42.3", main: "dist/lib.js", types: "dist/lib.d.ts", scripts: { ci: "npm ci", "gen-data-json": "node hack/build-template-data.js", prebuild: "rm -fr dist/* && npm run gen-data-json", version: "node scripts/set-version.js", build: "tsc && node build.mjs && npm pack", "build:image": "npm run build && docker buildx build --output type=docker --tag pepr:dev .", test: "npm run test:unit && npm run test:journey", "test:unit": "npm run gen-data-json && jest src --coverage --detectOpenHandles --coverageDirectory=./coverage --testPathIgnorePatterns='cosign.e2e.test.ts'", "test:journey": "npm run test:journey:k3d && npm run build && npm run test:journey:image && npm run test:journey:run", "test:journey:prep": "if [ ! -d ./pepr-upgrade-test ]; then git clone https://github.com/defenseunicorns/pepr-upgrade-test.git ; fi", "test:journey-wasm": "npm run test:journey:k3d && npm run build && npm run test:journey:image && npm run test:journey:run-wasm", "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:image": "docker buildx build --output type=docker --tag pepr:dev . && k3d image import pepr:dev -c pepr-dev", "test:journey:run": "jest --detectOpenHandles journey/entrypoint.test.ts && npm run test:journey:prep && npm run test:journey:upgrade", "test:journey:run-wasm": "jest --detectOpenHandles journey/entrypoint-wasm.test.ts", "test:journey:upgrade": "npm run test:journey:k3d && npm run test:journey:image && jest --detectOpenHandles journey/pepr-upgrade.test.ts", "format:check": "eslint src && prettier src --check", "format:fix": "eslint src --fix && prettier src --write", prepare: `if [ "$NODE_ENV" != 'production' ]; then husky; fi` }, dependencies: { "@types/ramda": "0.30.2", express: "4.21.2", "fast-json-patch": "3.1.1", "follow-redirects": "1.15.9", "http-status-codes": "^2.3.0", "json-pointer": "^0.6.2", "kubernetes-fluent-client": "3.3.7", pino: "9.6.0", "pino-pretty": "13.0.0", "prom-client": "15.1.3", ramda: "0.30.1", sigstore: "3.0.0" }, devDependencies: { "@commitlint/cli": "19.6.1", "@commitlint/config-conventional": "19.6.0", "@fast-check/jest": "^2.0.1", "@jest/globals": "29.7.0", "@types/eslint": "9.6.1", "@types/express": "5.0.0", "@types/follow-redirects": "1.14.4", "@types/json-pointer": "^1.0.34", "@types/node": "22.x.x", "@types/node-forge": "1.3.11", "@types/uuid": "10.0.0", "fast-check": "^3.19.0", husky: "^9.1.6", jest: "29.7.0", "js-yaml": "^4.1.0", "ts-jest": "29.2.5", undici: "^7.0.1" }, peerDependencies: { "@typescript-eslint/eslint-plugin": "7.18.0", "@typescript-eslint/parser": "7.18.0", "@types/prompts": "2.4.9", eslint: "8.57.0", commander: "12.1.0", esbuild: "0.24.0", "node-forge": "1.3.1", prettier: "3.4.2", prompts: "2.4.2", typescript: "^5.3.3", uuid: "11.0.3" } };
|
|
55
55
|
|
|
56
56
|
// src/lib/k8s.ts
|
|
57
57
|
var import_kubernetes_fluent_client = require("kubernetes-fluent-client");
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { CapabilityExport } from "../types";
|
|
2
|
+
import { ModuleConfig } from "../core/module";
|
|
3
|
+
import { TLSOut } from "../tls";
|
|
4
|
+
import { WebhookIgnore } from "../k8s";
|
|
5
|
+
import { V1MutatingWebhookConfiguration, V1ValidatingWebhookConfiguration } from "@kubernetes/client-node/dist/gen";
|
|
6
|
+
export declare class Assets {
|
|
7
|
+
readonly config: ModuleConfig;
|
|
8
|
+
readonly path: string;
|
|
9
|
+
readonly host?: string | undefined;
|
|
10
|
+
readonly name: string;
|
|
11
|
+
readonly tls: TLSOut;
|
|
12
|
+
readonly apiToken: string;
|
|
13
|
+
readonly alwaysIgnore: WebhookIgnore;
|
|
14
|
+
capabilities: CapabilityExport[];
|
|
15
|
+
image: string;
|
|
16
|
+
buildTimestamp: string;
|
|
17
|
+
hash: string;
|
|
18
|
+
constructor(config: ModuleConfig, path: string, host?: string | undefined);
|
|
19
|
+
setHash: (hash: string) => void;
|
|
20
|
+
deploy: (force: boolean, webhookTimeout?: number) => Promise<void>;
|
|
21
|
+
zarfYaml: (path: string) => string;
|
|
22
|
+
zarfYamlChart: (path: string) => string;
|
|
23
|
+
allYaml: (imagePullSecret?: string) => Promise<string>;
|
|
24
|
+
writeWebhookFiles: (validateWebhook: V1MutatingWebhookConfiguration | V1ValidatingWebhookConfiguration | null, mutateWebhook: V1MutatingWebhookConfiguration | V1ValidatingWebhookConfiguration | null, helm: Record<string, Record<string, string>>) => Promise<void>;
|
|
25
|
+
generateHelmChart: (basePath: string) => Promise<void>;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=assets.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assets.d.ts","sourceRoot":"","sources":["../../../src/lib/assets/assets.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAU,MAAM,QAAQ,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAoBvC,OAAO,EAAE,8BAA8B,EAAE,gCAAgC,EAAE,MAAM,kCAAkC,CAAC;AAEpH,qBAAa,MAAM;IAYf,QAAQ,CAAC,MAAM,EAAE,YAAY;IAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM;IACrB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM;IAbxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,YAAY,EAAG,aAAa,CAAC;IACtC,YAAY,EAAG,gBAAgB,EAAE,CAAC;IAElC,KAAK,EAAE,MAAM,CAAC;IACd,cAAc,EAAE,MAAM,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;gBAGF,MAAM,EAAE,YAAY,EACpB,IAAI,EAAE,MAAM,EACZ,IAAI,CAAC,EAAE,MAAM,YAAA;IAcxB,OAAO,SAAU,MAAM,KAAG,IAAI,CAE5B;IAEF,MAAM,UAAiB,OAAO,mBAAmB,MAAM,KAAG,OAAO,CAAC,IAAI,CAAC,CAGrE;IAEF,QAAQ,SAAU,MAAM,KAAG,MAAM,CAA+D;IAEhG,aAAa,SAAU,MAAM,KAAG,MAAM,CAAoE;IAE1G,OAAO,qBAA4B,MAAM,KAAG,OAAO,CAAC,MAAM,CAAC,CAgCzD;IAEF,iBAAiB,oBACE,8BAA8B,GAAG,gCAAgC,GAAG,IAAI,iBAC1E,8BAA8B,GAAG,gCAAgC,GAAG,IAAI,QACjF,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,KAC3C,OAAO,CAAC,IAAI,CAAC,CAad;IAEF,iBAAiB,aAAoB,MAAM,KAAG,OAAO,CAAC,IAAI,CAAC,CAsDzD;CACH"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Assets } from "
|
|
1
|
+
import { Assets } from "./assets";
|
|
2
2
|
import { ImagePullSecret } from "../types";
|
|
3
3
|
export declare function deployImagePullSecret(imagePullSecret: ImagePullSecret, name: string): Promise<void>;
|
|
4
4
|
export declare function deploy(assets: Assets, force: boolean, webhookTimeout?: number): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../../src/lib/assets/deploy.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,MAAM,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../../src/lib/assets/deploy.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAOlC,OAAO,EAAoB,eAAe,EAAE,MAAM,UAAU,CAAC;AAE7D,wBAAsB,qBAAqB,CAAC,eAAe,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CA0BzG;AACD,wBAAsB,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,cAAc,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CA8CnG"}
|
|
@@ -1,25 +1,6 @@
|
|
|
1
|
+
import { kind } from "kubernetes-fluent-client";
|
|
1
2
|
import { ModuleConfig } from "../core/module";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export declare class Assets {
|
|
6
|
-
readonly config: ModuleConfig;
|
|
7
|
-
readonly path: string;
|
|
8
|
-
readonly host?: string | undefined;
|
|
9
|
-
readonly name: string;
|
|
10
|
-
readonly tls: TLSOut;
|
|
11
|
-
readonly apiToken: string;
|
|
12
|
-
readonly alwaysIgnore: WebhookIgnore;
|
|
13
|
-
capabilities: CapabilityExport[];
|
|
14
|
-
image: string;
|
|
15
|
-
buildTimestamp: string;
|
|
16
|
-
hash: string;
|
|
17
|
-
constructor(config: ModuleConfig, path: string, host?: string | undefined);
|
|
18
|
-
setHash: (hash: string) => void;
|
|
19
|
-
deploy: (force: boolean, webhookTimeout?: number) => Promise<void>;
|
|
20
|
-
zarfYaml: (path: string) => string;
|
|
21
|
-
zarfYamlChart: (path: string) => string;
|
|
22
|
-
allYaml: (imagePullSecret?: string) => Promise<string>;
|
|
23
|
-
generateHelmChart: (basePath: string) => Promise<void>;
|
|
24
|
-
}
|
|
3
|
+
export declare function toYaml(obj: any): string;
|
|
4
|
+
export declare function createWebhookYaml(name: string, config: ModuleConfig, webhookConfiguration: kind.MutatingWebhookConfiguration | kind.ValidatingWebhookConfiguration): string;
|
|
5
|
+
export declare function helmLayout(basePath: string, unique: string): Record<string, Record<string, string>>;
|
|
25
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/assets/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/assets/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAGhD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAG9C,wBAAgB,MAAM,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM,CAEvC;AAED,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,YAAY,EACpB,oBAAoB,EAAE,IAAI,CAAC,4BAA4B,GAAG,IAAI,CAAC,8BAA8B,GAC5F,MAAM,CAWR;AAED,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAsCnG"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { KubernetesObject, V1EnvVar } from "@kubernetes/client-node";
|
|
2
2
|
import { kind } from "kubernetes-fluent-client";
|
|
3
|
-
import { Assets } from "
|
|
3
|
+
import { Assets } from "./assets";
|
|
4
4
|
import { ModuleConfig } from "../core/module";
|
|
5
5
|
/** Generate the pepr-system namespace */
|
|
6
6
|
export declare function getNamespace(namespaceLabels?: Record<string, string>): KubernetesObject;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pods.d.ts","sourceRoot":"","sources":["../../../src/lib/assets/pods.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACrE,OAAO,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAGhD,OAAO,EAAE,MAAM,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"pods.d.ts","sourceRoot":"","sources":["../../../src/lib/assets/pods.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACrE,OAAO,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAGhD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAG9C,yCAAyC;AACzC,wBAAgB,YAAY,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,gBAAgB,CAmBvF;AAED,wBAAgB,UAAU,CACxB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,cAAc,EAAE,MAAM,EACtB,eAAe,CAAC,EAAE,MAAM,GACvB,IAAI,CAAC,UAAU,GAAG,IAAI,CAyJxB;AAED,wBAAgB,aAAa,CAC3B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,cAAc,EAAE,MAAM,EACtB,eAAe,CAAC,EAAE,MAAM,GACvB,IAAI,CAAC,UAAU,CA+IjB;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC,MAAM,CAuBrF;AAED,wBAAgB,MAAM,CAAC,MAAM,EAAE,YAAY,EAAE,SAAS,UAAQ,EAAE,eAAe,UAAQ,GAAG,QAAQ,EAAE,CAkBnG"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { V1RuleWithOperations } from "@kubernetes/client-node";
|
|
2
2
|
import { kind } from "kubernetes-fluent-client";
|
|
3
|
-
import { Assets } from "
|
|
3
|
+
import { Assets } from "./assets";
|
|
4
4
|
export declare function generateWebhookRules(assets: Assets, isMutateWebhook: boolean): Promise<V1RuleWithOperations[]>;
|
|
5
5
|
export declare function webhookConfig(assets: Assets, mutateOrValidate: "mutate" | "validate", timeoutSeconds?: number): Promise<kind.MutatingWebhookConfiguration | kind.ValidatingWebhookConfiguration | null>;
|
|
6
6
|
//# sourceMappingURL=webhooks.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webhooks.d.ts","sourceRoot":"","sources":["../../../src/lib/assets/webhooks.ts"],"names":[],"mappings":"AAGA,OAAO,EAGL,oBAAoB,EACrB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAGhD,OAAO,EAAE,MAAM,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"webhooks.d.ts","sourceRoot":"","sources":["../../../src/lib/assets/webhooks.ts"],"names":[],"mappings":"AAGA,OAAO,EAGL,oBAAoB,EACrB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAGhD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AA8BlC,wBAAsB,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,eAAe,EAAE,OAAO,GAAG,OAAO,CAAC,oBAAoB,EAAE,CAAC,CAYpH;AAED,wBAAsB,aAAa,CACjC,MAAM,EAAE,MAAM,EACd,gBAAgB,EAAE,QAAQ,GAAG,UAAU,EACvC,cAAc,SAAK,GAClB,OAAO,CAAC,IAAI,CAAC,4BAA4B,GAAG,IAAI,CAAC,8BAA8B,GAAG,IAAI,CAAC,CA+DzF"}
|
|
@@ -1,6 +1,32 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { V1Deployment, V1MutatingWebhookConfiguration, V1ValidatingWebhookConfiguration } from "@kubernetes/client-node";
|
|
2
|
+
import { ModuleConfig } from "../core/module";
|
|
3
|
+
import { CapabilityExport } from "../types";
|
|
4
|
+
import { TLSOut } from "../tls";
|
|
5
|
+
type CommonOverrideValues = {
|
|
6
|
+
apiToken: string;
|
|
7
|
+
capabilities: CapabilityExport[];
|
|
8
|
+
config: ModuleConfig;
|
|
9
|
+
hash: string;
|
|
10
|
+
name: string;
|
|
11
|
+
};
|
|
12
|
+
type ChartOverrides = CommonOverrideValues & {
|
|
13
|
+
image: string;
|
|
14
|
+
};
|
|
15
|
+
type ResourceOverrides = CommonOverrideValues & {
|
|
16
|
+
path: string;
|
|
17
|
+
tls: TLSOut;
|
|
18
|
+
};
|
|
19
|
+
export declare function overridesFile({ hash, name, image, config, apiToken, capabilities }: ChartOverrides, path: string): Promise<void>;
|
|
20
|
+
export declare function generateZarfYaml(name: string, image: string, config: ModuleConfig, path: string): string;
|
|
21
|
+
export declare function generateZarfYamlChart(name: string, image: string, config: ModuleConfig, path: string): string;
|
|
22
|
+
type webhooks = {
|
|
23
|
+
validate: V1ValidatingWebhookConfiguration | null;
|
|
24
|
+
mutate: V1MutatingWebhookConfiguration | null;
|
|
25
|
+
};
|
|
26
|
+
type deployments = {
|
|
27
|
+
default: V1Deployment;
|
|
28
|
+
watch: V1Deployment | null;
|
|
29
|
+
};
|
|
30
|
+
export declare function generateAllYaml(webhooks: webhooks, deployments: deployments, assets: ResourceOverrides): Promise<string>;
|
|
31
|
+
export {};
|
|
6
32
|
//# sourceMappingURL=yaml.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"yaml.d.ts","sourceRoot":"","sources":["../../../src/lib/assets/yaml.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"yaml.d.ts","sourceRoot":"","sources":["../../../src/lib/assets/yaml.ts"],"names":[],"mappings":"AAGA,OAAO,EAEL,YAAY,EACZ,8BAA8B,EAC9B,gCAAgC,EACjC,MAAM,yBAAyB,CAAC;AAMjC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,KAAK,oBAAoB,GAAG;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,gBAAgB,EAAE,CAAC;IACjC,MAAM,EAAE,YAAY,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,KAAK,cAAc,GAAG,oBAAoB,GAAG;IAC3C,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,KAAK,iBAAiB,GAAG,oBAAoB,GAAG;IAC9C,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAGF,wBAAsB,aAAa,CACjC,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,EAAE,EAAE,cAAc,EACrE,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,IAAI,CAAC,CAyJf;AACD,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CA0BxG;AAED,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CA2B7G;AAED,KAAK,QAAQ,GAAG;IAAE,QAAQ,EAAE,gCAAgC,GAAG,IAAI,CAAC;IAAC,MAAM,EAAE,8BAA8B,GAAG,IAAI,CAAA;CAAE,CAAC;AACrH,KAAK,WAAW,GAAG;IAAE,OAAO,EAAE,YAAY,CAAC;IAAC,KAAK,EAAE,YAAY,GAAG,IAAI,CAAA;CAAE,CAAC;AAEzE,wBAAsB,eAAe,CACnC,QAAQ,EAAE,QAAQ,EAClB,WAAW,EAAE,WAAW,EACxB,MAAM,EAAE,iBAAiB,GACxB,OAAO,CAAC,MAAM,CAAC,CAiCjB"}
|
package/package.json
CHANGED
package/src/cli/build.helpers.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { execSync } from "child_process";
|
|
|
5
5
|
import { CapabilityExport } from "../lib/types";
|
|
6
6
|
import { validateCapabilityNames } from "../lib/helpers";
|
|
7
7
|
import { BuildOptions, BuildResult, context, BuildContext } from "esbuild";
|
|
8
|
-
import { Assets } from "../lib/assets";
|
|
8
|
+
import { Assets } from "../lib/assets/assets";
|
|
9
9
|
import { resolve } from "path";
|
|
10
10
|
import { promises as fs } from "fs";
|
|
11
11
|
|
package/src/cli/build.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { execFileSync } from "child_process";
|
|
|
5
5
|
import { BuildOptions, BuildResult, analyzeMetafile } from "esbuild";
|
|
6
6
|
import { promises as fs } from "fs";
|
|
7
7
|
import { basename, dirname, extname, resolve } from "path";
|
|
8
|
-
import { Assets } from "../lib/assets";
|
|
8
|
+
import { Assets } from "../lib/assets/assets";
|
|
9
9
|
import { dependencies, version } from "./init/templates";
|
|
10
10
|
import { RootCmd } from "./root";
|
|
11
11
|
import { Option } from "commander";
|
package/src/cli/deploy.ts
CHANGED
package/src/cli/dev.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { ChildProcess, fork } from "child_process";
|
|
|
5
5
|
import { promises as fs } from "fs";
|
|
6
6
|
import prompt from "prompts";
|
|
7
7
|
import { validateCapabilityNames } from "../lib/helpers";
|
|
8
|
-
import { Assets } from "../lib/assets";
|
|
8
|
+
import { Assets } from "../lib/assets/assets";
|
|
9
9
|
import { buildModule, loadModule } from "./build";
|
|
10
10
|
import { RootCmd } from "./root";
|
|
11
11
|
import { K8s, kind } from "kubernetes-fluent-client";
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import crypto from "crypto";
|
|
2
|
+
import { CapabilityExport } from "../types";
|
|
3
|
+
import { ModuleConfig } from "../core/module";
|
|
4
|
+
import { TLSOut, genTLS } from "../tls";
|
|
5
|
+
import { WebhookIgnore } from "../k8s";
|
|
6
|
+
import {
|
|
7
|
+
chartYaml,
|
|
8
|
+
namespaceTemplate,
|
|
9
|
+
clusterRoleTemplate,
|
|
10
|
+
admissionDeployTemplate,
|
|
11
|
+
serviceMonitorTemplate,
|
|
12
|
+
watcherDeployTemplate,
|
|
13
|
+
} from "./helm";
|
|
14
|
+
import { createDirectoryIfNotExists } from "../filesystemService";
|
|
15
|
+
import { deploy } from "./deploy";
|
|
16
|
+
import { getDeployment, getModuleSecret, getWatcher } from "./pods";
|
|
17
|
+
import { helmLayout, createWebhookYaml, toYaml } from "./index";
|
|
18
|
+
import { loadCapabilities } from "./loader";
|
|
19
|
+
import { namespaceComplianceValidator, dedent } from "../helpers";
|
|
20
|
+
import { storeRole, storeRoleBinding, clusterRoleBinding, serviceAccount } from "./rbac";
|
|
21
|
+
import { watcherService, service, tlsSecret, apiTokenSecret } from "./networking";
|
|
22
|
+
import { webhookConfig } from "./webhooks";
|
|
23
|
+
import { generateZarfYaml, generateZarfYamlChart, generateAllYaml, overridesFile } from "./yaml";
|
|
24
|
+
import { promises as fs } from "fs";
|
|
25
|
+
import { V1MutatingWebhookConfiguration, V1ValidatingWebhookConfiguration } from "@kubernetes/client-node/dist/gen";
|
|
26
|
+
|
|
27
|
+
export class Assets {
|
|
28
|
+
readonly name: string;
|
|
29
|
+
readonly tls: TLSOut;
|
|
30
|
+
readonly apiToken: string;
|
|
31
|
+
readonly alwaysIgnore!: WebhookIgnore;
|
|
32
|
+
capabilities!: CapabilityExport[];
|
|
33
|
+
|
|
34
|
+
image: string;
|
|
35
|
+
buildTimestamp: string;
|
|
36
|
+
hash: string;
|
|
37
|
+
|
|
38
|
+
constructor(
|
|
39
|
+
readonly config: ModuleConfig,
|
|
40
|
+
readonly path: string,
|
|
41
|
+
readonly host?: string,
|
|
42
|
+
) {
|
|
43
|
+
this.name = `pepr-${config.uuid}`;
|
|
44
|
+
this.buildTimestamp = `${Date.now()}`;
|
|
45
|
+
this.alwaysIgnore = config.alwaysIgnore;
|
|
46
|
+
this.image = `ghcr.io/defenseunicorns/pepr/controller:v${config.peprVersion}`;
|
|
47
|
+
this.hash = "";
|
|
48
|
+
// Generate the ephemeral tls things
|
|
49
|
+
this.tls = genTLS(this.host || `${this.name}.pepr-system.svc`);
|
|
50
|
+
|
|
51
|
+
// Generate the api token for the controller / webhook
|
|
52
|
+
this.apiToken = crypto.randomBytes(32).toString("hex");
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
setHash = (hash: string): void => {
|
|
56
|
+
this.hash = hash;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
deploy = async (force: boolean, webhookTimeout?: number): Promise<void> => {
|
|
60
|
+
this.capabilities = await loadCapabilities(this.path);
|
|
61
|
+
await deploy(this, force, webhookTimeout);
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
zarfYaml = (path: string): string => generateZarfYaml(this.name, this.image, this.config, path);
|
|
65
|
+
|
|
66
|
+
zarfYamlChart = (path: string): string => generateZarfYamlChart(this.name, this.image, this.config, path);
|
|
67
|
+
|
|
68
|
+
allYaml = async (imagePullSecret?: string): Promise<string> => {
|
|
69
|
+
this.capabilities = await loadCapabilities(this.path);
|
|
70
|
+
// give error if namespaces are not respected
|
|
71
|
+
for (const capability of this.capabilities) {
|
|
72
|
+
namespaceComplianceValidator(capability, this.alwaysIgnore?.namespaces);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const webhooks = {
|
|
76
|
+
mutate: await webhookConfig(this, "mutate", this.config.webhookTimeout),
|
|
77
|
+
validate: await webhookConfig(this, "validate", this.config.webhookTimeout),
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
const code = await fs.readFile(this.path);
|
|
81
|
+
|
|
82
|
+
// Generate a hash of the code
|
|
83
|
+
this.hash = crypto.createHash("sha256").update(code).digest("hex");
|
|
84
|
+
|
|
85
|
+
const deployments = {
|
|
86
|
+
default: getDeployment(this, this.hash, this.buildTimestamp, imagePullSecret),
|
|
87
|
+
watch: getWatcher(this, this.hash, this.buildTimestamp, imagePullSecret),
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
const assetsInputs = {
|
|
91
|
+
apiToken: this.apiToken,
|
|
92
|
+
capabilities: this.capabilities,
|
|
93
|
+
config: this.config,
|
|
94
|
+
hash: this.hash,
|
|
95
|
+
name: this.name,
|
|
96
|
+
path: this.path,
|
|
97
|
+
tls: this.tls,
|
|
98
|
+
};
|
|
99
|
+
return generateAllYaml(webhooks, deployments, assetsInputs);
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
writeWebhookFiles = async (
|
|
103
|
+
validateWebhook: V1MutatingWebhookConfiguration | V1ValidatingWebhookConfiguration | null,
|
|
104
|
+
mutateWebhook: V1MutatingWebhookConfiguration | V1ValidatingWebhookConfiguration | null,
|
|
105
|
+
helm: Record<string, Record<string, string>>,
|
|
106
|
+
): Promise<void> => {
|
|
107
|
+
if (validateWebhook || mutateWebhook) {
|
|
108
|
+
await fs.writeFile(helm.files.admissionDeploymentYaml, dedent(admissionDeployTemplate(this.buildTimestamp)));
|
|
109
|
+
await fs.writeFile(helm.files.admissionServiceMonitorYaml, dedent(serviceMonitorTemplate("admission")));
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (mutateWebhook) {
|
|
113
|
+
await fs.writeFile(helm.files.mutationWebhookYaml, createWebhookYaml(this.name, this.config, mutateWebhook));
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if (validateWebhook) {
|
|
117
|
+
await fs.writeFile(helm.files.validationWebhookYaml, createWebhookYaml(this.name, this.config, validateWebhook));
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
generateHelmChart = async (basePath: string): Promise<void> => {
|
|
122
|
+
const helm = helmLayout(basePath, this.config.uuid);
|
|
123
|
+
|
|
124
|
+
try {
|
|
125
|
+
await Promise.all(
|
|
126
|
+
Object.values(helm.dirs)
|
|
127
|
+
.sort((l, r) => l.split("/").length - r.split("/").length)
|
|
128
|
+
.map(async dir => await createDirectoryIfNotExists(dir)),
|
|
129
|
+
);
|
|
130
|
+
|
|
131
|
+
const code = await fs.readFile(this.path);
|
|
132
|
+
|
|
133
|
+
const pairs: [string, () => string][] = [
|
|
134
|
+
[helm.files.chartYaml, (): string => dedent(chartYaml(this.config.uuid, this.config.description || ""))],
|
|
135
|
+
[helm.files.namespaceYaml, (): string => dedent(namespaceTemplate())],
|
|
136
|
+
[helm.files.watcherServiceYaml, (): string => toYaml(watcherService(this.name))],
|
|
137
|
+
[helm.files.admissionServiceYaml, (): string => toYaml(service(this.name))],
|
|
138
|
+
[helm.files.tlsSecretYaml, (): string => toYaml(tlsSecret(this.name, this.tls))],
|
|
139
|
+
[helm.files.apiTokenSecretYaml, (): string => toYaml(apiTokenSecret(this.name, this.apiToken))],
|
|
140
|
+
[helm.files.storeRoleYaml, (): string => toYaml(storeRole(this.name))],
|
|
141
|
+
[helm.files.storeRoleBindingYaml, (): string => toYaml(storeRoleBinding(this.name))],
|
|
142
|
+
[helm.files.clusterRoleYaml, (): string => dedent(clusterRoleTemplate())],
|
|
143
|
+
[helm.files.clusterRoleBindingYaml, (): string => toYaml(clusterRoleBinding(this.name))],
|
|
144
|
+
[helm.files.serviceAccountYaml, (): string => toYaml(serviceAccount(this.name))],
|
|
145
|
+
[helm.files.moduleSecretYaml, (): string => toYaml(getModuleSecret(this.name, code, this.hash))],
|
|
146
|
+
];
|
|
147
|
+
await Promise.all(pairs.map(async ([file, content]) => await fs.writeFile(file, content())));
|
|
148
|
+
|
|
149
|
+
const overrideData = {
|
|
150
|
+
hash: this.hash,
|
|
151
|
+
name: this.name,
|
|
152
|
+
image: this.image,
|
|
153
|
+
config: this.config,
|
|
154
|
+
apiToken: this.apiToken,
|
|
155
|
+
capabilities: this.capabilities,
|
|
156
|
+
};
|
|
157
|
+
await overridesFile(overrideData, helm.files.valuesYaml);
|
|
158
|
+
|
|
159
|
+
const [mutateWebhook, validateWebhook] = await Promise.all([
|
|
160
|
+
webhookConfig(this, "mutate", this.config.webhookTimeout),
|
|
161
|
+
webhookConfig(this, "validate", this.config.webhookTimeout),
|
|
162
|
+
]);
|
|
163
|
+
|
|
164
|
+
await this.writeWebhookFiles(validateWebhook, mutateWebhook, helm);
|
|
165
|
+
|
|
166
|
+
const watchDeployment = getWatcher(this, this.hash, this.buildTimestamp);
|
|
167
|
+
if (watchDeployment) {
|
|
168
|
+
await fs.writeFile(helm.files.watcherDeploymentYaml, dedent(watcherDeployTemplate(this.buildTimestamp)));
|
|
169
|
+
await fs.writeFile(helm.files.watcherServiceMonitorYaml, dedent(serviceMonitorTemplate("watcher")));
|
|
170
|
+
}
|
|
171
|
+
} catch (err) {
|
|
172
|
+
console.error(`Error generating helm chart: ${err.message}`);
|
|
173
|
+
process.exit(1);
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
}
|
package/src/lib/assets/deploy.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { promises as fs } from "fs";
|
|
|
6
6
|
import { K8s, kind } from "kubernetes-fluent-client";
|
|
7
7
|
import { V1PolicyRule as PolicyRule } from "@kubernetes/client-node";
|
|
8
8
|
|
|
9
|
-
import { Assets } from "
|
|
9
|
+
import { Assets } from "./assets";
|
|
10
10
|
import Log from "../telemetry/logger";
|
|
11
11
|
import { apiTokenSecret, service, tlsSecret, watcherService } from "./networking";
|
|
12
12
|
import { getDeployment, getModuleSecret, getNamespace, getWatcher } from "./pods";
|
package/src/lib/assets/index.ts
CHANGED
|
@@ -1,57 +1,35 @@
|
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
2
|
// SPDX-FileCopyrightText: 2023-Present The Pepr Authors
|
|
3
3
|
|
|
4
|
-
import crypto from "crypto";
|
|
5
4
|
import { dumpYaml } from "@kubernetes/client-node";
|
|
6
5
|
import { kind } from "kubernetes-fluent-client";
|
|
7
|
-
import {
|
|
8
|
-
import { TLSOut, genTLS } from "../tls";
|
|
9
|
-
import { CapabilityExport } from "../types";
|
|
10
|
-
import { WebhookIgnore } from "../k8s";
|
|
11
|
-
import { deploy } from "./deploy";
|
|
12
|
-
import { loadCapabilities } from "./loader";
|
|
13
|
-
import { allYaml, zarfYaml, overridesFile, zarfYamlChart } from "./yaml";
|
|
14
|
-
import { namespaceComplianceValidator, replaceString } from "../helpers";
|
|
15
|
-
import { dedent } from "../helpers";
|
|
6
|
+
import { replaceString } from "../helpers";
|
|
16
7
|
import { resolve } from "path";
|
|
17
|
-
import {
|
|
18
|
-
chartYaml,
|
|
19
|
-
namespaceTemplate,
|
|
20
|
-
admissionDeployTemplate,
|
|
21
|
-
watcherDeployTemplate,
|
|
22
|
-
clusterRoleTemplate,
|
|
23
|
-
serviceMonitorTemplate,
|
|
24
|
-
} from "./helm";
|
|
25
|
-
import { promises as fs } from "fs";
|
|
26
|
-
import { webhookConfig } from "./webhooks";
|
|
27
|
-
import { apiTokenSecret, service, tlsSecret, watcherService } from "./networking";
|
|
28
|
-
import { getWatcher, getModuleSecret } from "./pods";
|
|
29
|
-
|
|
30
|
-
import { clusterRoleBinding, serviceAccount, storeRole, storeRoleBinding } from "./rbac";
|
|
31
|
-
import { createDirectoryIfNotExists } from "../filesystemService";
|
|
8
|
+
import { ModuleConfig } from "../core/module";
|
|
32
9
|
|
|
33
10
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
34
|
-
function toYaml(obj: any): string {
|
|
11
|
+
export function toYaml(obj: any): string {
|
|
35
12
|
return dumpYaml(obj, { noRefs: true });
|
|
36
13
|
}
|
|
37
14
|
|
|
38
|
-
function createWebhookYaml(
|
|
39
|
-
|
|
15
|
+
export function createWebhookYaml(
|
|
16
|
+
name: string,
|
|
17
|
+
config: ModuleConfig,
|
|
40
18
|
webhookConfiguration: kind.MutatingWebhookConfiguration | kind.ValidatingWebhookConfiguration,
|
|
41
19
|
): string {
|
|
42
20
|
const yaml = toYaml(webhookConfiguration);
|
|
43
21
|
return replaceString(
|
|
44
22
|
replaceString(
|
|
45
|
-
replaceString(yaml,
|
|
46
|
-
|
|
23
|
+
replaceString(yaml, name, "{{ .Values.uuid }}"),
|
|
24
|
+
config.onError === "reject" ? "Fail" : "Ignore",
|
|
47
25
|
"{{ .Values.admission.failurePolicy }}",
|
|
48
26
|
),
|
|
49
|
-
`${
|
|
27
|
+
`${config.webhookTimeout}` || "10",
|
|
50
28
|
"{{ .Values.admission.webhookTimeout }}",
|
|
51
29
|
);
|
|
52
30
|
}
|
|
53
31
|
|
|
54
|
-
function helmLayout(basePath: string, unique: string): Record<string, Record<string, string>> {
|
|
32
|
+
export function helmLayout(basePath: string, unique: string): Record<string, Record<string, string>> {
|
|
55
33
|
const helm: Record<string, Record<string, string>> = {
|
|
56
34
|
dirs: {
|
|
57
35
|
chart: resolve(`${basePath}/${unique}-chart`),
|
|
@@ -90,115 +68,3 @@ function helmLayout(basePath: string, unique: string): Record<string, Record<str
|
|
|
90
68
|
|
|
91
69
|
return helm;
|
|
92
70
|
}
|
|
93
|
-
|
|
94
|
-
export class Assets {
|
|
95
|
-
readonly name: string;
|
|
96
|
-
readonly tls: TLSOut;
|
|
97
|
-
readonly apiToken: string;
|
|
98
|
-
readonly alwaysIgnore!: WebhookIgnore;
|
|
99
|
-
capabilities!: CapabilityExport[];
|
|
100
|
-
|
|
101
|
-
image: string;
|
|
102
|
-
buildTimestamp: string;
|
|
103
|
-
hash: string;
|
|
104
|
-
|
|
105
|
-
constructor(
|
|
106
|
-
readonly config: ModuleConfig,
|
|
107
|
-
readonly path: string,
|
|
108
|
-
readonly host?: string,
|
|
109
|
-
) {
|
|
110
|
-
this.name = `pepr-${config.uuid}`;
|
|
111
|
-
this.buildTimestamp = `${Date.now()}`;
|
|
112
|
-
this.alwaysIgnore = config.alwaysIgnore;
|
|
113
|
-
this.image = `ghcr.io/defenseunicorns/pepr/controller:v${config.peprVersion}`;
|
|
114
|
-
this.hash = "";
|
|
115
|
-
// Generate the ephemeral tls things
|
|
116
|
-
this.tls = genTLS(this.host || `${this.name}.pepr-system.svc`);
|
|
117
|
-
|
|
118
|
-
// Generate the api token for the controller / webhook
|
|
119
|
-
this.apiToken = crypto.randomBytes(32).toString("hex");
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
setHash = (hash: string): void => {
|
|
123
|
-
this.hash = hash;
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
deploy = async (force: boolean, webhookTimeout?: number): Promise<void> => {
|
|
127
|
-
this.capabilities = await loadCapabilities(this.path);
|
|
128
|
-
await deploy(this, force, webhookTimeout);
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
zarfYaml = (path: string): string => zarfYaml(this, path);
|
|
132
|
-
|
|
133
|
-
zarfYamlChart = (path: string): string => zarfYamlChart(this, path);
|
|
134
|
-
|
|
135
|
-
allYaml = async (imagePullSecret?: string): Promise<string> => {
|
|
136
|
-
this.capabilities = await loadCapabilities(this.path);
|
|
137
|
-
// give error if namespaces are not respected
|
|
138
|
-
for (const capability of this.capabilities) {
|
|
139
|
-
namespaceComplianceValidator(capability, this.alwaysIgnore?.namespaces);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
return allYaml(this, imagePullSecret);
|
|
143
|
-
};
|
|
144
|
-
|
|
145
|
-
/* eslint max-statements: ["warn", 21] */
|
|
146
|
-
generateHelmChart = async (basePath: string): Promise<void> => {
|
|
147
|
-
const helm = helmLayout(basePath, this.config.uuid);
|
|
148
|
-
|
|
149
|
-
try {
|
|
150
|
-
await Promise.all(
|
|
151
|
-
Object.values(helm.dirs)
|
|
152
|
-
.sort((l, r) => l.split("/").length - r.split("/").length)
|
|
153
|
-
.map(async dir => await createDirectoryIfNotExists(dir)),
|
|
154
|
-
);
|
|
155
|
-
|
|
156
|
-
const code = await fs.readFile(this.path);
|
|
157
|
-
|
|
158
|
-
const pairs: [string, () => string][] = [
|
|
159
|
-
[helm.files.chartYaml, (): string => dedent(chartYaml(this.config.uuid, this.config.description || ""))],
|
|
160
|
-
[helm.files.namespaceYaml, (): string => dedent(namespaceTemplate())],
|
|
161
|
-
[helm.files.watcherServiceYaml, (): string => toYaml(watcherService(this.name))],
|
|
162
|
-
[helm.files.admissionServiceYaml, (): string => toYaml(service(this.name))],
|
|
163
|
-
[helm.files.tlsSecretYaml, (): string => toYaml(tlsSecret(this.name, this.tls))],
|
|
164
|
-
[helm.files.apiTokenSecretYaml, (): string => toYaml(apiTokenSecret(this.name, this.apiToken))],
|
|
165
|
-
[helm.files.storeRoleYaml, (): string => toYaml(storeRole(this.name))],
|
|
166
|
-
[helm.files.storeRoleBindingYaml, (): string => toYaml(storeRoleBinding(this.name))],
|
|
167
|
-
[helm.files.clusterRoleYaml, (): string => dedent(clusterRoleTemplate())],
|
|
168
|
-
[helm.files.clusterRoleBindingYaml, (): string => toYaml(clusterRoleBinding(this.name))],
|
|
169
|
-
[helm.files.serviceAccountYaml, (): string => toYaml(serviceAccount(this.name))],
|
|
170
|
-
[helm.files.moduleSecretYaml, (): string => toYaml(getModuleSecret(this.name, code, this.hash))],
|
|
171
|
-
];
|
|
172
|
-
await Promise.all(pairs.map(async ([file, content]) => await fs.writeFile(file, content())));
|
|
173
|
-
|
|
174
|
-
await overridesFile(this, helm.files.valuesYaml);
|
|
175
|
-
|
|
176
|
-
const [mutateWebhook, validateWebhook] = await Promise.all([
|
|
177
|
-
webhookConfig(this, "mutate", this.config.webhookTimeout),
|
|
178
|
-
webhookConfig(this, "validate", this.config.webhookTimeout),
|
|
179
|
-
]);
|
|
180
|
-
|
|
181
|
-
if (validateWebhook || mutateWebhook) {
|
|
182
|
-
await fs.writeFile(helm.files.admissionDeploymentYaml, dedent(admissionDeployTemplate(this.buildTimestamp)));
|
|
183
|
-
await fs.writeFile(helm.files.admissionServiceMonitorYaml, dedent(serviceMonitorTemplate("admission")));
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
if (mutateWebhook) {
|
|
187
|
-
await fs.writeFile(helm.files.mutationWebhookYaml, createWebhookYaml(this, mutateWebhook));
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
if (validateWebhook) {
|
|
191
|
-
await fs.writeFile(helm.files.validationWebhookYaml, createWebhookYaml(this, validateWebhook));
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
const watchDeployment = getWatcher(this, this.hash, this.buildTimestamp);
|
|
195
|
-
if (watchDeployment) {
|
|
196
|
-
await fs.writeFile(helm.files.watcherDeploymentYaml, dedent(watcherDeployTemplate(this.buildTimestamp)));
|
|
197
|
-
await fs.writeFile(helm.files.watcherServiceMonitorYaml, dedent(serviceMonitorTemplate("watcher")));
|
|
198
|
-
}
|
|
199
|
-
} catch (err) {
|
|
200
|
-
console.error(`Error generating helm chart: ${err.message}`);
|
|
201
|
-
process.exit(1);
|
|
202
|
-
}
|
|
203
|
-
};
|
|
204
|
-
}
|
package/src/lib/assets/pods.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { KubernetesObject, V1EnvVar } from "@kubernetes/client-node";
|
|
|
5
5
|
import { kind } from "kubernetes-fluent-client";
|
|
6
6
|
import { gzipSync } from "zlib";
|
|
7
7
|
import { secretOverLimit } from "../helpers";
|
|
8
|
-
import { Assets } from "
|
|
8
|
+
import { Assets } from "./assets";
|
|
9
9
|
import { ModuleConfig } from "../core/module";
|
|
10
10
|
import { Binding } from "../types";
|
|
11
11
|
|