pepr 0.52.0 → 0.52.1-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/crd/create/createCRDscaffold.d.ts +7 -0
- package/dist/cli/crd/create/createCRDscaffold.d.ts.map +1 -0
- package/dist/cli/crd/create/index.d.ts +3 -0
- package/dist/cli/crd/create/index.d.ts.map +1 -0
- package/dist/cli/crd/{generate.d.ts → generate/generators.d.ts} +2 -4
- package/dist/cli/crd/generate/generators.d.ts.map +1 -0
- package/dist/cli/crd/generate/index.d.ts +3 -0
- package/dist/cli/crd/generate/index.d.ts.map +1 -0
- package/dist/cli/crd/generate/messages.d.ts.map +1 -0
- package/dist/cli/crd/index.d.ts +1 -1
- package/dist/cli/crd/index.d.ts.map +1 -1
- package/dist/cli/init/index.d.ts.map +1 -1
- package/dist/cli/init/templates.d.ts +1 -1
- package/dist/cli/init/templates.d.ts.map +1 -1
- package/dist/cli/uuid.d.ts +4 -0
- package/dist/cli/uuid.d.ts.map +1 -1
- package/dist/cli.js +183 -170
- package/dist/controller.js +1 -1
- package/dist/lib/assets/helm.d.ts.map +1 -1
- package/dist/lib/assets/yaml/overridesFile.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/cli/crd/{create.ts → create/createCRDscaffold.ts} +1 -38
- package/src/cli/crd/create/index.ts +41 -0
- package/src/cli/crd/{generate.ts → generate/generators.ts} +2 -13
- package/src/cli/crd/generate/index.ts +14 -0
- package/src/cli/crd/{messages.ts → generate/messages.ts} +3 -0
- package/src/cli/crd/index.ts +7 -9
- package/src/cli/format/index.ts +3 -3
- package/src/cli/init/index.ts +4 -19
- package/src/cli/init/templates.ts +4 -9
- package/src/cli/uuid.ts +40 -23
- package/src/cli.ts +1 -1
- package/src/lib/assets/helm.ts +6 -0
- package/src/lib/assets/yaml/overridesFile.ts +2 -0
- package/dist/cli/crd/create.d.ts +0 -10
- package/dist/cli/crd/create.d.ts.map +0 -1
- package/dist/cli/crd/generate.d.ts.map +0 -1
- package/dist/cli/crd/messages.d.ts.map +0 -1
- /package/dist/cli/crd/{messages.d.ts → generate/messages.d.ts} +0 -0
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.52.
|
|
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.52.1-nightly.1", 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.9.0", 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");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helm.d.ts","sourceRoot":"","sources":["../../../src/lib/assets/helm.ts"],"names":[],"mappings":"AAGA,KAAK,cAAc,GAAG,WAAW,GAAG,SAAS,CAAC;AAE9C,wBAAgB,mBAAmB,IAAI,MAAM,CAY5C;AAED,wBAAgB,iBAAiB,IAAI,MAAM,CAe1C;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,CA2BpE;AAED,wBAAgB,qBAAqB,CAAC,cAAc,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"helm.d.ts","sourceRoot":"","sources":["../../../src/lib/assets/helm.ts"],"names":[],"mappings":"AAGA,KAAK,cAAc,GAAG,WAAW,GAAG,SAAS,CAAC;AAE9C,wBAAgB,mBAAmB,IAAI,MAAM,CAY5C;AAED,wBAAgB,iBAAiB,IAAI,MAAM,CAe1C;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,CA2BpE;AAED,wBAAgB,qBAAqB,CAAC,cAAc,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,GAAG,MAAM,CAmG1F;AAED,wBAAgB,uBAAuB,CAAC,cAAc,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,GAAG,MAAM,CAuH5F;AAED,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,GAAG,MAAM,CA0BjF;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,GAAG,MAAM,CAoB1E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"overridesFile.d.ts","sourceRoot":"","sources":["../../../../src/lib/assets/yaml/overridesFile.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAK7D,MAAM,MAAM,cAAc,GAAG;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,gBAAgB,EAAE,CAAC;IACjC,MAAM,EAAE,YAAY,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAGF,wBAAsB,aAAa,CACjC,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,EAAE,cAAc,EACpE,IAAI,EAAE,MAAM,EACZ,gBAAgB,EAAE,MAAM,EAAE,EAC1B,cAAc,GAAE;IAAE,SAAS,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAuC,GAC5F,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"overridesFile.d.ts","sourceRoot":"","sources":["../../../../src/lib/assets/yaml/overridesFile.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAK7D,MAAM,MAAM,cAAc,GAAG;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,gBAAgB,EAAE,CAAC;IACjC,MAAM,EAAE,YAAY,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAGF,wBAAsB,aAAa,CACjC,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,EAAE,cAAc,EACpE,IAAI,EAAE,MAAM,EACZ,gBAAgB,EAAE,MAAM,EAAE,EAC1B,cAAc,GAAE;IAAE,SAAS,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAuC,GAC5F,OAAO,CAAC,IAAI,CAAC,CAoKf"}
|
package/package.json
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"!src/fixtures/**",
|
|
17
17
|
"!dist/**/*.test.d.ts*"
|
|
18
18
|
],
|
|
19
|
-
"version": "0.52.
|
|
19
|
+
"version": "0.52.1-nightly.1",
|
|
20
20
|
"main": "dist/lib.js",
|
|
21
21
|
"types": "dist/lib.d.ts",
|
|
22
22
|
"scripts": {
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"heredoc": "^1.3.1",
|
|
63
63
|
"http-status-codes": "^2.3.0",
|
|
64
64
|
"json-pointer": "^0.6.2",
|
|
65
|
-
"kubernetes-fluent-client": "3.
|
|
65
|
+
"kubernetes-fluent-client": "3.9.0",
|
|
66
66
|
"pino": "9.7.0",
|
|
67
67
|
"pino-pretty": "13.0.0",
|
|
68
68
|
"prom-client": "15.1.3",
|
|
@@ -106,4 +106,4 @@
|
|
|
106
106
|
"typescript": "5.8.3",
|
|
107
107
|
"uuid": "11.1.0"
|
|
108
108
|
}
|
|
109
|
-
}
|
|
109
|
+
}
|
|
@@ -1,44 +1,7 @@
|
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
2
|
// SPDX-FileCopyrightText: 2023-Present The Pepr Authors
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
import { createDirectoryIfNotExists } from "../../lib/filesystemService";
|
|
6
|
-
import { promises as fs } from "fs";
|
|
7
|
-
import path from "path";
|
|
8
|
-
|
|
9
|
-
// Scaffolds a new CRD TypeScript definition
|
|
10
|
-
const create = new Command("create")
|
|
11
|
-
.description("Create a new CRD TypeScript definition")
|
|
12
|
-
.addOption(
|
|
13
|
-
new Option(
|
|
14
|
-
"-S, --scope <scope>",
|
|
15
|
-
"Whether the resulting custom resource is cluster- or namespace-scoped",
|
|
16
|
-
)
|
|
17
|
-
.choices(["Namespaced", "Cluster"])
|
|
18
|
-
.default("Namespaced"),
|
|
19
|
-
)
|
|
20
|
-
.option("-d, --domain <domain>", "Optional domain for CRD (e.g. pepr.dev)", "pepr.dev")
|
|
21
|
-
.requiredOption("-g, --group <group>", "API group (e.g. cache)")
|
|
22
|
-
.requiredOption("-k, --kind <kind>", "Kind name (e.g. memcached)")
|
|
23
|
-
.option("-p, --plural <plural>", "Plural name for CRD (e.g. memcacheds)")
|
|
24
|
-
.requiredOption("-s, --short-name <name>", "Short name for CRD (e.g. mc)", "")
|
|
25
|
-
.requiredOption("-v, --version <version>", "API version (e.g. v1alpha1)")
|
|
26
|
-
.action(async ({ group, version, kind, domain, scope, plural, shortName }) => {
|
|
27
|
-
console.log("This feature is currently in alpha.");
|
|
28
|
-
const outputDir = path.resolve(`./api/${version}`);
|
|
29
|
-
await createDirectoryIfNotExists(outputDir);
|
|
30
|
-
|
|
31
|
-
// create file in directory with kind
|
|
32
|
-
await fs.writeFile(
|
|
33
|
-
`./api/${version}/${kind.toLowerCase()}_types.ts`,
|
|
34
|
-
generateCRDScaffold(group, version, kind, { domain, scope, plural, shortName }),
|
|
35
|
-
);
|
|
36
|
-
console.log(`✔ Created ${kind} TypeScript definition in ${outputDir}`);
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
export default create;
|
|
40
|
-
|
|
41
|
-
export const generateCRDScaffold = (
|
|
4
|
+
export const createCRDscaffold = (
|
|
42
5
|
group: string,
|
|
43
6
|
version: string,
|
|
44
7
|
kind: string,
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// SPDX-FileCopyrightText: 2023-Present The Pepr Authors
|
|
3
|
+
|
|
4
|
+
import { Command, Option } from "commander";
|
|
5
|
+
import { createDirectoryIfNotExists } from "../../../lib/filesystemService";
|
|
6
|
+
import { promises as fs } from "fs";
|
|
7
|
+
import Log from "../../../lib/telemetry/logger";
|
|
8
|
+
import { createCRDscaffold } from "./createCRDscaffold";
|
|
9
|
+
import path from "path";
|
|
10
|
+
|
|
11
|
+
// Scaffolds a new CRD TypeScript definition
|
|
12
|
+
export default function (): Command {
|
|
13
|
+
return new Command("create")
|
|
14
|
+
.description("Create a new CRD TypeScript definition")
|
|
15
|
+
.addOption(
|
|
16
|
+
new Option(
|
|
17
|
+
"-S, --scope <scope>",
|
|
18
|
+
"Whether the resulting custom resource is cluster- or namespace-scoped",
|
|
19
|
+
)
|
|
20
|
+
.choices(["Namespaced", "Cluster"])
|
|
21
|
+
.default("Namespaced"),
|
|
22
|
+
)
|
|
23
|
+
.option("-d, --domain <domain>", "Optional domain for CRD (e.g. pepr.dev)", "pepr.dev")
|
|
24
|
+
.requiredOption("-g, --group <group>", "API group (e.g. cache)")
|
|
25
|
+
.requiredOption("-k, --kind <kind>", "Kind name (e.g. memcached)")
|
|
26
|
+
.option("-p, --plural <plural>", "Plural name for CRD (e.g. memcacheds)")
|
|
27
|
+
.requiredOption("-s, --short-name <name>", "Short name for CRD (e.g. mc)")
|
|
28
|
+
.requiredOption("-v, --version <version>", "API version (e.g. v1alpha1)")
|
|
29
|
+
.action(async ({ group, version, kind, domain, scope, plural, shortName }) => {
|
|
30
|
+
Log.warn("This feature is currently in alpha.");
|
|
31
|
+
const outputDir = path.resolve(`./api/${version}`);
|
|
32
|
+
await createDirectoryIfNotExists(outputDir);
|
|
33
|
+
|
|
34
|
+
// create file in directory with kind
|
|
35
|
+
await fs.writeFile(
|
|
36
|
+
`./api/${version}/${kind.toLowerCase()}_types.ts`,
|
|
37
|
+
createCRDscaffold(group, version, kind, { domain, scope, plural, shortName }),
|
|
38
|
+
);
|
|
39
|
+
Log.info(`✔ Created ${kind} TypeScript definition in ${outputDir}`);
|
|
40
|
+
});
|
|
41
|
+
}
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
-
// SPDX-FileCopyrightText: 2023-Present The Pepr Authors
|
|
3
|
-
|
|
4
|
-
import { Command } from "commander";
|
|
5
1
|
import fs from "fs";
|
|
6
2
|
import path from "path";
|
|
7
|
-
import Log from "
|
|
3
|
+
import Log from "../../../lib/telemetry/logger";
|
|
8
4
|
import { stringify } from "yaml";
|
|
9
5
|
import {
|
|
10
6
|
Project,
|
|
@@ -15,18 +11,11 @@ import {
|
|
|
15
11
|
SourceFile,
|
|
16
12
|
Type,
|
|
17
13
|
} from "ts-morph";
|
|
18
|
-
import { createDirectoryIfNotExists } from "
|
|
14
|
+
import { createDirectoryIfNotExists } from "../../../lib/filesystemService";
|
|
19
15
|
import { kind as k } from "kubernetes-fluent-client";
|
|
20
16
|
import { V1JSONSchemaProps } from "@kubernetes/client-node";
|
|
21
17
|
import { WarningMessages, ErrorMessages } from "./messages";
|
|
22
18
|
|
|
23
|
-
export default new Command("generate")
|
|
24
|
-
.description(
|
|
25
|
-
"Generate CRD manifests from TypeScript definitions stored in 'api/' of the current directory.",
|
|
26
|
-
)
|
|
27
|
-
.option("-o, --output <directory>", "Output directory for generated CRDs", "./crds")
|
|
28
|
-
.action(generateCRDs);
|
|
29
|
-
|
|
30
19
|
export function extractCRDDetails(
|
|
31
20
|
content: string,
|
|
32
21
|
sourceFile: SourceFile,
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// SPDX-FileCopyrightText: 2023-Present The Pepr Authors
|
|
3
|
+
|
|
4
|
+
import { Command } from "commander";
|
|
5
|
+
import { generateCRDs } from "./generators";
|
|
6
|
+
|
|
7
|
+
export default function (): Command {
|
|
8
|
+
return new Command("generate")
|
|
9
|
+
.description(
|
|
10
|
+
"Generate CRD manifests from TypeScript definitions stored in 'api/' of the current directory.",
|
|
11
|
+
)
|
|
12
|
+
.option("-o, --output <directory>", "Output directory for generated CRDs", "./crds")
|
|
13
|
+
.action(options => generateCRDs(options));
|
|
14
|
+
}
|
package/src/cli/crd/index.ts
CHANGED
|
@@ -2,14 +2,12 @@
|
|
|
2
2
|
// SPDX-FileCopyrightText: 2023-Present The Pepr Authors
|
|
3
3
|
|
|
4
4
|
import { Command } from "commander";
|
|
5
|
-
import
|
|
6
|
-
import
|
|
5
|
+
import generate from "./generate/";
|
|
6
|
+
import create from "./create";
|
|
7
7
|
|
|
8
|
-
export default function (
|
|
9
|
-
|
|
10
|
-
.
|
|
11
|
-
.
|
|
12
|
-
|
|
13
|
-
crd.addCommand(createCmd);
|
|
14
|
-
crd.addCommand(generateCmd);
|
|
8
|
+
export default function (): Command {
|
|
9
|
+
return new Command("crd")
|
|
10
|
+
.description("Scaffold and generate Kubernetes CRDs from structured TypeScript definitions")
|
|
11
|
+
.addCommand(create())
|
|
12
|
+
.addCommand(generate());
|
|
15
13
|
}
|
package/src/cli/format/index.ts
CHANGED
|
@@ -16,7 +16,7 @@ export default function (program: Command): void {
|
|
|
16
16
|
const success = await peprFormat(opts.validateOnly);
|
|
17
17
|
|
|
18
18
|
if (success) {
|
|
19
|
-
|
|
19
|
+
Log.info("Module formatted");
|
|
20
20
|
} else {
|
|
21
21
|
process.exit(1);
|
|
22
22
|
}
|
|
@@ -59,8 +59,8 @@ export async function peprFormat(validateOnly: boolean): Promise<boolean> {
|
|
|
59
59
|
hasFailure = hasFailure || (await formatWithPrettier(results, validateOnly));
|
|
60
60
|
|
|
61
61
|
return !hasFailure;
|
|
62
|
-
} catch (
|
|
63
|
-
|
|
62
|
+
} catch (error) {
|
|
63
|
+
Log.error(error, `Error formatting module:`);
|
|
64
64
|
return false;
|
|
65
65
|
}
|
|
66
66
|
}
|
package/src/cli/init/index.ts
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
|
|
4
4
|
import { execSync } from "child_process";
|
|
5
5
|
import { resolve } from "path";
|
|
6
|
-
import prompts from "prompts";
|
|
7
6
|
|
|
8
7
|
import { Command } from "commander";
|
|
9
8
|
import {
|
|
@@ -28,7 +27,7 @@ import { Option } from "commander";
|
|
|
28
27
|
|
|
29
28
|
export default function (program: Command): void {
|
|
30
29
|
let response = {} as PromptOptions;
|
|
31
|
-
|
|
30
|
+
|
|
32
31
|
program
|
|
33
32
|
.command("init")
|
|
34
33
|
.description("Initialize a new Pepr Module")
|
|
@@ -50,26 +49,12 @@ export default function (program: Command): void {
|
|
|
50
49
|
)
|
|
51
50
|
.option("-y, --yes", "Skip verification prompt when creating a new module.")
|
|
52
51
|
.hook("preAction", async thisCommand => {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
if (process.env.TEST_MODE === "true") {
|
|
56
|
-
prompts.inject([
|
|
57
|
-
"pepr-test-module",
|
|
58
|
-
"A test module for Pepr",
|
|
59
|
-
"ignore",
|
|
60
|
-
"static-test",
|
|
61
|
-
"y",
|
|
62
|
-
]);
|
|
63
|
-
pkgOverride = "file:../pepr-0.0.0-development.tgz";
|
|
64
|
-
response = await walkthrough();
|
|
65
|
-
} else {
|
|
66
|
-
response = await walkthrough(thisCommand.opts());
|
|
67
|
-
Object.entries(response).map(([key, value]) => thisCommand.setOptionValue(key, value));
|
|
68
|
-
}
|
|
52
|
+
response = await walkthrough(thisCommand.opts());
|
|
53
|
+
Object.entries(response).map(([key, value]) => thisCommand.setOptionValue(key, value));
|
|
69
54
|
})
|
|
70
55
|
.action(async opts => {
|
|
71
56
|
const dirName = sanitizeName(response.name);
|
|
72
|
-
const packageJSON = genPkgJSON(response
|
|
57
|
+
const packageJSON = genPkgJSON(response);
|
|
73
58
|
|
|
74
59
|
const confirmed = await confirm(dirName, packageJSON, peprTSTemplate.path, opts.yes);
|
|
75
60
|
|
|
@@ -49,7 +49,7 @@ export type peprPackageJSON = {
|
|
|
49
49
|
print: string;
|
|
50
50
|
};
|
|
51
51
|
|
|
52
|
-
export function genPkgJSON(opts: InitOptions
|
|
52
|
+
export function genPkgJSON(opts: InitOptions): peprPackageJSON {
|
|
53
53
|
// Generate a random UUID for the module based on the module name if it is not provided
|
|
54
54
|
const uuid = !opts.uuid ? uuidv4() : opts.uuid;
|
|
55
55
|
// Generate a name for the module based on the module name
|
|
@@ -57,11 +57,6 @@ export function genPkgJSON(opts: InitOptions, pgkVerOverride?: string): peprPack
|
|
|
57
57
|
// Make typescript a dev dependency
|
|
58
58
|
const { typescript } = peerDependencies;
|
|
59
59
|
|
|
60
|
-
const testEnv = {
|
|
61
|
-
MY_CUSTOM_VAR: "example-value",
|
|
62
|
-
ZARF_VAR: "###ZARF_VAR_THING###",
|
|
63
|
-
};
|
|
64
|
-
|
|
65
60
|
const data = {
|
|
66
61
|
name,
|
|
67
62
|
version: "0.0.1",
|
|
@@ -71,7 +66,7 @@ export function genPkgJSON(opts: InitOptions, pgkVerOverride?: string): peprPack
|
|
|
71
66
|
node: ">=20.0.0",
|
|
72
67
|
},
|
|
73
68
|
pepr: {
|
|
74
|
-
uuid:
|
|
69
|
+
uuid: uuid,
|
|
75
70
|
onError: opts.errorBehavior,
|
|
76
71
|
webhookTimeout: 10,
|
|
77
72
|
customLabels: {
|
|
@@ -93,13 +88,13 @@ export function genPkgJSON(opts: InitOptions, pgkVerOverride?: string): peprPack
|
|
|
93
88
|
},
|
|
94
89
|
},
|
|
95
90
|
includedFiles: [],
|
|
96
|
-
env:
|
|
91
|
+
env: {},
|
|
97
92
|
},
|
|
98
93
|
scripts: {
|
|
99
94
|
"k3d-setup": scripts["test:journey:k3d"],
|
|
100
95
|
},
|
|
101
96
|
dependencies: {
|
|
102
|
-
pepr:
|
|
97
|
+
pepr: version,
|
|
103
98
|
undici: "^7.0.1",
|
|
104
99
|
},
|
|
105
100
|
devDependencies: {
|
package/src/cli/uuid.ts
CHANGED
|
@@ -10,29 +10,8 @@ export default function (program: Command): void {
|
|
|
10
10
|
.command("uuid [uuid]")
|
|
11
11
|
.description("Module UUID(s) currently deployed in the cluster")
|
|
12
12
|
.action(async uuid => {
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
if (!uuid) {
|
|
17
|
-
deployments = await K8s(kind.Deployment)
|
|
18
|
-
.InNamespace("pepr-system")
|
|
19
|
-
.WithLabel("pepr.dev/uuid")
|
|
20
|
-
.Get();
|
|
21
|
-
} else {
|
|
22
|
-
deployments = await K8s(kind.Deployment)
|
|
23
|
-
.InNamespace("pepr-system")
|
|
24
|
-
.WithLabel("pepr.dev/uuid", uuid)
|
|
25
|
-
.Get();
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// Populate the uuidTable with the UUID and description
|
|
29
|
-
deployments.items.map(deploy => {
|
|
30
|
-
const uuid = deploy.metadata?.labels?.["pepr.dev/uuid"] || "";
|
|
31
|
-
const description = deploy.metadata?.annotations?.["pepr.dev/description"] || "";
|
|
32
|
-
if (uuid !== "") {
|
|
33
|
-
uuidTable[uuid] = description;
|
|
34
|
-
}
|
|
35
|
-
});
|
|
13
|
+
const deployments = await getPeprDeploymentsByUUID(uuid);
|
|
14
|
+
const uuidTable = buildUUIDTable(deployments);
|
|
36
15
|
|
|
37
16
|
console.log("UUID\t\tDescription");
|
|
38
17
|
console.log("--------------------------------------------");
|
|
@@ -42,3 +21,41 @@ export default function (program: Command): void {
|
|
|
42
21
|
});
|
|
43
22
|
});
|
|
44
23
|
}
|
|
24
|
+
|
|
25
|
+
export async function getPeprDeploymentsByUUID(
|
|
26
|
+
uuid?: string,
|
|
27
|
+
): Promise<KubernetesListObject<kind.Deployment>> {
|
|
28
|
+
const k8sQuery = K8s(kind.Deployment).InNamespace("pepr-system");
|
|
29
|
+
|
|
30
|
+
let deployments = uuid
|
|
31
|
+
? await k8sQuery.WithLabel("pepr.dev/uuid", uuid).Get()
|
|
32
|
+
: await k8sQuery.WithLabel("pepr.dev/uuid").Get();
|
|
33
|
+
|
|
34
|
+
if (uuid) {
|
|
35
|
+
deployments = {
|
|
36
|
+
...deployments,
|
|
37
|
+
items: deployments.items.filter(
|
|
38
|
+
deploy => deploy.metadata?.labels?.["pepr.dev/uuid"] === uuid,
|
|
39
|
+
),
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return deployments;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function buildUUIDTable(
|
|
47
|
+
deployments: KubernetesListObject<kind.Deployment>,
|
|
48
|
+
): Record<string, string> {
|
|
49
|
+
const uuidTable: Record<string, string> = {};
|
|
50
|
+
|
|
51
|
+
deployments.items.forEach(deploy => {
|
|
52
|
+
const uuid = deploy.metadata?.labels?.["pepr.dev/uuid"] || "";
|
|
53
|
+
const description = deploy.metadata?.annotations?.["pepr.dev/description"] || "";
|
|
54
|
+
|
|
55
|
+
if (uuid !== "") {
|
|
56
|
+
uuidTable[uuid] = description;
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
return uuidTable;
|
|
61
|
+
}
|
package/src/cli.ts
CHANGED
|
@@ -29,6 +29,7 @@ program
|
|
|
29
29
|
.enablePositionalOptions()
|
|
30
30
|
.version(version)
|
|
31
31
|
.description(`Pepr (v${version}) - Type safe K8s middleware for humans`)
|
|
32
|
+
.addCommand(crd())
|
|
32
33
|
.action(() => {
|
|
33
34
|
if (program.args.length < 1) {
|
|
34
35
|
console.log(banner);
|
|
@@ -49,5 +50,4 @@ format(program);
|
|
|
49
50
|
monitor(program);
|
|
50
51
|
uuid(program);
|
|
51
52
|
kfc(program);
|
|
52
|
-
crd(program);
|
|
53
53
|
program.parse();
|
package/src/lib/assets/helm.ts
CHANGED
|
@@ -93,6 +93,9 @@ export function watcherDeployTemplate(buildTimestamp: string, type: ControllerTy
|
|
|
93
93
|
labels:
|
|
94
94
|
app: {{ .Values.uuid }}-watcher
|
|
95
95
|
pepr.dev/controller: watcher
|
|
96
|
+
{{- if .Values.watcher.podLabels }}
|
|
97
|
+
{{- toYaml .Values.watcher.podLabels | nindent 8 }}
|
|
98
|
+
{{- end }}
|
|
96
99
|
spec:
|
|
97
100
|
terminationGracePeriodSeconds: {{ .Values.watcher.terminationGracePeriodSeconds }}
|
|
98
101
|
serviceAccountName: {{ .Values.uuid }}
|
|
@@ -189,6 +192,9 @@ export function admissionDeployTemplate(buildTimestamp: string, type: Controller
|
|
|
189
192
|
labels:
|
|
190
193
|
app: {{ .Values.uuid }}
|
|
191
194
|
pepr.dev/controller: admission
|
|
195
|
+
{{- if .Values.admission.podLabels }}
|
|
196
|
+
{{- toYaml .Values.admission.podLabels | nindent 8 }}
|
|
197
|
+
{{- end }}
|
|
192
198
|
spec:
|
|
193
199
|
{{- if or .Values.admission.antiAffinity .Values.admission.affinity }}
|
|
194
200
|
affinity:
|
|
@@ -100,6 +100,7 @@ export async function overridesFile(
|
|
|
100
100
|
},
|
|
101
101
|
},
|
|
102
102
|
podAnnotations: {},
|
|
103
|
+
podLabels: {},
|
|
103
104
|
nodeSelector: {},
|
|
104
105
|
tolerations: [],
|
|
105
106
|
extraVolumeMounts: [],
|
|
@@ -172,6 +173,7 @@ export async function overridesFile(
|
|
|
172
173
|
extraVolumes: [],
|
|
173
174
|
affinity: {},
|
|
174
175
|
podAnnotations: {},
|
|
176
|
+
podLabels: {},
|
|
175
177
|
serviceMonitor: {
|
|
176
178
|
enabled: false,
|
|
177
179
|
labels: {},
|
package/dist/cli/crd/create.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { Command } from "commander";
|
|
2
|
-
declare const create: Command;
|
|
3
|
-
export default create;
|
|
4
|
-
export declare const generateCRDScaffold: (group: string, version: string, kind: string, data: {
|
|
5
|
-
domain: string;
|
|
6
|
-
plural: string;
|
|
7
|
-
scope: string;
|
|
8
|
-
shortName: string;
|
|
9
|
-
}) => string;
|
|
10
|
-
//# sourceMappingURL=create.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../src/cli/crd/create.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAU,MAAM,WAAW,CAAC;AAM5C,QAAA,MAAM,MAAM,SA2BR,CAAC;AAEL,eAAe,MAAM,CAAC;AAEtB,eAAO,MAAM,mBAAmB,GAC9B,OAAO,MAAM,EACb,SAAS,MAAM,EACf,MAAM,MAAM,EACZ,MAAM;IACJ,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;CACnB,KACA,MA8EF,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
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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