pmcf 1.58.0 → 1.59.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/bin/pmcf-package +36 -33
- package/package.json +1 -1
- package/src/base.mjs +3 -3
- package/src/cluster.mjs +38 -28
- package/src/dns.mjs +7 -7
- package/src/host.mjs +29 -17
- package/src/location.mjs +48 -48
- package/src/owner.mjs +15 -8
- package/src/utils.mjs +11 -0
- package/types/base.d.mts +2 -2
- package/types/host.d.mts +1 -0
- package/types/utils.d.mts +1 -0
package/bin/pmcf-package
CHANGED
|
@@ -20,40 +20,43 @@ const publishingDetails = createPublishingDetails(options.publish, process.env);
|
|
|
20
20
|
for (const name of args) {
|
|
21
21
|
const object = await root.load(name);
|
|
22
22
|
const stagingDir = join(options.output, object.fullName);
|
|
23
|
-
const { properties, outputs } = await object.preparePackage(stagingDir);
|
|
24
23
|
|
|
25
|
-
for (const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
24
|
+
for await (const { properties, outputs } of object.preparePackages(
|
|
25
|
+
stagingDir
|
|
26
|
+
)) {
|
|
27
|
+
for (const outputFactory of outputs) {
|
|
28
|
+
properties.version = pkg.version;
|
|
29
|
+
properties.license = pkg.license;
|
|
30
|
+
properties.maintainer = pkg.contributors.map(
|
|
31
|
+
c => c.name + (c.email ? ` <${c.email}>` : "")
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
if (properties.verbose) {
|
|
35
|
+
console.log(properties);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const sources = [
|
|
39
|
+
new FileContentProvider(stagingDir + "/")[Symbol.asyncIterator]()
|
|
40
|
+
];
|
|
41
|
+
|
|
42
|
+
const output = new outputFactory(properties);
|
|
43
|
+
|
|
44
|
+
const artifact = await output.create(
|
|
45
|
+
sources,
|
|
46
|
+
[],
|
|
47
|
+
publishingDetails,
|
|
48
|
+
options
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
if (properties.verbose) {
|
|
52
|
+
console.log(artifact);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
await Promise.all(
|
|
56
|
+
publishingDetails.map(publishDetail =>
|
|
57
|
+
output.publish(artifact, publishDetail)
|
|
58
|
+
)
|
|
59
|
+
);
|
|
34
60
|
}
|
|
35
|
-
|
|
36
|
-
const sources = [
|
|
37
|
-
new FileContentProvider(stagingDir + "/")[Symbol.asyncIterator]()
|
|
38
|
-
];
|
|
39
|
-
|
|
40
|
-
const output = new outputFactory(properties);
|
|
41
|
-
|
|
42
|
-
const artifact = await output.create(
|
|
43
|
-
sources,
|
|
44
|
-
[],
|
|
45
|
-
publishingDetails,
|
|
46
|
-
options
|
|
47
|
-
);
|
|
48
|
-
|
|
49
|
-
if (properties.verbose) {
|
|
50
|
-
console.log(artifact);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
await Promise.all(
|
|
54
|
-
publishingDetails.map(publishDetail =>
|
|
55
|
-
output.publish(artifact, publishDetail)
|
|
56
|
-
)
|
|
57
|
-
);
|
|
58
61
|
}
|
|
59
62
|
}
|
package/package.json
CHANGED
package/src/base.mjs
CHANGED
|
@@ -204,7 +204,7 @@ export class Base {
|
|
|
204
204
|
}
|
|
205
205
|
|
|
206
206
|
typeNamed(typeName, name) {
|
|
207
|
-
return this.owner
|
|
207
|
+
return this.owner?.typeNamed(typeName, name);
|
|
208
208
|
}
|
|
209
209
|
|
|
210
210
|
addObject(object) {
|
|
@@ -331,8 +331,8 @@ export class Base {
|
|
|
331
331
|
return new Set(allOutputs.filter(o => this.packaging.has(o.name)));
|
|
332
332
|
}
|
|
333
333
|
|
|
334
|
-
async
|
|
335
|
-
|
|
334
|
+
async *preparePackages(stagingDir) {
|
|
335
|
+
yield {
|
|
336
336
|
outputs: this.outputs,
|
|
337
337
|
properties: {
|
|
338
338
|
name: this.packageName,
|
package/src/cluster.mjs
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
|
+
import { join } from "node:path";
|
|
1
2
|
import { Owner } from "./owner.mjs";
|
|
2
3
|
import { addType } from "./types.mjs";
|
|
4
|
+
import { writeLines } from "./utils.mjs";
|
|
3
5
|
|
|
4
6
|
const ClusterTypeDefinition = {
|
|
5
7
|
name: "cluster",
|
|
6
|
-
owners: [Owner.typeDefinition, "network", "root"],
|
|
8
|
+
owners: [Owner.typeDefinition, "network", "location", "root"],
|
|
7
9
|
priority: 0.7,
|
|
8
10
|
extends: Owner.typeDefinition,
|
|
9
11
|
properties: {
|
|
10
|
-
masters: { type: "
|
|
11
|
-
backups: { type: "
|
|
12
|
+
masters: { type: "network_interface", collection: true, writeable: true },
|
|
13
|
+
backups: { type: "network_interface", collection: true, writeable: true }
|
|
12
14
|
}
|
|
13
15
|
};
|
|
14
16
|
|
|
@@ -33,30 +35,38 @@ export class Cluster extends Owner {
|
|
|
33
35
|
return `${this.constructor.typeDefinition.name}-${this.owner.name}-${this.name}`;
|
|
34
36
|
}
|
|
35
37
|
|
|
36
|
-
async
|
|
37
|
-
const result
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
38
|
+
async *preparePackages(stagingDir) {
|
|
39
|
+
for await (const result of super.preparePackages(stagingDir)) {
|
|
40
|
+
for (const ni of this.masters.union(this.backups)) {
|
|
41
|
+
|
|
42
|
+
const cfg = [
|
|
43
|
+
`vrrp_instance ${this.name} {`,
|
|
44
|
+
` state ${this.masters.has(ni) ? "MASTER" : "BACKUP"}`,
|
|
45
|
+
` interface ${ni.name}`,
|
|
46
|
+
" virtual_router_id 101",
|
|
47
|
+
" priority 255",
|
|
48
|
+
" advert_int 1",
|
|
49
|
+
" authentication {",
|
|
50
|
+
" auth_type PASS",
|
|
51
|
+
" auth_pass pass1234",
|
|
52
|
+
" }",
|
|
53
|
+
" virtual_ipaddress {",
|
|
54
|
+
" 192.168.1.250",
|
|
55
|
+
" }",
|
|
56
|
+
"}"
|
|
57
|
+
];
|
|
58
|
+
|
|
59
|
+
await writeLines(
|
|
60
|
+
join(stagingDir, "etc/keepalived"),
|
|
61
|
+
"keepalived.conf",
|
|
62
|
+
cfg
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
result.properties.name = `${this.constructor.typeDefinition.name}-${this.owner.name}-${this.name}-${ni.host.name}`;
|
|
66
|
+
result.properties.dependencies = ["keepalived"];
|
|
67
|
+
|
|
68
|
+
yield result;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
61
71
|
}
|
|
62
72
|
}
|
package/src/dns.mjs
CHANGED
|
@@ -107,15 +107,15 @@ export class DNSService extends Base {
|
|
|
107
107
|
return `named-${this.owner.name}`;
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
-
async
|
|
111
|
-
const result
|
|
110
|
+
async *preparePackages(stagingDir) {
|
|
111
|
+
for await (const result of super.preparePackages(stagingDir)) {
|
|
112
|
+
await generateNamedDefs(this, stagingDir);
|
|
112
113
|
|
|
113
|
-
|
|
114
|
+
result.properties.dependencies = ["mf-named"];
|
|
115
|
+
result.properties.replaces = ["mf-named-zones"];
|
|
114
116
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
return result;
|
|
117
|
+
yield result;
|
|
118
|
+
}
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
121
|
|
package/src/host.mjs
CHANGED
|
@@ -287,6 +287,17 @@ export class Host extends Base {
|
|
|
287
287
|
return super.typeNamed(typeName, name);
|
|
288
288
|
}
|
|
289
289
|
|
|
290
|
+
named(name) {
|
|
291
|
+
const ni = this.#networkInterfaces.get(name);
|
|
292
|
+
if (ni) {
|
|
293
|
+
return ni;
|
|
294
|
+
}
|
|
295
|
+
const service = this.services.find(s => s.name === name);
|
|
296
|
+
if (service) {
|
|
297
|
+
return service;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
|
|
290
301
|
get networkInterfaces() {
|
|
291
302
|
return this.#networkInterfaces;
|
|
292
303
|
}
|
|
@@ -333,25 +344,26 @@ export class Host extends Base {
|
|
|
333
344
|
return `${this.constructor.typeDefinition.name}-${this.owner.name}-${this.name}`;
|
|
334
345
|
}
|
|
335
346
|
|
|
336
|
-
async
|
|
337
|
-
const result
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
347
|
+
async *preparePackages(stagingDir) {
|
|
348
|
+
for await (const result of super.preparePackages(stagingDir)) {
|
|
349
|
+
await generateNetworkDefs(this, stagingDir);
|
|
350
|
+
await generateMachineInfo(this, stagingDir);
|
|
351
|
+
await copySshKeys(this, stagingDir);
|
|
352
|
+
await generateKnownHosts(
|
|
353
|
+
this.owner.hosts(),
|
|
354
|
+
join(stagingDir, "root", ".ssh")
|
|
355
|
+
);
|
|
345
356
|
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
357
|
+
result.properties.dependencies = [
|
|
358
|
+
this.location.packageName,
|
|
359
|
+
...this.depends
|
|
360
|
+
];
|
|
361
|
+
result.properties.provides = [...this.provides];
|
|
362
|
+
result.properties.replaces = [`mf-${this.hostName}`, ...this.replaces];
|
|
363
|
+
result.properties.backup = "root/.ssh/known_hosts";
|
|
353
364
|
|
|
354
|
-
|
|
365
|
+
yield result;
|
|
366
|
+
}
|
|
355
367
|
}
|
|
356
368
|
}
|
|
357
369
|
|
package/src/location.mjs
CHANGED
|
@@ -45,52 +45,51 @@ export class Location extends Owner {
|
|
|
45
45
|
return [...this.typeList("network")][0] || super.network;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
async
|
|
49
|
-
const result
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
/*
|
|
48
|
+
async *preparePackages(stagingDir) {
|
|
49
|
+
for await (const result of super.preparePackages(stagingDir)) {
|
|
50
|
+
await writeLines(
|
|
51
|
+
join(stagingDir, "etc/systemd/resolved.conf.d"),
|
|
52
|
+
`${this.name}.conf`,
|
|
53
|
+
sectionLines("Resolve", await this.dns.resolvedConfig())
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
await writeLines(
|
|
57
|
+
join(stagingDir, "etc/systemd/journald.conf.d"),
|
|
58
|
+
`${this.name}.conf`,
|
|
59
|
+
sectionLines("Journal", {
|
|
60
|
+
Compress: "yes",
|
|
61
|
+
SystemMaxUse: "500M",
|
|
62
|
+
SyncIntervalSec: "15m"
|
|
63
|
+
})
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
await writeLines(
|
|
67
|
+
join(stagingDir, "etc/systemd/timesyncd.conf.d"),
|
|
68
|
+
`${this.name}.conf`,
|
|
69
|
+
sectionLines("Time", {
|
|
70
|
+
NTP: this.ntp.servers.join(" "),
|
|
71
|
+
PollIntervalMinSec: 60,
|
|
72
|
+
SaveIntervalSec: 3600
|
|
73
|
+
})
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
const locationDir = join(stagingDir, "etc", "location");
|
|
77
|
+
|
|
78
|
+
await mkdir(locationDir, { recursive: true });
|
|
79
|
+
|
|
80
|
+
await copyFile(
|
|
81
|
+
join(this.directory, "location.json"),
|
|
82
|
+
join(locationDir, "location.json")
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
result.properties.provides = [
|
|
86
|
+
"location",
|
|
87
|
+
"mf-location",
|
|
88
|
+
`mf-location-${this.name}`
|
|
89
|
+
];
|
|
90
|
+
result.properties.replaces = [`mf-location-${this.name}`];
|
|
91
|
+
|
|
92
|
+
/*
|
|
94
93
|
const install = "location.install";
|
|
95
94
|
|
|
96
95
|
console.log(new URL(install, import.meta.url));
|
|
@@ -102,7 +101,8 @@ export class Location extends Owner {
|
|
|
102
101
|
|
|
103
102
|
result.properties.install = install;
|
|
104
103
|
*/
|
|
105
|
-
|
|
106
|
-
|
|
104
|
+
|
|
105
|
+
yield result;
|
|
106
|
+
}
|
|
107
107
|
}
|
|
108
108
|
}
|
package/src/owner.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { asIterator, normalizeCIDR } from "./utils.mjs";
|
|
2
2
|
import { Base } from "./base.mjs";
|
|
3
3
|
import { Subnet } from "./subnet.mjs";
|
|
4
4
|
import { addType } from "./types.mjs";
|
|
@@ -90,12 +90,17 @@ export class Owner extends Base {
|
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
typeNamed(typeName, name) {
|
|
93
|
-
|
|
94
|
-
|
|
93
|
+
const typeSlot = this.#membersByType.get(typeName);
|
|
94
|
+
if (typeSlot) {
|
|
95
|
+
const object = typeSlot.get(
|
|
96
|
+
name[0] === "/" ? name.substring(this.fullName.length + 1) : name
|
|
97
|
+
);
|
|
98
|
+
if (object) {
|
|
99
|
+
return object;
|
|
100
|
+
}
|
|
95
101
|
}
|
|
96
102
|
|
|
97
|
-
|
|
98
|
-
return typeSlot?.get(name) || this.owner?.typeNamed(typeName, name);
|
|
103
|
+
return super.typeNamed(typeName, name);
|
|
99
104
|
}
|
|
100
105
|
|
|
101
106
|
typeObject(typeName) {
|
|
@@ -218,11 +223,13 @@ export class Owner extends Base {
|
|
|
218
223
|
this.#bridges.add(bridge);
|
|
219
224
|
}
|
|
220
225
|
|
|
221
|
-
for (const name of
|
|
226
|
+
for (const name of asIterator(destinationNetworks)) {
|
|
222
227
|
const other = this.networkNamed(name);
|
|
223
228
|
if (other) {
|
|
224
|
-
bridge.
|
|
225
|
-
|
|
229
|
+
if (!bridge.has(other)) {
|
|
230
|
+
bridge.add(other);
|
|
231
|
+
other.bridge = bridge;
|
|
232
|
+
}
|
|
226
233
|
} else {
|
|
227
234
|
bridge.add(name);
|
|
228
235
|
this.finalize(() => this._resolveBridges());
|
package/src/utils.mjs
CHANGED
|
@@ -33,6 +33,17 @@ export function asArray(value) {
|
|
|
33
33
|
return Array.isArray(value) ? value : value === undefined ? [] : [value];
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
+
export function asIterator(value)
|
|
37
|
+
{
|
|
38
|
+
if(value === undefined) { return []; }
|
|
39
|
+
|
|
40
|
+
if(typeof value[Symbol.iterator] === 'function') {
|
|
41
|
+
return value;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return asArray(value);
|
|
45
|
+
}
|
|
46
|
+
|
|
36
47
|
export function isIPv4Address(address) {
|
|
37
48
|
return address.indexOf(".") >= 0;
|
|
38
49
|
}
|
package/types/base.d.mts
CHANGED
|
@@ -71,14 +71,14 @@ export class Base {
|
|
|
71
71
|
get packaging(): Set<any>;
|
|
72
72
|
get derivedPackaging(): any;
|
|
73
73
|
get outputs(): Set<typeof import("npm-pkgbuild").ARCH | typeof import("npm-pkgbuild").DOCKER>;
|
|
74
|
-
|
|
74
|
+
preparePackages(stagingDir: any): AsyncGenerator<{
|
|
75
75
|
outputs: Set<typeof import("npm-pkgbuild").ARCH | typeof import("npm-pkgbuild").DOCKER>;
|
|
76
76
|
properties: {
|
|
77
77
|
name: string;
|
|
78
78
|
description: string;
|
|
79
79
|
access: string;
|
|
80
80
|
};
|
|
81
|
-
}>;
|
|
81
|
+
}, void, unknown>;
|
|
82
82
|
expand(object: any): any;
|
|
83
83
|
finalize(action: any): void;
|
|
84
84
|
execFinalize(): void;
|
package/types/host.d.mts
CHANGED
|
@@ -176,6 +176,7 @@ export class Host extends Base {
|
|
|
176
176
|
get domainName(): string;
|
|
177
177
|
get host(): this;
|
|
178
178
|
findServices(filter: any): Generator<any, void, unknown>;
|
|
179
|
+
named(name: any): any;
|
|
179
180
|
set networkInterfaces(networkInterface: Map<any, any>);
|
|
180
181
|
get networkInterfaces(): Map<any, any>;
|
|
181
182
|
networkAddresses(): Generator<{
|
package/types/utils.d.mts
CHANGED
|
@@ -2,6 +2,7 @@ export function writeLines(dir: any, name: any, lines: any): Promise<void>;
|
|
|
2
2
|
export function sectionLines(sectionName: any, values: any): string[];
|
|
3
3
|
export function bridgeToJSON(bridge: any): any[];
|
|
4
4
|
export function asArray(value: any): any[];
|
|
5
|
+
export function asIterator(value: any): any;
|
|
5
6
|
export function isIPv4Address(address: any): boolean;
|
|
6
7
|
export function isIPv6Address(address: any): boolean;
|
|
7
8
|
export function isLinkLocal(address: any): any;
|