pepr 0.1.35 → 0.1.37
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/.env +0 -0
- package/README.md +16 -0
- package/dist/index.d.ts +12 -5
- package/dist/index.js +8 -1
- package/dist/package.json +8 -6
- package/dist/src/cli/build.js +3 -3
- package/dist/src/cli/deploy.js +2 -2
- package/dist/src/cli/dev.js +2 -2
- package/dist/src/cli/index.js +3 -3
- package/dist/src/cli/init/index.d.ts +1 -1
- package/dist/src/cli/init/index.js +1 -1
- package/dist/src/cli/init/templates.js +5 -4
- package/dist/src/cli/init/walkthrough.js +1 -1
- package/dist/src/cli/root.js +1 -1
- package/dist/src/cli/test.js +1 -1
- package/dist/src/cli/version.d.ts +1 -0
- package/dist/src/cli/version.js +6 -0
- package/dist/src/lib/fetch.d.ts +17 -0
- package/dist/src/lib/fetch.js +29 -0
- package/dist/src/lib/k8s/index.d.ts +1 -0
- package/dist/src/lib/k8s/upstream.d.ts +1 -0
- package/dist/src/lib/k8s/upstream.js +1 -0
- package/dist/src/lib/k8s/webhook.d.ts +1 -1
- package/dist/src/lib/k8s/webhook.js +1 -1
- package/dist/src/lib/logger.d.ts +3 -2
- package/dist/src/lib/logger.js +3 -1
- package/dist/src/lib/module.d.ts +4 -1
- package/dist/src/lib/module.js +10 -7
- package/dist/src/lib/request.js +3 -26
- package/package.json +8 -6
package/.env
ADDED
|
File without changes
|
package/README.md
CHANGED
|
@@ -10,6 +10,22 @@ Pepr is on a mission to save Kubernetes from the tyranny of YAML, intimidating g
|
|
|
10
10
|
- Write capabilities in TypeScript and bundle them for in-cluster processing in [NodeJS](https://nodejs.org/).
|
|
11
11
|
- React to cluster resources by mutating them, creating new Kubernetes resources, or performing arbitrary exec/API operations.
|
|
12
12
|
|
|
13
|
+
## Wow too many words! tl;dr;
|
|
14
|
+
```bash
|
|
15
|
+
# Install Pepr (you can also use npx)
|
|
16
|
+
npm i -g pepr
|
|
17
|
+
|
|
18
|
+
# Initialize a new Pepr Module
|
|
19
|
+
pepr init
|
|
20
|
+
|
|
21
|
+
# Follow the prompts...
|
|
22
|
+
|
|
23
|
+
# Within the new project dir, start playing with things
|
|
24
|
+
pepr dev
|
|
25
|
+
|
|
26
|
+
# Be amazed and ⭐️ this repo
|
|
27
|
+
```
|
|
28
|
+
|
|
13
29
|
Pepr is an open-source project that helps IT Ops teams of all skill levels manage and modify resources in a Kubernetes (K8s) cluster using TypeScript. Kubernetes simplifies the management of multiple computers working together to run and scale applications. Pepr acts as a smart assistant, automatically changing or validating parts of the system as needed.
|
|
14
30
|
|
|
15
31
|
TypeScript is used to create Pepr capabilities, benefiting from its error-catching and clean code features, but without requiring specialized software engineering experience or prior Typescript knowledge. Pepr also provides a user-friendly interface for writing commands in plain English in a [Fluent Interface](https://en.wikipedia.org/wiki/Fluent_interface) style.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
|
|
1
|
+
import k8s from "@kubernetes/client-node";
|
|
2
|
+
import utils from "ramda";
|
|
3
|
+
import { fetch, fetchRaw } from "src/lib/fetch";
|
|
4
|
+
import { Capability } from "./src/lib/capability";
|
|
5
|
+
import { a } from "./src/lib/k8s";
|
|
6
|
+
import Log from "./src/lib/logger";
|
|
7
|
+
import { PeprModule } from "./src/lib/module";
|
|
8
|
+
import type * as KubernetesClientNode from "@kubernetes/client-node";
|
|
9
|
+
import type * as RamdaUtils from "ramda";
|
|
10
|
+
export { a,
|
|
11
|
+
/** PeprModule is used to setup a complete Pepr Module: `new PeprModule(cfg, {...capabilities})` */
|
|
12
|
+
PeprModule, Capability, Log, utils, fetch, fetchRaw, k8s, RamdaUtils, KubernetesClientNode, };
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.Log = exports.Capability = exports.PeprModule = exports.a = void 0;
|
|
6
|
+
exports.k8s = exports.fetchRaw = exports.fetch = exports.utils = exports.Log = exports.Capability = exports.PeprModule = exports.a = void 0;
|
|
7
|
+
const client_node_1 = __importDefault(require("@kubernetes/client-node"));
|
|
8
|
+
exports.k8s = client_node_1.default;
|
|
9
|
+
const ramda_1 = __importDefault(require("ramda"));
|
|
10
|
+
exports.utils = ramda_1.default;
|
|
11
|
+
const fetch_1 = require("src/lib/fetch");
|
|
12
|
+
Object.defineProperty(exports, "fetch", { enumerable: true, get: function () { return fetch_1.fetch; } });
|
|
13
|
+
Object.defineProperty(exports, "fetchRaw", { enumerable: true, get: function () { return fetch_1.fetchRaw; } });
|
|
7
14
|
const capability_1 = require("./src/lib/capability");
|
|
8
15
|
Object.defineProperty(exports, "Capability", { enumerable: true, get: function () { return capability_1.Capability; } });
|
|
9
16
|
const k8s_1 = require("./src/lib/k8s");
|
package/dist/package.json
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pepr",
|
|
3
|
-
"version": "0.1.35",
|
|
4
3
|
"description": "Kubernetes application engine",
|
|
5
4
|
"author": "Defense Unicorns",
|
|
6
5
|
"homepage": "https://github.com/defenseunicorns/pepr",
|
|
@@ -10,6 +9,7 @@
|
|
|
10
9
|
"engines": {
|
|
11
10
|
"node": ">=18.0.0"
|
|
12
11
|
},
|
|
12
|
+
"version": "0.1.37",
|
|
13
13
|
"main": "dist/index.js",
|
|
14
14
|
"types": "dist/index.d.ts",
|
|
15
15
|
"pepr": {
|
|
@@ -24,14 +24,13 @@
|
|
|
24
24
|
}
|
|
25
25
|
},
|
|
26
26
|
"scripts": {
|
|
27
|
-
"
|
|
28
|
-
"build": "tsc -p tsconfig.build.json",
|
|
27
|
+
"build": "rm -fr dist/* && tsc -p tsconfig.build.json",
|
|
29
28
|
"test": "ava",
|
|
30
29
|
"lint": "npx eslint src",
|
|
31
30
|
"lint:fix": "npm run lint -- --fix",
|
|
32
31
|
"prettier": "npx prettier src --check",
|
|
33
32
|
"prettier:fix": "npm run prettier -- --write",
|
|
34
|
-
"prepublishOnly": "
|
|
33
|
+
"prepublishOnly": "npm run lint:fix && npm run prettier:fix && npm run test && npm run build",
|
|
35
34
|
"e2e-dev-setup": "k3d cluster delete pepr-dev && k3d cluster create pepr-dev --k3s-arg '--debug@server:0'",
|
|
36
35
|
"e2e-dev": "npm run build && docker buildx build --tag pepr:dev . && k3d image import pepr:dev -c pepr-dev && node dist/pepr-cli.js deploy -f -i pepr:dev"
|
|
37
36
|
},
|
|
@@ -45,25 +44,28 @@
|
|
|
45
44
|
"commander": "^10.0.0",
|
|
46
45
|
"express": "^4.18.2",
|
|
47
46
|
"fast-json-patch": "^3.1.1",
|
|
47
|
+
"node-fetch": "^2.6.9",
|
|
48
48
|
"node-forge": "^1.3.1",
|
|
49
49
|
"prettier": "^2.8.7",
|
|
50
50
|
"prompts": "^2.4.2",
|
|
51
51
|
"ramda": "^0.29.0",
|
|
52
52
|
"rollup": "^3.20.2",
|
|
53
|
+
"ts-node": "^10.9.1",
|
|
53
54
|
"tslib": "^2.5.0",
|
|
54
55
|
"typescript": "^5.0.2",
|
|
55
|
-
"ts-node": "^10.9.1",
|
|
56
56
|
"uuid": "^9.0.0"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"@types/express": "^4.17.17",
|
|
60
|
+
"@types/node-fetch": "^2.6.3",
|
|
60
61
|
"@types/node-forge": "^1.3.2",
|
|
61
62
|
"@types/prompts": "^2.4.4",
|
|
62
63
|
"@types/uuid": "^9.0.1",
|
|
63
64
|
"@typescript-eslint/eslint-plugin": "^5.57.0",
|
|
64
65
|
"@typescript-eslint/parser": "^5.57.0",
|
|
65
66
|
"ava": "^5.2.0",
|
|
66
|
-
"eslint": "^8.37.0"
|
|
67
|
+
"eslint": "^8.37.0",
|
|
68
|
+
"nock": "^13.3.0"
|
|
67
69
|
},
|
|
68
70
|
"ava": {
|
|
69
71
|
"extensions": [
|
package/dist/src/cli/build.js
CHANGED
|
@@ -7,14 +7,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
8
|
exports.buildModule = void 0;
|
|
9
9
|
const plugin_json_1 = __importDefault(require("@rollup/plugin-json"));
|
|
10
|
-
const package_json_1 = require("
|
|
10
|
+
const package_json_1 = require("package.json");
|
|
11
11
|
const plugin_node_resolve_1 = __importDefault(require("@rollup/plugin-node-resolve"));
|
|
12
12
|
const plugin_typescript_1 = __importDefault(require("@rollup/plugin-typescript"));
|
|
13
13
|
const fs_1 = require("fs");
|
|
14
14
|
const path_1 = require("path");
|
|
15
15
|
const rollup_1 = require("rollup");
|
|
16
|
-
const logger_1 = __importDefault(require("
|
|
17
|
-
const webhook_1 = require("
|
|
16
|
+
const logger_1 = __importDefault(require("src/lib/logger"));
|
|
17
|
+
const webhook_1 = require("src/lib/k8s/webhook");
|
|
18
18
|
function default_1(program) {
|
|
19
19
|
program
|
|
20
20
|
.command("build")
|
package/dist/src/cli/deploy.js
CHANGED
|
@@ -6,8 +6,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
6
6
|
};
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
8
|
const fs_1 = require("fs");
|
|
9
|
-
const webhook_1 = require("
|
|
10
|
-
const logger_1 = __importDefault(require("
|
|
9
|
+
const webhook_1 = require("src/lib/k8s/webhook");
|
|
10
|
+
const logger_1 = __importDefault(require("src/lib/logger"));
|
|
11
11
|
const build_1 = require("./build");
|
|
12
12
|
const prompts_1 = require("prompts");
|
|
13
13
|
function default_1(program) {
|
package/dist/src/cli/dev.js
CHANGED
|
@@ -10,8 +10,8 @@ const chokidar_1 = require("chokidar");
|
|
|
10
10
|
const fs_1 = require("fs");
|
|
11
11
|
const path_1 = require("path");
|
|
12
12
|
const prompts_1 = require("prompts");
|
|
13
|
-
const webhook_1 = require("
|
|
14
|
-
const logger_1 = __importDefault(require("
|
|
13
|
+
const webhook_1 = require("src/lib/k8s/webhook");
|
|
14
|
+
const logger_1 = __importDefault(require("src/lib/logger"));
|
|
15
15
|
const build_1 = require("./build");
|
|
16
16
|
function default_1(program) {
|
|
17
17
|
program
|
package/dist/src/cli/index.js
CHANGED
|
@@ -5,7 +5,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
6
6
|
};
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
const package_json_1 = require("../../package.json");
|
|
9
8
|
const banner_1 = require("./banner");
|
|
10
9
|
const build_1 = __importDefault(require("./build"));
|
|
11
10
|
const capability_1 = __importDefault(require("./capability"));
|
|
@@ -14,10 +13,11 @@ const dev_1 = __importDefault(require("./dev"));
|
|
|
14
13
|
const init_1 = __importDefault(require("./init"));
|
|
15
14
|
const root_1 = require("./root");
|
|
16
15
|
const test_1 = __importDefault(require("./test"));
|
|
16
|
+
const version_1 = require("./version");
|
|
17
17
|
const program = new root_1.RootCmd();
|
|
18
18
|
program
|
|
19
|
-
.version(
|
|
20
|
-
.description(`Pepr Kubernetes Thingy (v${
|
|
19
|
+
.version(version_1.version)
|
|
20
|
+
.description(`Pepr Kubernetes Thingy (v${version_1.version})`)
|
|
21
21
|
.action(() => {
|
|
22
22
|
if (program.args.length < 1) {
|
|
23
23
|
console.log(banner_1.banner);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { RootCmd } from "
|
|
1
|
+
import { RootCmd } from "src/cli/root";
|
|
2
2
|
export default function (program: RootCmd): void;
|
|
@@ -7,7 +7,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
8
|
const child_process_1 = require("child_process");
|
|
9
9
|
const path_1 = require("path");
|
|
10
|
-
const logger_1 = __importDefault(require("
|
|
10
|
+
const logger_1 = __importDefault(require("src/lib/logger"));
|
|
11
11
|
const templates_1 = require("./templates");
|
|
12
12
|
const utils_1 = require("./utils");
|
|
13
13
|
const walkthrough_1 = require("./walkthrough");
|
|
@@ -3,11 +3,12 @@
|
|
|
3
3
|
// SPDX-FileCopyrightText: 2023-Present The Pepr Authors
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
5
|
exports.snippet = exports.helloPeprTS = exports.samplesYaml = exports.readme = exports.prettierRC = exports.gitIgnore = exports.tsConfig = exports.genPkgJSON = exports.genPeprTS = void 0;
|
|
6
|
+
const client_node_1 = require("@kubernetes/client-node");
|
|
7
|
+
const package_json_1 = require("package.json");
|
|
8
|
+
const version_1 = require("src/cli/version");
|
|
6
9
|
const util_1 = require("util");
|
|
7
10
|
const uuid_1 = require("uuid");
|
|
8
|
-
const package_json_1 = require("../../../package.json");
|
|
9
11
|
const utils_1 = require("./utils");
|
|
10
|
-
const client_node_1 = require("@kubernetes/client-node");
|
|
11
12
|
function genPeprTS() {
|
|
12
13
|
return {
|
|
13
14
|
path: "pepr.ts",
|
|
@@ -43,7 +44,7 @@ function genPkgJSON(opts) {
|
|
|
43
44
|
keywords: ["pepr", "k8s", "policy-engine", "pepr-module", "security"],
|
|
44
45
|
pepr: {
|
|
45
46
|
name: opts.name.trim(),
|
|
46
|
-
version:
|
|
47
|
+
version: version_1.version,
|
|
47
48
|
uuid,
|
|
48
49
|
onError: opts.errorBehavior,
|
|
49
50
|
alwaysIgnore: {
|
|
@@ -56,7 +57,7 @@ function genPkgJSON(opts) {
|
|
|
56
57
|
start: "pepr dev",
|
|
57
58
|
},
|
|
58
59
|
dependencies: {
|
|
59
|
-
pepr: `^${
|
|
60
|
+
pepr: `^${version_1.version}`,
|
|
60
61
|
},
|
|
61
62
|
devDependencies: {
|
|
62
63
|
typescript,
|
|
@@ -8,7 +8,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
8
8
|
exports.confirm = exports.walkthrough = void 0;
|
|
9
9
|
const fs_1 = require("fs");
|
|
10
10
|
const prompts_1 = __importDefault(require("prompts"));
|
|
11
|
-
const types_1 = require("
|
|
11
|
+
const types_1 = require("src/lib/types");
|
|
12
12
|
const templates_1 = require("./templates");
|
|
13
13
|
const utils_1 = require("./utils");
|
|
14
14
|
function walkthrough() {
|
package/dist/src/cli/root.js
CHANGED
|
@@ -7,7 +7,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
8
|
exports.RootCmd = void 0;
|
|
9
9
|
const commander_1 = require("commander");
|
|
10
|
-
const logger_1 = __importDefault(require("
|
|
10
|
+
const logger_1 = __importDefault(require("src/lib/logger"));
|
|
11
11
|
class RootCmd extends commander_1.Command {
|
|
12
12
|
createCommand(name) {
|
|
13
13
|
const cmd = new commander_1.Command(name);
|
package/dist/src/cli/test.js
CHANGED
|
@@ -9,7 +9,7 @@ const child_process_1 = require("child_process");
|
|
|
9
9
|
const chokidar_1 = require("chokidar");
|
|
10
10
|
const path_1 = require("path");
|
|
11
11
|
const util_1 = require("util");
|
|
12
|
-
const logger_1 = __importDefault(require("
|
|
12
|
+
const logger_1 = __importDefault(require("src/lib/logger"));
|
|
13
13
|
const build_1 = require("./build");
|
|
14
14
|
const exec = (0, util_1.promisify)(child_process_1.exec);
|
|
15
15
|
function default_1(program) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const version: string;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import f, { RequestInfo, RequestInit } from "node-fetch";
|
|
3
|
+
export { f as fetchRaw };
|
|
4
|
+
/**
|
|
5
|
+
* Perform an async HTTP call and return the parsed JSON response, optionally
|
|
6
|
+
* as a specific type.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* fetch<string[]>("https://example.com/api/foo");
|
|
11
|
+
* ```
|
|
12
|
+
*
|
|
13
|
+
* @param url The URL or Request object to fetch
|
|
14
|
+
* @param init Additional options for the request
|
|
15
|
+
* @returns
|
|
16
|
+
*/
|
|
17
|
+
export declare function fetch<T>(url: URL | RequestInfo, init?: RequestInit): Promise<T>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
// SPDX-FileCopyrightText: 2023-Present The Pepr Authors
|
|
4
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
5
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
6
|
+
};
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.fetch = exports.fetchRaw = void 0;
|
|
9
|
+
const node_fetch_1 = __importDefault(require("node-fetch"));
|
|
10
|
+
exports.fetchRaw = node_fetch_1.default;
|
|
11
|
+
/**
|
|
12
|
+
* Perform an async HTTP call and return the parsed JSON response, optionally
|
|
13
|
+
* as a specific type.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* fetch<string[]>("https://example.com/api/foo");
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* @param url The URL or Request object to fetch
|
|
21
|
+
* @param init Additional options for the request
|
|
22
|
+
* @returns
|
|
23
|
+
*/
|
|
24
|
+
async function fetch(url, init) {
|
|
25
|
+
const resp = await (0, node_fetch_1.default)(url, init);
|
|
26
|
+
const data = await resp.json();
|
|
27
|
+
return data;
|
|
28
|
+
}
|
|
29
|
+
exports.fetch = fetch;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
+
/** a is a colleciton of K8s types to be used within a CapabilityAction: `When(a.Configmap)` */
|
|
1
2
|
export { V1APIService as APIService, V1CertificateSigningRequest as CertificateSigningRequest, V1ConfigMap as ConfigMap, V1ControllerRevision as ControllerRevision, V1CronJob as CronJob, V1CSIDriver as CSIDriver, V1CSIStorageCapacity as CSIStorageCapacity, V1CustomResourceDefinition as CustomResourceDefinition, V1DaemonSet as DaemonSet, V1Deployment as Deployment, V1EndpointSlice as EndpointSlice, V1HorizontalPodAutoscaler as HorizontalPodAutoscaler, V1Ingress as Ingress, V1IngressClass as IngressClass, V1Job as Job, V1LimitRange as LimitRange, V1LocalSubjectAccessReview as LocalSubjectAccessReview, V1MutatingWebhookConfiguration as MutatingWebhookConfiguration, V1Namespace as Namespace, V1NetworkPolicy as NetworkPolicy, V1Node as Node, V1PersistentVolume as PersistentVolume, V1PersistentVolumeClaim as PersistentVolumeClaim, V1Pod as Pod, V1PodDisruptionBudget as PodDisruptionBudget, V1PodTemplate as PodTemplate, V1ReplicaSet as ReplicaSet, V1ReplicationController as ReplicationController, V1ResourceQuota as ResourceQuota, V1RuntimeClass as RuntimeClass, V1Secret as Secret, V1SelfSubjectAccessReview as SelfSubjectAccessReview, V1SelfSubjectRulesReview as SelfSubjectRulesReview, V1Service as Service, V1ServiceAccount as ServiceAccount, V1StatefulSet as StatefulSet, V1StorageClass as StorageClass, V1SubjectAccessReview as SubjectAccessReview, V1TokenReview as TokenReview, V1ValidatingWebhookConfiguration as ValidatingWebhookConfiguration, V1VolumeAttachment as VolumeAttachment, } from "@kubernetes/client-node/dist";
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
// SPDX-FileCopyrightText: 2023-Present The Pepr Authors
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
5
|
exports.VolumeAttachment = exports.ValidatingWebhookConfiguration = exports.TokenReview = exports.SubjectAccessReview = exports.StorageClass = exports.StatefulSet = exports.ServiceAccount = exports.Service = exports.SelfSubjectRulesReview = exports.SelfSubjectAccessReview = exports.Secret = exports.RuntimeClass = exports.ResourceQuota = exports.ReplicationController = exports.ReplicaSet = exports.PodTemplate = exports.PodDisruptionBudget = exports.Pod = exports.PersistentVolumeClaim = exports.PersistentVolume = exports.Node = exports.NetworkPolicy = exports.Namespace = exports.MutatingWebhookConfiguration = exports.LocalSubjectAccessReview = exports.LimitRange = exports.Job = exports.IngressClass = exports.Ingress = exports.HorizontalPodAutoscaler = exports.EndpointSlice = exports.Deployment = exports.DaemonSet = exports.CustomResourceDefinition = exports.CSIStorageCapacity = exports.CSIDriver = exports.CronJob = exports.ControllerRevision = exports.ConfigMap = exports.CertificateSigningRequest = exports.APIService = void 0;
|
|
6
|
+
/** a is a colleciton of K8s types to be used within a CapabilityAction: `When(a.Configmap)` */
|
|
6
7
|
var dist_1 = require("@kubernetes/client-node/dist");
|
|
7
8
|
Object.defineProperty(exports, "APIService", { enumerable: true, get: function () { return dist_1.V1APIService; } });
|
|
8
9
|
Object.defineProperty(exports, "CertificateSigningRequest", { enumerable: true, get: function () { return dist_1.V1CertificateSigningRequest; } });
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { V1ClusterRole, V1ClusterRoleBinding, V1Deployment, V1MutatingWebhookConfiguration, V1Namespace, V1NetworkPolicy, V1Secret, V1Service, V1ServiceAccount } from "@kubernetes/client-node";
|
|
2
|
-
import { ModuleConfig } from "
|
|
2
|
+
import { ModuleConfig } from "src/lib/types";
|
|
3
3
|
import { TLSOut } from "./tls";
|
|
4
4
|
export declare class Webhook {
|
|
5
5
|
private readonly config;
|
|
@@ -8,7 +8,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
8
8
|
exports.Webhook = void 0;
|
|
9
9
|
const client_node_1 = require("@kubernetes/client-node");
|
|
10
10
|
const zlib_1 = require("zlib");
|
|
11
|
-
const logger_1 = __importDefault(require("
|
|
11
|
+
const logger_1 = __importDefault(require("src/lib/logger"));
|
|
12
12
|
const tls_1 = require("./tls");
|
|
13
13
|
const peprIgnore = {
|
|
14
14
|
key: "pepr.dev",
|
package/dist/src/lib/logger.d.ts
CHANGED
package/dist/src/lib/logger.js
CHANGED
package/dist/src/lib/module.d.ts
CHANGED
|
@@ -5,13 +5,16 @@ export type PackageJSON = {
|
|
|
5
5
|
pepr: ModuleConfig;
|
|
6
6
|
};
|
|
7
7
|
export declare class PeprModule {
|
|
8
|
+
private readonly _deferStart;
|
|
8
9
|
private _controller;
|
|
9
10
|
/**
|
|
10
11
|
* Create a new Pepr runtime
|
|
11
12
|
*
|
|
12
13
|
* @param config The configuration for the Pepr runtime
|
|
14
|
+
* @param capabilities The capabilities to be loaded into the Pepr runtime
|
|
15
|
+
* @param _deferStart (optional) If set to `true`, the Pepr runtime will not be started automatically. This can be used to start the Pepr runtime manually with `start()`.
|
|
13
16
|
*/
|
|
14
|
-
constructor({ description, pepr }: PackageJSON, capabilities?: Capability[],
|
|
17
|
+
constructor({ description, pepr }: PackageJSON, capabilities?: Capability[], _deferStart?: boolean);
|
|
15
18
|
/**
|
|
16
19
|
* Start the Pepr runtime manually.
|
|
17
20
|
* Normally this is called automatically when the Pepr module is instantiated, but can be called manually if `deferStart` is set to `true` in the constructor.
|
package/dist/src/lib/module.js
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
// SPDX-FileCopyrightText: 2023-Present The Pepr Authors
|
|
4
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
5
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
6
|
-
};
|
|
7
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
5
|
exports.PeprModule = void 0;
|
|
9
|
-
const
|
|
6
|
+
const index_1 = require("index");
|
|
10
7
|
const controller_1 = require("./controller");
|
|
11
8
|
const alwaysIgnore = {
|
|
12
9
|
namespaces: ["kube-system", "pepr-system"],
|
|
@@ -17,12 +14,15 @@ class PeprModule {
|
|
|
17
14
|
* Create a new Pepr runtime
|
|
18
15
|
*
|
|
19
16
|
* @param config The configuration for the Pepr runtime
|
|
17
|
+
* @param capabilities The capabilities to be loaded into the Pepr runtime
|
|
18
|
+
* @param _deferStart (optional) If set to `true`, the Pepr runtime will not be started automatically. This can be used to start the Pepr runtime manually with `start()`.
|
|
20
19
|
*/
|
|
21
|
-
constructor({ description, pepr }, capabilities = [],
|
|
22
|
-
|
|
20
|
+
constructor({ description, pepr }, capabilities = [], _deferStart = false) {
|
|
21
|
+
this._deferStart = _deferStart;
|
|
22
|
+
const config = index_1.utils.mergeDeepWith(index_1.utils.concat, pepr, alwaysIgnore);
|
|
23
23
|
config.description = description;
|
|
24
24
|
this._controller = new controller_1.Controller(config, capabilities);
|
|
25
|
-
if (!
|
|
25
|
+
if (!_deferStart) {
|
|
26
26
|
this.start();
|
|
27
27
|
}
|
|
28
28
|
}
|
|
@@ -33,6 +33,9 @@ class PeprModule {
|
|
|
33
33
|
* @param port
|
|
34
34
|
*/
|
|
35
35
|
start(port = 3000) {
|
|
36
|
+
if (!this._deferStart) {
|
|
37
|
+
throw new Error("Cannot start Pepr module: Pepr module was not instantiated with deferStart=true");
|
|
38
|
+
}
|
|
36
39
|
this._controller.startServer(port);
|
|
37
40
|
}
|
|
38
41
|
}
|
package/dist/src/lib/request.js
CHANGED
|
@@ -1,32 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
// SPDX-FileCopyrightText: 2023-Present The Pepr Authors
|
|
4
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
5
|
-
if (k2 === undefined) k2 = k;
|
|
6
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
7
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
8
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
9
|
-
}
|
|
10
|
-
Object.defineProperty(o, k2, desc);
|
|
11
|
-
}) : (function(o, m, k, k2) {
|
|
12
|
-
if (k2 === undefined) k2 = k;
|
|
13
|
-
o[k2] = m[k];
|
|
14
|
-
}));
|
|
15
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
16
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
17
|
-
}) : function(o, v) {
|
|
18
|
-
o["default"] = v;
|
|
19
|
-
});
|
|
20
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
21
|
-
if (mod && mod.__esModule) return mod;
|
|
22
|
-
var result = {};
|
|
23
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
24
|
-
__setModuleDefault(result, mod);
|
|
25
|
-
return result;
|
|
26
|
-
};
|
|
27
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
5
|
exports.RequestWrapper = void 0;
|
|
29
|
-
const
|
|
6
|
+
const index_1 = require("index");
|
|
30
7
|
/**
|
|
31
8
|
* The RequestWrapper class provides methods to modify Kubernetes objects in the context
|
|
32
9
|
* of a mutating webhook request.
|
|
@@ -62,7 +39,7 @@ class RequestWrapper {
|
|
|
62
39
|
*/
|
|
63
40
|
constructor(input) {
|
|
64
41
|
// Deep clone the object to prevent mutation of the original object
|
|
65
|
-
this.Raw =
|
|
42
|
+
this.Raw = index_1.utils.clone(input.object);
|
|
66
43
|
// Store the input
|
|
67
44
|
this._input = input;
|
|
68
45
|
}
|
|
@@ -72,7 +49,7 @@ class RequestWrapper {
|
|
|
72
49
|
* @param obj - The object to merge with the current resource.
|
|
73
50
|
*/
|
|
74
51
|
Merge(obj) {
|
|
75
|
-
this.Raw =
|
|
52
|
+
this.Raw = index_1.utils.mergeDeepRight(this.Raw, obj);
|
|
76
53
|
}
|
|
77
54
|
/**
|
|
78
55
|
* Updates a label on the Kubernetes resource.
|
package/package.json
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pepr",
|
|
3
|
-
"version": "0.1.35",
|
|
4
3
|
"description": "Kubernetes application engine",
|
|
5
4
|
"author": "Defense Unicorns",
|
|
6
5
|
"homepage": "https://github.com/defenseunicorns/pepr",
|
|
@@ -10,6 +9,7 @@
|
|
|
10
9
|
"engines": {
|
|
11
10
|
"node": ">=18.0.0"
|
|
12
11
|
},
|
|
12
|
+
"version": "0.1.37",
|
|
13
13
|
"main": "dist/index.js",
|
|
14
14
|
"types": "dist/index.d.ts",
|
|
15
15
|
"pepr": {
|
|
@@ -24,14 +24,13 @@
|
|
|
24
24
|
}
|
|
25
25
|
},
|
|
26
26
|
"scripts": {
|
|
27
|
-
"
|
|
28
|
-
"build": "tsc -p tsconfig.build.json",
|
|
27
|
+
"build": "rm -fr dist/* && tsc -p tsconfig.build.json",
|
|
29
28
|
"test": "ava",
|
|
30
29
|
"lint": "npx eslint src",
|
|
31
30
|
"lint:fix": "npm run lint -- --fix",
|
|
32
31
|
"prettier": "npx prettier src --check",
|
|
33
32
|
"prettier:fix": "npm run prettier -- --write",
|
|
34
|
-
"prepublishOnly": "
|
|
33
|
+
"prepublishOnly": "npm run lint:fix && npm run prettier:fix && npm run test && npm run build",
|
|
35
34
|
"e2e-dev-setup": "k3d cluster delete pepr-dev && k3d cluster create pepr-dev --k3s-arg '--debug@server:0'",
|
|
36
35
|
"e2e-dev": "npm run build && docker buildx build --tag pepr:dev . && k3d image import pepr:dev -c pepr-dev && node dist/pepr-cli.js deploy -f -i pepr:dev"
|
|
37
36
|
},
|
|
@@ -45,25 +44,28 @@
|
|
|
45
44
|
"commander": "^10.0.0",
|
|
46
45
|
"express": "^4.18.2",
|
|
47
46
|
"fast-json-patch": "^3.1.1",
|
|
47
|
+
"node-fetch": "^2.6.9",
|
|
48
48
|
"node-forge": "^1.3.1",
|
|
49
49
|
"prettier": "^2.8.7",
|
|
50
50
|
"prompts": "^2.4.2",
|
|
51
51
|
"ramda": "^0.29.0",
|
|
52
52
|
"rollup": "^3.20.2",
|
|
53
|
+
"ts-node": "^10.9.1",
|
|
53
54
|
"tslib": "^2.5.0",
|
|
54
55
|
"typescript": "^5.0.2",
|
|
55
|
-
"ts-node": "^10.9.1",
|
|
56
56
|
"uuid": "^9.0.0"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"@types/express": "^4.17.17",
|
|
60
|
+
"@types/node-fetch": "^2.6.3",
|
|
60
61
|
"@types/node-forge": "^1.3.2",
|
|
61
62
|
"@types/prompts": "^2.4.4",
|
|
62
63
|
"@types/uuid": "^9.0.1",
|
|
63
64
|
"@typescript-eslint/eslint-plugin": "^5.57.0",
|
|
64
65
|
"@typescript-eslint/parser": "^5.57.0",
|
|
65
66
|
"ava": "^5.2.0",
|
|
66
|
-
"eslint": "^8.37.0"
|
|
67
|
+
"eslint": "^8.37.0",
|
|
68
|
+
"nock": "^13.3.0"
|
|
67
69
|
},
|
|
68
70
|
"ava": {
|
|
69
71
|
"extensions": [
|