pmcf 6.4.1 → 6.6.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/README.md CHANGED
@@ -77,26 +77,26 @@ generates config packages for:
77
77
  * [domainNames](#domainnames)
78
78
  * [InitializationContext](#initializationcontext)
79
79
  * [Parameters](#parameters-13)
80
+ * [SkeletonNetworkInterface](#skeletonnetworkinterface)
81
+ * [networkAddresses](#networkaddresses)
82
+ * [Parameters](#parameters-14)
80
83
  * [SystemdJournalRemoteService](#systemdjournalremoteservice)
81
84
  * [Properties](#properties)
82
85
  * [systemdConfigs](#systemdconfigs)
83
- * [Parameters](#parameters-14)
86
+ * [Parameters](#parameters-15)
84
87
  * [SystemdJournalUploadService](#systemdjournaluploadservice)
85
88
  * [Properties](#properties-1)
86
89
  * [systemdConfigs](#systemdconfigs-1)
87
- * [Parameters](#parameters-15)
90
+ * [Parameters](#parameters-16)
88
91
  * [NetworkAddress](#networkaddress)
89
- * [Parameters](#parameters-16)
92
+ * [Parameters](#parameters-17)
90
93
  * [subnet](#subnet)
91
94
  * [networkInterface](#networkinterface)
92
95
  * [address](#address)
93
96
  * [addresses](#addresses)
94
- * [Parameters](#parameters-17)
95
- * [cidrAddresses](#cidraddresses)
96
97
  * [Parameters](#parameters-18)
97
- * [SkeletonNetworkInterface](#skeletonnetworkinterface)
98
- * [networkAddresses](#networkaddresses)
99
- * [Parameters](#parameters-19)
98
+ * [cidrAddresses](#cidraddresses)
99
+ * [Parameters](#parameters-19)
100
100
  * [families](#families)
101
101
  * [secretName](#secretname)
102
102
  * [directHosts](#directhosts)
@@ -286,6 +286,18 @@ Keeps track of all in flight object creations and loose ends during config initi
286
286
 
287
287
  * `directory` (optional, default `"/"`)
288
288
 
289
+ ## SkeletonNetworkInterface
290
+
291
+ **Extends ServiceOwner**
292
+
293
+ ### networkAddresses
294
+
295
+ #### Parameters
296
+
297
+ * `filter` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** (optional, default `n=>true`)
298
+
299
+ Returns **Iterable<[NetworkAddress](#networkaddress)>**&#x20;
300
+
289
301
  ## SystemdJournalRemoteService
290
302
 
291
303
  **Extends CoreService**
@@ -361,18 +373,6 @@ Returns **Iterable<[string](https://developer.mozilla.org/docs/Web/JavaScript/Re
361
373
 
362
374
  Returns **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>**&#x20;
363
375
 
364
- ## SkeletonNetworkInterface
365
-
366
- **Extends ServiceOwner**
367
-
368
- ### networkAddresses
369
-
370
- #### Parameters
371
-
372
- * `filter` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** (optional, default `n=>true`)
373
-
374
- Returns **Iterable<[NetworkAddress](#networkaddress)>**&#x20;
375
-
376
376
  ## families
377
377
 
378
378
  Returns **[Set](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Set)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>**&#x20;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pmcf",
3
- "version": "6.4.1",
3
+ "version": "6.6.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
package/src/base.mjs CHANGED
@@ -91,7 +91,29 @@ export class Base {
91
91
  return this;
92
92
  }
93
93
 
94
- materializeExtends() {}
94
+ materializeExtends() {
95
+ for (const [path, attribute] of extendingAttributeIterator(
96
+ this.constructor,
97
+ attribute => attribute.collection && !attribute.type.primitive
98
+ )) {
99
+ const collection = this[path];
100
+ if (typeof collection?.get === "function") {
101
+ for (const [name, extending] of this.mapFromDirections(
102
+ ["extends"],
103
+ path
104
+ )) {
105
+ const present = collection.get(extending.name);
106
+
107
+ if (present) {
108
+ present.extends.add(extending);
109
+ present.materializeExtends();
110
+ } else {
111
+ collection.set(extending.name, extending.forOwner(this));
112
+ }
113
+ }
114
+ }
115
+ }
116
+ }
95
117
 
96
118
  named(name) {
97
119
  if (name[0] === "/") {
@@ -190,7 +212,7 @@ export class Base {
190
212
  *walkDirections(directions = ["this", "extends", "owner"]) {
191
213
  if (directions.indexOf("this") >= 0) {
192
214
  yield this;
193
- directions = directions.filter(d => d != "this");
215
+ directions = directions.filter(d => d !== "this");
194
216
  }
195
217
 
196
218
  yield* this._walkDirections(directions, new Set());
@@ -268,7 +290,12 @@ export class Base {
268
290
  const value = this.attribute(name);
269
291
 
270
292
  if (value !== undefined) {
271
- yield [attribute.externalName ?? name, toExternal(value, attribute), path, attribute];
293
+ yield [
294
+ attribute.externalName ?? name,
295
+ toExternal(value, attribute),
296
+ path,
297
+ attribute
298
+ ];
272
299
  }
273
300
  }
274
301
  }
@@ -414,6 +441,23 @@ export class Base {
414
441
  return new Set(allOutputs.filter(o => this.packaging.has(o.name)));
415
442
  }
416
443
 
444
+ get packageContentPermissions() {
445
+ const owner = this.constructor.name;
446
+ const group = owner;
447
+ return [
448
+ {
449
+ mode: 0o644,
450
+ owner,
451
+ group
452
+ },
453
+ {
454
+ mode: 0o755,
455
+ owner,
456
+ group
457
+ }
458
+ ];
459
+ }
460
+
417
461
  get packageData() {
418
462
  const nameParts = [this.typeName, this.owner?.name, this.name];
419
463
  return {
package/src/host.mjs CHANGED
@@ -106,23 +106,6 @@ export class Host extends ServiceOwner {
106
106
  _serial;
107
107
  _keymap;
108
108
 
109
- materializeExtends() {
110
- super.materializeExtends();
111
-
112
- for (const host of this.walkDirections(["extends"])) {
113
- for (const ni of host.networkInterfaces.values()) {
114
- const present = this.networkInterfaces.get(ni.name);
115
-
116
- if (present) {
117
- present.extends.add(ni);
118
- present.materializeExtends();
119
- } else {
120
- this.networkInterfaces.set(ni.name, ni.forOwner(this));
121
- }
122
- }
123
- }
124
- }
125
-
126
109
  set serial(value) {
127
110
  this._serial = value;
128
111
  }
@@ -25,13 +25,11 @@ export class InitializationContext {
25
25
  .outstandingResolves) {
26
26
  value = object.expand(value);
27
27
 
28
- for (const type of attribute.type.members || [attribute.type]) {
29
- for (const node of object.walkDirections(["this", "owner"])) {
30
- const resolved = this.named(value, node);
31
- if (resolved) {
32
- assign(attribute, object, resolved);
33
- continue nextOutstanding;
34
- }
28
+ for (const node of object.walkDirections(["this", "owner"])) {
29
+ const resolved = this.named(value, node);
30
+ if (resolved) {
31
+ assign(attribute, object, resolved);
32
+ continue nextOutstanding;
35
33
  }
36
34
  }
37
35
 
@@ -28,22 +28,4 @@ export class ServiceOwner extends Base {
28
28
  get services() {
29
29
  return this._services;
30
30
  }
31
-
32
- materializeExtends() {
33
- super.materializeExtends();
34
-
35
- for (const [name, service] of this.mapFromDirections(
36
- ["extends"],
37
- "services"
38
- )) {
39
- const present = this.services.get(service.name);
40
-
41
- if (present) {
42
- present.extends.add(service);
43
- present.materializeExtends();
44
- } else {
45
- this.services.set(service.name, service.forOwner(this));
46
- }
47
- }
48
- }
49
31
  }
@@ -45,32 +45,33 @@ export class mosquitto extends CoreService {
45
45
  }
46
46
 
47
47
  async *preparePackages(dir) {
48
- const owner = "mosquitto";
49
- const group = "mosquitto";
48
+ const pm = this.root.named("/services/primary-SW/mosquitto");
50
49
 
50
+ console.log(
51
+ "MOSQUITTO",
52
+ pm.fullName,
53
+ this.fullName,
54
+ [...this.extends].map(n => n.fullName),
55
+ [...this.walkDirections(["this", "extends"])].map(n => this.fullName)
56
+ );
57
+
58
+ const permissions = this.packageContentPermissions;
51
59
  const packageData = this.packageData;
60
+
52
61
  packageData.sources = await Array.fromAsync(
53
- this.templateContent(
54
- {
55
- mode: 0o644,
56
- owner,
57
- group
58
- },
59
- {
60
- mode: 0o755,
61
- owner,
62
- group
63
- }
64
- )
62
+ this.templateContent(...permissions)
65
63
  );
66
64
 
67
- packageData.sources.push(new FileContentProvider(dir + "/"));
65
+ packageData.sources.push(
66
+ new FileContentProvider(dir + "/", ...permissions)
67
+ );
68
68
 
69
69
  await writeLines(
70
70
  join(dir, "etc", "mosquitto"),
71
71
  "mosquitto.conf",
72
72
  setionLinesFromAttributeIterator(
73
- this.attributeIterator(filterConfigurable), " "
73
+ this.attributeIterator(filterConfigurable),
74
+ " "
74
75
  )
75
76
  );
76
77
 
@@ -34,24 +34,11 @@ export class openldap extends CoreService {
34
34
  }
35
35
 
36
36
  async *preparePackages(dir) {
37
- const owner = "ldap";
38
- const group = "ldap";
39
-
37
+ const permissions = this.packageContentPermissions;
40
38
  const packageData = this.packageData;
41
39
 
42
40
  packageData.sources = await Array.fromAsync(
43
- this.templateContent(
44
- {
45
- mode: 0o644,
46
- owner,
47
- group
48
- },
49
- {
50
- mode: 0o755,
51
- owner,
52
- group
53
- }
54
- )
41
+ this.templateContent(...permissions)
55
42
  );
56
43
 
57
44
  yield packageData;
@@ -6,7 +6,7 @@ import {
6
6
  boolean_attribute_writable,
7
7
  yesno_attribute_writable
8
8
  } from "pacc";
9
- import { ExtraSourceService, serviceEndpoints, addType } from "pmcf";
9
+ import { ExtraSourceService, serviceEndpoints, addType, FAMILY_DNS } from "pmcf";
10
10
  import {
11
11
  filterConfigurable,
12
12
  yesno,
@@ -100,7 +100,7 @@ export class SystemdResolvedService extends ExtraSourceService {
100
100
  e.family == FAMILY_IPV4 &&
101
101
  e.networkInterface &&
102
102
  e.networkInterface.kind !== "loopback",
103
- //e.family !== "dns",
103
+ //e.family !== FAMILY_DNS,
104
104
  select: endpoint => endpoint.address,
105
105
  join: " ",
106
106
  limit