pmcf 6.59.2 → 6.60.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/README.md CHANGED
@@ -81,30 +81,30 @@ generates config packages for:
81
81
  * [domainNames](#domainnames)
82
82
  * [InitializationContext](#initializationcontext)
83
83
  * [Parameters](#parameters-14)
84
- * [SkeletonNetworkInterface](#skeletonnetworkinterface)
85
- * [networkAddresses](#networkaddresses)
86
- * [Parameters](#parameters-15)
87
84
  * [Interface](#interface)
88
85
  * [zones](#zones)
89
86
  * [addressesStatement](#addressesstatement)
90
- * [Parameters](#parameters-16)
87
+ * [Parameters](#parameters-15)
91
88
  * [SystemdJournalRemoteService](#systemdjournalremoteservice)
92
89
  * [Properties](#properties)
93
90
  * [systemdConfigs](#systemdconfigs)
94
- * [Parameters](#parameters-17)
91
+ * [Parameters](#parameters-16)
95
92
  * [SystemdJournalUploadService](#systemdjournaluploadservice)
96
93
  * [Properties](#properties-1)
97
94
  * [systemdConfigs](#systemdconfigs-1)
98
- * [Parameters](#parameters-18)
95
+ * [Parameters](#parameters-17)
99
96
  * [NetworkAddress](#networkaddress)
100
- * [Parameters](#parameters-19)
97
+ * [Parameters](#parameters-18)
101
98
  * [subnet](#subnet)
102
99
  * [networkInterface](#networkinterface)
103
100
  * [address](#address)
104
101
  * [addresses](#addresses)
105
- * [Parameters](#parameters-20)
102
+ * [Parameters](#parameters-19)
106
103
  * [cidrAddresses](#cidraddresses)
107
- * [Parameters](#parameters-21)
104
+ * [Parameters](#parameters-20)
105
+ * [SkeletonNetworkInterface](#skeletonnetworkinterface)
106
+ * [networkAddresses](#networkaddresses)
107
+ * [Parameters](#parameters-21)
108
108
  * [families](#families)
109
109
  * [secretName](#secretname)
110
110
  * [directHosts](#directhosts)
@@ -308,18 +308,6 @@ Keeps track of all in flight object creations and loose ends during config initi
308
308
 
309
309
  * `directory` (optional, default `"/"`)
310
310
 
311
- ## SkeletonNetworkInterface
312
-
313
- **Extends Interface**
314
-
315
- ### networkAddresses
316
-
317
- #### Parameters
318
-
319
- * `filter` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** (optional, default `n=>true`)
320
-
321
- Returns **Iterable<[NetworkAddress](#networkaddress)>**&#x20;
322
-
323
311
  ## Interface
324
312
 
325
313
  **Extends ServiceOwner**
@@ -413,6 +401,18 @@ Returns **Iterable<[string](https://developer.mozilla.org/docs/Web/JavaScript/Re
413
401
 
414
402
  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;
415
403
 
404
+ ## SkeletonNetworkInterface
405
+
406
+ **Extends Interface**
407
+
408
+ ### networkAddresses
409
+
410
+ #### Parameters
411
+
412
+ * `filter` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** (optional, default `n=>true`)
413
+
414
+ Returns **Iterable<[NetworkAddress](#networkaddress)>**&#x20;
415
+
416
416
  ## families
417
417
 
418
418
  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.59.2",
3
+ "version": "6.60.1",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -16,6 +16,7 @@ import {
16
16
  import { PROTOCOL_TCP, PROTOCOL_UDP, PROTOCOL_QUIC } from "./constants.mjs";
17
17
 
18
18
  export const SCOPE_SYSTEMD_NETWORKD = "systemd-networkd";
19
+ export const SCOPE_SYSTEMD_TIMESYNCD = "systemd-timesyncd";
19
20
 
20
21
  export const networkAddressType = "network|host|network_interface";
21
22
 
@@ -1,3 +1,4 @@
1
+ import { join } from "node:path";
1
2
  import {
2
3
  FAMILY_IPV4,
3
4
  FAMILY_IPV6,
@@ -10,7 +11,8 @@ import {
10
11
  number_attribute_writable,
11
12
  priority_attribute,
12
13
  default_collection_attribute_writable,
13
- asArray
14
+ asArray,
15
+ boolean_attribute_writable_false
14
16
  } from "pacc";
15
17
  import {
16
18
  base,
@@ -20,6 +22,7 @@ import {
20
22
  HTTPEndpoint,
21
23
  unix_endpoint
22
24
  } from "pmcf";
25
+ import { writeLines } from "./utils.mjs";
23
26
  import { addType } from "./type.mjs";
24
27
  import { FAMILY_UNIX, FAMILY_DNS } from "./constants.mjs";
25
28
  import {
@@ -42,6 +45,12 @@ import {
42
45
  } from "./dns-utils.mjs";
43
46
 
44
47
  export class credential extends base {
48
+ static attributes = {
49
+ systemdCredential: {
50
+ ...boolean_attribute_writable_false,
51
+ name: "systemdCredential"
52
+ }
53
+ };
45
54
  static {
46
55
  addType(this);
47
56
  }
@@ -66,7 +75,7 @@ export class CoreService extends base {
66
75
  }
67
76
  static attributes = {
68
77
  ...networkAddressAttributes,
69
- // networkInterfaces: networkInterfaces_attribute,
78
+ // networkInterfaces: networkInterfaces_attribute,
70
79
 
71
80
  ...endpointAttributes,
72
81
  extends: {
@@ -93,12 +102,16 @@ export class CoreService extends base {
93
102
  _weight;
94
103
  _port;
95
104
  _systemdService;
96
- credentials = new Map();
105
+ _credentials = new Map();
97
106
 
98
107
  toString() {
99
108
  return `${this.fullName}(${this.type})`;
100
109
  }
101
110
 
111
+ get credentials() {
112
+ return this.mapFromDirections(["this", "extends"], "_credentials")
113
+ }
114
+
102
115
  get network() {
103
116
  return this.owner.network;
104
117
  }
@@ -270,6 +283,30 @@ export class CoreService extends base {
270
283
  return serviceTypes(ServiceTypes[this.type]);
271
284
  }
272
285
 
286
+ async writeSystemdCredentialConfig(dir, name) {
287
+ let lines = [];
288
+
289
+ const seen = new Set();
290
+
291
+ for (const [name, cred] of this.credentials) {
292
+ //console.log(this.fullName,name);
293
+ if (cred.systemdCredential && !seen.has(name)) {
294
+ seen.add(name);
295
+ lines.push(
296
+ `LoadCredentialEncrypted=${name}:/etc/credstore.encrypted/${name}`
297
+ );
298
+ }
299
+ }
300
+
301
+ if (lines.length) {
302
+ await writeLines(
303
+ join(dir, `etc/systemd/system/${name}.service.d`),
304
+ `credentials.conf`,
305
+ lines
306
+ );
307
+ }
308
+ }
309
+
273
310
  get systemdService() {
274
311
  return (
275
312
  this.attribute("_systemdService") ??
@@ -4,8 +4,10 @@ import {
4
4
  string_attribute_writable,
5
5
  string_set_attribute_writable
6
6
  } from "pacc";
7
- import { addType, CoreService, base } from "pmcf";
7
+ import { base } from "../base.mjs";
8
+ import { CoreService } from "../core-service.mjs";
8
9
  import { owner_attribute } from "../common-attributes.mjs";
10
+ import { addType } from "../type.mjs";
9
11
 
10
12
  class alpm_repository extends base {
11
13
  static attributes = {
@@ -404,7 +404,9 @@ export class kea extends CoreService {
404
404
 
405
405
  if (addr && subnet.matchesAddress(addr)) {
406
406
  ip =
407
- family === "6" ? { "ip-addresses": [addr] } : { "ip-address": addr };
407
+ family === "6"
408
+ ? { "ip-addresses": [addr] }
409
+ : { "ip-address": addr };
408
410
  }
409
411
 
410
412
  let ids = { "hw-address": k };
@@ -468,6 +470,9 @@ export class kea extends CoreService {
468
470
 
469
471
  const packageData = await this.preparePackage(dir);
470
472
 
473
+ await this.writeSystemdCredentialConfig(dir, "kea-dhcp4");
474
+ await this.writeSystemdCredentialConfig(dir, "kea-dhcp6");
475
+
471
476
  for (const [name, data] of Object.entries({
472
477
  "kea-dhcp-ddns": ddns,
473
478
  "kea-dhcp4": dhcp4,
@@ -1,40 +1,46 @@
1
1
  import { string_attribute_writable, duration_attribute_writable } from "pacc";
2
- import { ExtraSourceService, serviceEndpoints, addType } from "pmcf";
3
- import { filterConfigurable, sectionLines } from "../utils.mjs";
2
+ import { ExtraSourceService, serviceEndpoints } from "pmcf";
3
+ import { sectionLines } from "../utils.mjs";
4
+ import { SCOPE_SYSTEMD_TIMESYNCD } from "../common-attributes.mjs";
5
+ import { addType } from "../type.mjs";
4
6
 
5
7
  export class SystemdTimesyncdService extends ExtraSourceService {
6
8
  static name = "systemd-timesyncd";
7
9
  static attributes = {
8
- NTP: { ...string_attribute_writable, name: "NTP", configurable: true },
10
+ NTP: {
11
+ ...string_attribute_writable,
12
+ name: "NTP",
13
+ scope: SCOPE_SYSTEMD_TIMESYNCD
14
+ },
9
15
  FallbackNTP: {
10
16
  ...string_attribute_writable,
11
17
  name: "FallbackNTP",
12
- configurable: true
18
+ scope: SCOPE_SYSTEMD_TIMESYNCD
13
19
  },
14
20
  RootDistanceMaxSec: {
15
21
  ...duration_attribute_writable,
16
22
  name: "RootDistanceMaxSec",
17
- configurable: true
23
+ scope: SCOPE_SYSTEMD_TIMESYNCD
18
24
  },
19
25
  PollIntervalMinSec: {
20
26
  ...duration_attribute_writable,
21
27
  name: "PollIntervalMinSec",
22
- configurable: true
28
+ scope: SCOPE_SYSTEMD_TIMESYNCD
23
29
  },
24
30
  PollIntervalMaxSec: {
25
31
  ...duration_attribute_writable,
26
32
  name: "PollIntervalMaxSec",
27
- configurable: true
33
+ scope: SCOPE_SYSTEMD_TIMESYNCD
28
34
  },
29
35
  ConnectionRetrySec: {
30
36
  ...duration_attribute_writable,
31
37
  name: "ConnectionRetrySec",
32
- configurable: true
38
+ scope: SCOPE_SYSTEMD_TIMESYNCD
33
39
  },
34
40
  SaveIntervalSec: {
35
41
  ...duration_attribute_writable,
36
42
  name: "SaveIntervalSec",
37
- configurable: true
43
+ scope: SCOPE_SYSTEMD_TIMESYNCD
38
44
  }
39
45
  };
40
46
  static service = {
@@ -63,7 +69,9 @@ export class SystemdTimesyncdService extends ExtraSourceService {
63
69
  content: sectionLines("Time", {
64
70
  NTP: serviceEndpoints(this, options(300, 399)),
65
71
  FallbackNTP: serviceEndpoints(this, options(100, 199)),
66
- ...this.getAttributes(filterConfigurable)
72
+ ...this.getAttributes(
73
+ attribute => attribute.scope === SCOPE_SYSTEMD_TIMESYNCD
74
+ )
67
75
  })
68
76
  };
69
77
  }