pepr 0.44.0-nightly.5 → 0.44.0-nightly.7
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/deploy.d.ts.map +1 -1
- package/dist/cli/init/templates.d.ts +2 -2
- package/dist/cli.js +32 -27
- package/dist/controller.js +1 -1
- package/dist/lib/assets/rbac.d.ts.map +1 -1
- package/dist/lib/controller/index.d.ts.map +1 -1
- package/dist/lib/core/storage.d.ts.map +1 -1
- package/dist/lib/processors/watch-processor.d.ts.map +1 -1
- package/dist/lib.js +23 -11
- package/dist/lib.js.map +3 -3
- package/package.json +7 -7
- package/src/cli/build.ts +3 -3
- package/src/cli/deploy.ts +32 -26
- package/src/cli/init/index.ts +2 -2
- package/src/cli/init/walkthrough.ts +1 -1
- package/src/lib/assets/rbac.ts +1 -2
- package/src/lib/controller/index.ts +9 -3
- package/src/lib/core/schedule.ts +2 -2
- package/src/lib/core/storage.ts +2 -1
- package/src/lib/processors/mutate-processor.ts +1 -1
- package/src/lib/processors/watch-processor.ts +5 -3
- package/src/sdk/heredoc.ts +2 -2
package/package.json
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"!src/**/*.test.ts",
|
|
16
16
|
"!dist/**/*.test.d.ts*"
|
|
17
17
|
],
|
|
18
|
-
"version": "0.44.0-nightly.
|
|
18
|
+
"version": "0.44.0-nightly.7",
|
|
19
19
|
"main": "dist/lib.js",
|
|
20
20
|
"types": "dist/lib.d.ts",
|
|
21
21
|
"scripts": {
|
|
@@ -80,16 +80,16 @@
|
|
|
80
80
|
"glob": "^9.0.0"
|
|
81
81
|
},
|
|
82
82
|
"peerDependencies": {
|
|
83
|
-
"@typescript-eslint/eslint-plugin": "7.18.0",
|
|
84
|
-
"@typescript-eslint/parser": "7.18.0",
|
|
85
83
|
"@types/prompts": "2.4.9",
|
|
84
|
+
"@typescript-eslint/eslint-plugin": "8.23.0",
|
|
85
|
+
"@typescript-eslint/parser": "8.23.0",
|
|
86
|
+
"commander": "13.1.0",
|
|
87
|
+
"esbuild": "0.24.2",
|
|
86
88
|
"eslint": "8.57.0",
|
|
87
|
-
"commander": "12.1.0",
|
|
88
|
-
"esbuild": "0.24.0",
|
|
89
89
|
"node-forge": "1.3.1",
|
|
90
90
|
"prettier": "3.4.2",
|
|
91
91
|
"prompts": "2.4.2",
|
|
92
|
-
"typescript": "
|
|
93
|
-
"uuid": "11.0.
|
|
92
|
+
"typescript": "5.7.3",
|
|
93
|
+
"uuid": "11.0.5"
|
|
94
94
|
}
|
|
95
95
|
}
|
package/src/cli/build.ts
CHANGED
|
@@ -165,7 +165,7 @@ export default function (program: RootCmd): void {
|
|
|
165
165
|
return;
|
|
166
166
|
}
|
|
167
167
|
// set the image version if provided
|
|
168
|
-
opts.version
|
|
168
|
+
if (opts.version) cfg.pepr.peprVersion = opts.version;
|
|
169
169
|
|
|
170
170
|
// Generate a secret for the module
|
|
171
171
|
const assets = new Assets(
|
|
@@ -183,7 +183,7 @@ export default function (program: RootCmd): void {
|
|
|
183
183
|
opts.withPullSecret === "" ? [] : [opts.withPullSecret],
|
|
184
184
|
);
|
|
185
185
|
|
|
186
|
-
image !== ""
|
|
186
|
+
if (image !== "") assets.image = image;
|
|
187
187
|
|
|
188
188
|
// Ensure imagePullSecret is valid
|
|
189
189
|
validImagePullSecret(opts.withPullSecret);
|
|
@@ -218,7 +218,7 @@ export async function loadModule(entryPoint = peprTS): Promise<LoadModuleReturn>
|
|
|
218
218
|
try {
|
|
219
219
|
await fs.access(cfgPath);
|
|
220
220
|
await fs.access(entryPointPath);
|
|
221
|
-
} catch
|
|
221
|
+
} catch {
|
|
222
222
|
console.error(
|
|
223
223
|
`Could not find ${cfgPath} or ${entryPointPath} in the current directory. Please run this command from the root of your module's directory.`,
|
|
224
224
|
);
|
package/src/cli/deploy.ts
CHANGED
|
@@ -93,6 +93,35 @@ export async function getUserConfirmation(opts: { confirm: boolean }): Promise<b
|
|
|
93
93
|
return confirm.confirm ? true : false;
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
+
async function buildAndDeployModule(image: string, force: boolean): Promise<void> {
|
|
97
|
+
const builtModule = await buildModule();
|
|
98
|
+
if (!builtModule) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// Generate a secret for the module
|
|
103
|
+
const webhook = new Assets(
|
|
104
|
+
{ ...builtModule.cfg.pepr, description: builtModule.cfg.description },
|
|
105
|
+
builtModule.path,
|
|
106
|
+
[],
|
|
107
|
+
);
|
|
108
|
+
webhook.image = image ?? webhook.image;
|
|
109
|
+
|
|
110
|
+
try {
|
|
111
|
+
await webhook.deploy(deployWebhook, force, builtModule.cfg.pepr.webhookTimeout ?? 10);
|
|
112
|
+
|
|
113
|
+
// wait for capabilities to be loaded and test names
|
|
114
|
+
validateCapabilityNames(webhook.capabilities);
|
|
115
|
+
|
|
116
|
+
// Wait for the pepr-system resources to be fully up
|
|
117
|
+
await namespaceDeploymentsReady();
|
|
118
|
+
console.info(`✅ Module deployed successfully`);
|
|
119
|
+
} catch (e) {
|
|
120
|
+
console.error(`Error deploying module:`, e);
|
|
121
|
+
process.exit(1);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
96
125
|
export default function (program: RootCmd): void {
|
|
97
126
|
program
|
|
98
127
|
.command("deploy")
|
|
@@ -117,33 +146,10 @@ export default function (program: RootCmd): void {
|
|
|
117
146
|
return;
|
|
118
147
|
}
|
|
119
148
|
|
|
120
|
-
(await getUserConfirmation(opts))
|
|
121
|
-
|
|
122
|
-
const builtModule = await buildModule();
|
|
123
|
-
if (!builtModule) {
|
|
124
|
-
return;
|
|
149
|
+
if (!(await getUserConfirmation(opts))) {
|
|
150
|
+
process.exit(0);
|
|
125
151
|
}
|
|
126
152
|
|
|
127
|
-
|
|
128
|
-
const webhook = new Assets(
|
|
129
|
-
{ ...builtModule.cfg.pepr, description: builtModule.cfg.description },
|
|
130
|
-
builtModule.path,
|
|
131
|
-
[],
|
|
132
|
-
);
|
|
133
|
-
webhook.image = opts.image ?? webhook.image;
|
|
134
|
-
|
|
135
|
-
try {
|
|
136
|
-
await webhook.deploy(deployWebhook, opts.force, builtModule.cfg.pepr.webhookTimeout ?? 10);
|
|
137
|
-
|
|
138
|
-
// wait for capabilities to be loaded and test names
|
|
139
|
-
validateCapabilityNames(webhook.capabilities);
|
|
140
|
-
|
|
141
|
-
// Wait for the pepr-system resources to be fully up
|
|
142
|
-
await namespaceDeploymentsReady();
|
|
143
|
-
console.info(`✅ Module deployed successfully`);
|
|
144
|
-
} catch (e) {
|
|
145
|
-
console.error(`Error deploying module:`, e);
|
|
146
|
-
process.exit(1);
|
|
147
|
-
}
|
|
153
|
+
await buildAndDeployModule(opts.image, opts.force);
|
|
148
154
|
});
|
|
149
155
|
}
|
package/src/cli/init/index.ts
CHANGED
|
@@ -107,7 +107,7 @@ const doPostInitActions = (dirName: string): void => {
|
|
|
107
107
|
execSync("code .", {
|
|
108
108
|
stdio: "inherit",
|
|
109
109
|
});
|
|
110
|
-
} catch
|
|
111
|
-
|
|
110
|
+
} catch {
|
|
111
|
+
console.warn("VSCode was not found, IDE will not automatically open.");
|
|
112
112
|
}
|
|
113
113
|
};
|
|
@@ -38,7 +38,7 @@ export async function setName(name?: string): Promise<Answers<string>> {
|
|
|
38
38
|
await fs.access(name, fs.constants.F_OK);
|
|
39
39
|
|
|
40
40
|
return "A directory with this name already exists";
|
|
41
|
-
} catch
|
|
41
|
+
} catch {
|
|
42
42
|
return val.length > 2 || "The name must be at least 3 characters long";
|
|
43
43
|
}
|
|
44
44
|
},
|
package/src/lib/assets/rbac.ts
CHANGED
|
@@ -24,8 +24,7 @@ export function clusterRole(
|
|
|
24
24
|
const rbacMap = createRBACMap(capabilities);
|
|
25
25
|
// Generate scoped rules from rbacMap
|
|
26
26
|
const scopedRules = Object.keys(rbacMap).map(key => {
|
|
27
|
-
|
|
28
|
-
key.split("/").length < 3 ? (group = "") : (group = key.split("/")[0]);
|
|
27
|
+
const group: string = key.split("/").length < 3 ? "" : key.split("/")[0];
|
|
29
28
|
|
|
30
29
|
return {
|
|
31
30
|
apiGroups: [group],
|
|
@@ -53,7 +53,9 @@ export class Controller {
|
|
|
53
53
|
// Initialize the Pepr store for each capability
|
|
54
54
|
new StoreController(capabilities, `pepr-${config.uuid}-store`, () => {
|
|
55
55
|
this.#bindEndpoints();
|
|
56
|
-
onReady
|
|
56
|
+
if (typeof onReady === "function") {
|
|
57
|
+
onReady();
|
|
58
|
+
}
|
|
57
59
|
Log.info("✅ Controller startup complete");
|
|
58
60
|
// Initialize the schedule store for each capability
|
|
59
61
|
new StoreController(capabilities, `pepr-${config.uuid}-schedule`, () => {
|
|
@@ -224,7 +226,9 @@ export class Controller {
|
|
|
224
226
|
Log.debug({ ...reqMetadata, request }, "Incoming request body");
|
|
225
227
|
|
|
226
228
|
// Run the before hook if it exists
|
|
227
|
-
|
|
229
|
+
if (typeof this.#beforeHook === "function") {
|
|
230
|
+
this.#beforeHook(request || {});
|
|
231
|
+
}
|
|
228
232
|
|
|
229
233
|
// Process the request
|
|
230
234
|
const response: MutateResponse | ValidateResponse[] =
|
|
@@ -234,7 +238,9 @@ export class Controller {
|
|
|
234
238
|
|
|
235
239
|
// Run the after hook if it exists
|
|
236
240
|
[response].flat().map(res => {
|
|
237
|
-
this.#afterHook
|
|
241
|
+
if (typeof this.#afterHook === "function") {
|
|
242
|
+
this.#afterHook(res);
|
|
243
|
+
}
|
|
238
244
|
Log.info({ ...reqMetadata, res }, "Check response");
|
|
239
245
|
});
|
|
240
246
|
|
package/src/lib/core/schedule.ts
CHANGED
|
@@ -91,7 +91,7 @@ export class OnSchedule implements Schedule {
|
|
|
91
91
|
lastTimestamp: new Date(),
|
|
92
92
|
name: this.name,
|
|
93
93
|
};
|
|
94
|
-
this.store
|
|
94
|
+
if (this.store) this.store.setItem(this.name, JSON.stringify(schedule));
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
/**
|
|
@@ -170,6 +170,6 @@ export class OnSchedule implements Schedule {
|
|
|
170
170
|
clearInterval(this.intervalId);
|
|
171
171
|
this.intervalId = null;
|
|
172
172
|
}
|
|
173
|
-
this.store
|
|
173
|
+
if (this.store) this.store.removeItem(this.name);
|
|
174
174
|
}
|
|
175
175
|
}
|
package/src/lib/core/storage.ts
CHANGED
|
@@ -110,11 +110,12 @@ export class Storage implements PeprStore {
|
|
|
110
110
|
};
|
|
111
111
|
|
|
112
112
|
clear = (): void => {
|
|
113
|
-
Object.keys(this.#store).length > 0
|
|
113
|
+
if (Object.keys(this.#store).length > 0) {
|
|
114
114
|
this.#dispatchUpdate(
|
|
115
115
|
"remove",
|
|
116
116
|
Object.keys(this.#store).map(key => pointer.escape(key)),
|
|
117
117
|
);
|
|
118
|
+
}
|
|
118
119
|
};
|
|
119
120
|
|
|
120
121
|
removeItem = (key: string): void => {
|
|
@@ -137,9 +137,11 @@ async function runBinding(
|
|
|
137
137
|
|
|
138
138
|
// [ true, void, undefined ] SHOULD remove finalizer
|
|
139
139
|
// [ false ] should NOT remove finalizer
|
|
140
|
-
shouldRemoveFinalizer === false
|
|
141
|
-
|
|
142
|
-
|
|
140
|
+
if (shouldRemoveFinalizer === false) {
|
|
141
|
+
Log.debug({ obj: kubernetesObject }, `Skipping removal of finalizer '${peprFinal}' from '${resource}'`);
|
|
142
|
+
} else {
|
|
143
|
+
await removeFinalizer(binding, kubernetesObject);
|
|
144
|
+
}
|
|
143
145
|
}
|
|
144
146
|
};
|
|
145
147
|
|
package/src/sdk/heredoc.ts
CHANGED
|
@@ -14,8 +14,8 @@ export function heredoc(strings: TemplateStringsArray, ...values: string[]): str
|
|
|
14
14
|
const asLines = zipped.join("").split(/[\r\n]+/);
|
|
15
15
|
|
|
16
16
|
// strip whitespace-only first & last lines
|
|
17
|
-
asLines[0].trim().length === 0
|
|
18
|
-
asLines.slice(-1)[0].trim().length === 0
|
|
17
|
+
if (asLines[0].trim().length === 0) asLines.shift();
|
|
18
|
+
if (asLines.slice(-1)[0].trim().length === 0) asLines.pop();
|
|
19
19
|
|
|
20
20
|
// find smallest indent
|
|
21
21
|
const indent = asLines.reduce((acc, cur) => {
|