pmcf 6.46.11 → 6.47.0
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/package.json +1 -1
- package/src/base.mjs +30 -11
- package/src/cluster.mjs +3 -14
- package/src/content.mjs +1 -1
- package/src/host.mjs +1 -11
- package/src/services/bind.mjs +13 -19
- package/src/services/chrony.mjs +1 -13
- package/src/services/influxdb.mjs +1 -11
- package/src/services/kea.mjs +1 -13
- package/src/services/mosquitto.mjs +1 -11
- package/src/type.mjs +11 -2
package/package.json
CHANGED
package/src/base.mjs
CHANGED
|
@@ -225,17 +225,36 @@ export class base extends core {
|
|
|
225
225
|
return this._content;
|
|
226
226
|
}
|
|
227
227
|
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
228
|
+
async preparePackage(options) {
|
|
229
|
+
const content = this.content;
|
|
230
|
+
if (content) {
|
|
231
|
+
const pd = await content.preparePackage();
|
|
232
|
+
|
|
233
|
+
pd.sources.push(
|
|
234
|
+
...(await Array.fromAsync(this.templateContent(content)))
|
|
235
|
+
);
|
|
236
|
+
|
|
237
|
+
switch (typeof options) {
|
|
238
|
+
case "string":
|
|
239
|
+
options = { dir: options };
|
|
240
|
+
case "object":
|
|
241
|
+
pd.sources.push(
|
|
242
|
+
new FileContentProvider({
|
|
243
|
+
pattern: ["**/*"],
|
|
244
|
+
permissions: content.permissions,
|
|
245
|
+
...options
|
|
246
|
+
})
|
|
247
|
+
);
|
|
248
|
+
}
|
|
234
249
|
|
|
235
|
-
|
|
250
|
+
return pd;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
236
253
|
|
|
237
|
-
|
|
238
|
-
|
|
254
|
+
async *preparePackages(dir) {
|
|
255
|
+
const packageData = await this.preparePackage(dir);
|
|
256
|
+
if (packageData) {
|
|
257
|
+
yield packageData;
|
|
239
258
|
}
|
|
240
259
|
}
|
|
241
260
|
|
|
@@ -258,7 +277,7 @@ export class base extends core {
|
|
|
258
277
|
*
|
|
259
278
|
* @returns {AsyncIterable<ContentProvider>}
|
|
260
279
|
*/
|
|
261
|
-
async *templateContent() {
|
|
280
|
+
async *templateContent(content) {
|
|
262
281
|
for (const node of this.walkDirections(["this", "extends"])) {
|
|
263
282
|
const dir = join(node.directory, "content");
|
|
264
283
|
|
|
@@ -268,7 +287,7 @@ export class base extends core {
|
|
|
268
287
|
new FileContentProvider({
|
|
269
288
|
dir,
|
|
270
289
|
pattern: "**/*",
|
|
271
|
-
permissions:
|
|
290
|
+
permissions: content.permissions
|
|
272
291
|
}),
|
|
273
292
|
this.templateTransformers
|
|
274
293
|
);
|
package/src/cluster.mjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { join } from "node:path";
|
|
2
|
-
import { FileContentProvider } from "npm-pkgbuild";
|
|
3
2
|
import { FAMILY_IPV4 } from "ip-utilties";
|
|
4
3
|
import { duration_attribute_writable } from "pacc";
|
|
5
4
|
import { host } from "./host.mjs";
|
|
@@ -46,11 +45,10 @@ export class cluster extends host {
|
|
|
46
45
|
return new Set(this.masters).union(new Set(this.backups));
|
|
47
46
|
}
|
|
48
47
|
|
|
49
|
-
get isCluster()
|
|
50
|
-
{
|
|
48
|
+
get isCluster() {
|
|
51
49
|
return true;
|
|
52
50
|
}
|
|
53
|
-
|
|
51
|
+
|
|
54
52
|
isMember(host) {
|
|
55
53
|
return super.isMember(host) || this.hosts.get(host.name) === host;
|
|
56
54
|
}
|
|
@@ -71,16 +69,7 @@ export class cluster extends host {
|
|
|
71
69
|
const host = ni.host;
|
|
72
70
|
|
|
73
71
|
const packageStagingDir = join(stagingDir, host.name);
|
|
74
|
-
const packageData = await host.
|
|
75
|
-
|
|
76
|
-
packageData.sources.push(
|
|
77
|
-
...(await Array.fromAsync(this.templateContent())),
|
|
78
|
-
new FileContentProvider({
|
|
79
|
-
dir: packageStagingDir,
|
|
80
|
-
pattern: "**/*",
|
|
81
|
-
permissions: this.content.permissions
|
|
82
|
-
})
|
|
83
|
-
);
|
|
72
|
+
const packageData = await host.preparePackage({ dir: packageStagingDir });
|
|
84
73
|
|
|
85
74
|
const extra = [];
|
|
86
75
|
|
package/src/content.mjs
CHANGED
package/src/host.mjs
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { readFile } from "node:fs/promises";
|
|
2
2
|
import { join } from "node:path";
|
|
3
|
-
import { FileContentProvider } from "npm-pkgbuild";
|
|
4
3
|
import { AggregatedMap } from "aggregated-map";
|
|
5
4
|
import {
|
|
6
5
|
string_attribute,
|
|
@@ -323,16 +322,7 @@ export class host extends ServiceOwner {
|
|
|
323
322
|
}
|
|
324
323
|
|
|
325
324
|
async *preparePackages(dir) {
|
|
326
|
-
const packageData = await this.
|
|
327
|
-
|
|
328
|
-
packageData.sources.push(
|
|
329
|
-
...(await Array.fromAsync(this.templateContent())),
|
|
330
|
-
new FileContentProvider({
|
|
331
|
-
dir,
|
|
332
|
-
pattern: ["**/*", "**/.ssh/*"],
|
|
333
|
-
permissions: this.content.permissions
|
|
334
|
-
})
|
|
335
|
-
);
|
|
325
|
+
const packageData = await this.preparePackage({ dir, pattern: ["**/*", "**/.ssh/*"]});
|
|
336
326
|
|
|
337
327
|
for (const ni of this.networkInterfaces.values()) {
|
|
338
328
|
await ni.systemdDefinitions(dir, packageData);
|
package/src/services/bind.mjs
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { join } from "node:path";
|
|
2
2
|
import { createHmac } from "node:crypto";
|
|
3
|
-
import { FileContentProvider } from "npm-pkgbuild";
|
|
4
3
|
import { reverseArpa } from "ip-utilties";
|
|
5
4
|
import {
|
|
6
5
|
default_collection_attribute,
|
|
@@ -159,8 +158,7 @@ class bind_zone_config extends base {
|
|
|
159
158
|
this.name = name;
|
|
160
159
|
}
|
|
161
160
|
|
|
162
|
-
async write(
|
|
163
|
-
const dir = outputControl.dir;
|
|
161
|
+
async write(dir) {
|
|
164
162
|
const view = this.owner;
|
|
165
163
|
const type = this.type;
|
|
166
164
|
|
|
@@ -185,7 +183,7 @@ class bind_zone_config extends base {
|
|
|
185
183
|
addressesStatement(
|
|
186
184
|
" allow-update",
|
|
187
185
|
view.allowUpdate,
|
|
188
|
-
"
|
|
186
|
+
"any;",
|
|
189
187
|
" "
|
|
190
188
|
)
|
|
191
189
|
);
|
|
@@ -311,9 +309,9 @@ export class bind_acl extends bind_object {
|
|
|
311
309
|
|
|
312
310
|
const acl_attribute = {
|
|
313
311
|
...default_attribute_writable,
|
|
314
|
-
type:
|
|
312
|
+
type: bind_object,
|
|
315
313
|
name: "acl",
|
|
316
|
-
default: "'any'"
|
|
314
|
+
// default: "'any'"
|
|
317
315
|
};
|
|
318
316
|
|
|
319
317
|
class bind_view extends bind_object {
|
|
@@ -631,11 +629,11 @@ class bind_view extends bind_object {
|
|
|
631
629
|
|
|
632
630
|
async packageContent(outputControl) {
|
|
633
631
|
outputControl.packageData.sources.push(
|
|
634
|
-
...(await Array.fromAsync(this.templateContent()))
|
|
632
|
+
...(await Array.fromAsync(this.templateContent(this.service.content)))
|
|
635
633
|
);
|
|
636
634
|
|
|
637
635
|
for (const config of this.zoneConfigs.values()) {
|
|
638
|
-
await config.write(outputControl);
|
|
636
|
+
await config.write(outputControl.dir);
|
|
639
637
|
}
|
|
640
638
|
|
|
641
639
|
if (this.foreignDomains.size) {
|
|
@@ -661,6 +659,9 @@ class bind_view extends bind_object {
|
|
|
661
659
|
function addressesStatement(prefix, objects, empty = false, indent = "") {
|
|
662
660
|
const body = asArray(objects).map(value => {
|
|
663
661
|
if (typeof value !== "string") {
|
|
662
|
+
if(value instanceof bind_key) {
|
|
663
|
+
return `key ${value.name}`;
|
|
664
|
+
}
|
|
664
665
|
return value.name ?? value.address;
|
|
665
666
|
}
|
|
666
667
|
|
|
@@ -791,21 +792,14 @@ export class bind extends CoreService {
|
|
|
791
792
|
}
|
|
792
793
|
|
|
793
794
|
async *preparePackages(dir) {
|
|
794
|
-
const packageData = await this.
|
|
795
|
+
const packageData = await this.preparePackage(dir);
|
|
795
796
|
|
|
796
|
-
packageData
|
|
797
|
-
|
|
798
|
-
|
|
797
|
+
if(!packageData) {
|
|
798
|
+
return;
|
|
799
|
+
}
|
|
799
800
|
|
|
800
801
|
let hasContent = packageData.sources.length > 0;
|
|
801
802
|
|
|
802
|
-
packageData.sources.push(
|
|
803
|
-
new FileContentProvider({
|
|
804
|
-
dir: dir + "/",
|
|
805
|
-
permissions: this.content.permissions
|
|
806
|
-
})
|
|
807
|
-
);
|
|
808
|
-
|
|
809
803
|
const outputControl = { packageData, dir };
|
|
810
804
|
|
|
811
805
|
for (const key of this.keys.values()) {
|
package/src/services/chrony.mjs
CHANGED
|
@@ -46,19 +46,7 @@ export class chrony extends CoreService {
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
async *preparePackages(dir) {
|
|
49
|
-
const packageData = await this.
|
|
50
|
-
|
|
51
|
-
packageData.sources.push(
|
|
52
|
-
...(await Array.fromAsync(this.templateContent()))
|
|
53
|
-
);
|
|
54
|
-
|
|
55
|
-
packageData.sources.push(
|
|
56
|
-
new FileContentProvider({
|
|
57
|
-
dir: dir + "/",
|
|
58
|
-
permissions: this.content.permissions
|
|
59
|
-
})
|
|
60
|
-
);
|
|
61
|
-
|
|
49
|
+
const packageData = await this.preparePackage(dir);
|
|
62
50
|
const subnets = [...new Map(this.subnets).values()]; // TODO should be normal
|
|
63
51
|
const host = this.host;
|
|
64
52
|
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { join } from "node:path";
|
|
2
2
|
import { stringify } from "yaml";
|
|
3
|
-
import { FileContentProvider } from "npm-pkgbuild";
|
|
4
3
|
import { boolean_attribute_writable_true } from "pacc";
|
|
5
4
|
import { CoreService, addType, FAMILY_IPV4_IPV6 } from "pmcf";
|
|
6
5
|
import { writeLines, filterConfigurable } from "../utils.mjs";
|
|
@@ -31,16 +30,7 @@ export class influxdb extends CoreService {
|
|
|
31
30
|
}
|
|
32
31
|
|
|
33
32
|
async *preparePackages(dir) {
|
|
34
|
-
const packageData = await this.
|
|
35
|
-
|
|
36
|
-
packageData.sources.push(
|
|
37
|
-
...(await Array.fromAsync(this.templateContent())),
|
|
38
|
-
new FileContentProvider({
|
|
39
|
-
dir,
|
|
40
|
-
pattern: ["**/*"],
|
|
41
|
-
permissions: this.content.permissions
|
|
42
|
-
})
|
|
43
|
-
);
|
|
33
|
+
const packageData = await this.preparePackage(dir);
|
|
44
34
|
|
|
45
35
|
await writeLines(
|
|
46
36
|
join(dir, "etc", "influxdb"),
|
package/src/services/kea.mjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { join } from "node:path";
|
|
2
|
-
import { FileContentProvider } from "npm-pkgbuild";
|
|
3
2
|
import {
|
|
4
3
|
reverseArpa,
|
|
5
4
|
addressType,
|
|
@@ -185,18 +184,7 @@ export class kea extends CoreService {
|
|
|
185
184
|
const name = host.name;
|
|
186
185
|
const subnets = [...this.subnets.values()];
|
|
187
186
|
const dnsServerEndpoints = this.dnsServerEndpoints;
|
|
188
|
-
const packageData = await this.
|
|
189
|
-
|
|
190
|
-
packageData.sources.push(
|
|
191
|
-
...(await Array.fromAsync(this.templateContent()))
|
|
192
|
-
);
|
|
193
|
-
|
|
194
|
-
packageData.sources.push(
|
|
195
|
-
new FileContentProvider({
|
|
196
|
-
dir: dir + "/",
|
|
197
|
-
permissions: this.content.permissions
|
|
198
|
-
})
|
|
199
|
-
);
|
|
187
|
+
const packageData = await this.preparePackage(dir);
|
|
200
188
|
|
|
201
189
|
const loggers = [
|
|
202
190
|
{
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { join } from "node:path";
|
|
2
|
-
import { FileContentProvider } from "npm-pkgbuild";
|
|
3
2
|
import { port_attribute, string_attribute_writable } from "pacc";
|
|
4
3
|
import { CoreService, addType } from "pmcf";
|
|
5
4
|
import {
|
|
@@ -51,16 +50,7 @@ export class mosquitto extends CoreService {
|
|
|
51
50
|
}
|
|
52
51
|
|
|
53
52
|
async *preparePackages(dir) {
|
|
54
|
-
const packageData = await this.
|
|
55
|
-
|
|
56
|
-
packageData.sources.push(
|
|
57
|
-
...(await Array.fromAsync(this.templateContent())),
|
|
58
|
-
new FileContentProvider({
|
|
59
|
-
dir,
|
|
60
|
-
pattern: ["**/*"],
|
|
61
|
-
permissions: this.content.permissions
|
|
62
|
-
})
|
|
63
|
-
);
|
|
53
|
+
const packageData = await this.preparePackage(dir);
|
|
64
54
|
|
|
65
55
|
await writeLines(
|
|
66
56
|
join(dir, "etc", "mosquitto"),
|
package/src/type.mjs
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
addType as addTypeBasic,
|
|
3
|
+
toInternal,
|
|
4
|
+
registerToken,
|
|
5
|
+
DOT,
|
|
6
|
+
asArray
|
|
7
|
+
} from "pacc";
|
|
2
8
|
import { normalizeIP } from "ip-utilties";
|
|
3
9
|
import { addServiceType } from "pmcf";
|
|
4
10
|
|
|
@@ -39,7 +45,10 @@ export function assign(attribute, object, value) {
|
|
|
39
45
|
|
|
40
46
|
if (attribute.deferredExpression) {
|
|
41
47
|
if (object.hasOwnProperty(attribute.name)) {
|
|
42
|
-
error(
|
|
48
|
+
error(
|
|
49
|
+
`attribute ${attribute.name} of ${object.fullName} already defined`,
|
|
50
|
+
attribute
|
|
51
|
+
);
|
|
43
52
|
} else {
|
|
44
53
|
Object.defineProperty(object, attribute.name, {
|
|
45
54
|
get: () => object.expression(value)
|