pmcf 2.56.0 → 2.58.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/bin/pmcf-package CHANGED
@@ -30,10 +30,10 @@ const publishingDetails = createPublishingDetails(
30
30
  env
31
31
  );
32
32
 
33
- for (const name of args) {
34
- const object = await root.load(name);
33
+ for (const object of root.find(args)) {
35
34
  const stagingDir = join(options.output, object.fullName);
36
35
 
36
+ //console.log(`packages for ${object.fullName}`);
37
37
  for await (const { sources, outputs, properties } of object.preparePackages(
38
38
  stagingDir
39
39
  )) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pmcf",
3
- "version": "2.56.0",
3
+ "version": "2.58.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
package/src/base.mjs CHANGED
@@ -111,11 +111,10 @@ export class Base {
111
111
  if (Array.isArray(current)) {
112
112
  current.push(value);
113
113
  } else {
114
- if(current instanceof Set) {
114
+ if (current instanceof Set) {
115
115
  // TODO
116
116
  this[property.name] = value;
117
- }
118
- else if (current instanceof Map) {
117
+ } else if (current instanceof Map) {
119
118
  // TODO
120
119
  this[property.name] = value;
121
120
  } else {
@@ -427,16 +426,7 @@ export class Base {
427
426
  return new Set(allOutputs.filter(o => this.packaging.has(o.name)));
428
427
  }
429
428
 
430
- async *preparePackages(stagingDir) {
431
- yield {
432
- sources: [],
433
- outputs: this.outputs,
434
- properties: {
435
- description: `${this.typeName} definitions for ${this.fullName}`,
436
- access: "private"
437
- }
438
- };
439
- }
429
+ async *preparePackages(stagingDir) {}
440
430
 
441
431
  get tags() {
442
432
  return this._tags;
@@ -509,6 +499,7 @@ export class Base {
509
499
  traverse(visitor, ...args) {
510
500
  const visited = new Set();
511
501
  this._traverse(visited, visitor, ...args);
502
+ return visited;
512
503
  }
513
504
 
514
505
  _traverse(visited, visitor, ...args) {
package/src/cluster.mjs CHANGED
@@ -118,7 +118,7 @@ export class Cluster extends Host {
118
118
  cfg.push(" }");
119
119
  cfg.push(` virtual_router_id ${cluster.routerId}`);
120
120
  cfg.push(
121
- ` priority ${host.priority - (cluster.masters.has(ni) ? 0 : 5)}`
121
+ ` priority ${host.priority - 100 + (cluster.masters.has(ni) ? 0 : 5)}`
122
122
  );
123
123
  cfg.push(" smtp_alert");
124
124
  cfg.push(" advert_int 5");
package/src/dns-utils.mjs CHANGED
@@ -23,13 +23,17 @@ export function sortZoneRecords(a, b) {
23
23
  if (a.type === "PTR") {
24
24
  const toNum = a => {
25
25
  const s = a.split(".");
26
- s.pop();s.pop();s.pop();
27
- return s.reverse().reduce((a, c) => BigInt(parseInt(c,16)) + 256n * 256n * a, 0n);
26
+ s.pop();
27
+ s.pop();
28
+ s.pop();
29
+ return s
30
+ .reverse()
31
+ .reduce((a, c) => BigInt(parseInt(c, 16)) + 256n * 256n * a, 0n);
28
32
  };
29
33
  return Number(toNum(a.key) - toNum(b.key));
30
34
  }
31
35
  order = a.key.localeCompare(b.key);
32
- if(order) {
36
+ if (order) {
33
37
  return order;
34
38
  }
35
39
 
@@ -100,3 +104,7 @@ export function dnsMergeParameters(a, b) {
100
104
  ])
101
105
  );
102
106
  }
107
+
108
+ export function dnsPriority(priority) {
109
+ return 500 - (priority ?? 10);
110
+ }
package/src/owner.mjs CHANGED
@@ -3,6 +3,7 @@ import { asIterator } from "./utils.mjs";
3
3
  import { Base } from "./base.mjs";
4
4
  import { Subnet, SUBNET_GLOBAL_IPV4, SUBNET_GLOBAL_IPV6 } from "./subnet.mjs";
5
5
  import { addType, types } from "./types.mjs";
6
+
6
7
  const OwnerTypeDefinition = {
7
8
  name: "owner",
8
9
  owners: ["location", "owner", "root"],
@@ -57,6 +58,17 @@ export class Owner extends Base {
57
58
  return false;
58
59
  }
59
60
 
61
+ *find(pattern) {
62
+ for (const node of this.traverse(() => {})) {
63
+ for (const p of pattern) {
64
+ if (node.fullName.match(p)) {
65
+ yield node;
66
+ break;
67
+ }
68
+ }
69
+ }
70
+ }
71
+
60
72
  named(name) {
61
73
  if (name[0] === "/") {
62
74
  name = name.substring(this.fullName.length + 1);
@@ -185,9 +197,10 @@ export class Owner extends Base {
185
197
  }
186
198
 
187
199
  let subnet = this.subnetForAddress(address);
188
-
200
+
189
201
  if (!subnet) {
190
- subnet = familyIP(address) === 'IPv4' ? SUBNET_GLOBAL_IPV4 : SUBNET_GLOBAL_IPV6;
202
+ subnet =
203
+ familyIP(address) === "IPv4" ? SUBNET_GLOBAL_IPV4 : SUBNET_GLOBAL_IPV6;
191
204
 
192
205
  /*
193
206
  this.error(
@@ -196,7 +209,7 @@ export class Owner extends Base {
196
209
  );
197
210
  */
198
211
  }
199
-
212
+
200
213
  return subnet;
201
214
  }
202
215
 
@@ -216,8 +229,7 @@ export class Owner extends Base {
216
229
  return this.typeList("cluster");
217
230
  }
218
231
 
219
- get bridges()
220
- {
232
+ get bridges() {
221
233
  return this._bridges;
222
234
  }
223
235
 
package/src/service.mjs CHANGED
@@ -6,7 +6,8 @@ import {
6
6
  DNSRecord,
7
7
  dnsFullName,
8
8
  dnsFormatParameters,
9
- dnsMergeParameters
9
+ dnsMergeParameters,
10
+ dnsPriority
10
11
  } from "./dns-utils.mjs";
11
12
 
12
13
  const ServiceTypes = {
@@ -268,7 +269,7 @@ export class Service extends Base {
268
269
 
269
270
  dnsRecordsForDomainName(domainName, hasSVRRecords) {
270
271
  const records = [];
271
- if (this.priority <= 1 && this.alias) {
272
+ if (this.priority >= 390 && this.alias) {
272
273
  records.push(DNSRecord(this.alias, "CNAME", dnsFullName(domainName)));
273
274
  }
274
275
 
@@ -283,7 +284,7 @@ export class Service extends Base {
283
284
  DNSRecord(
284
285
  dnsFullName(`_${this.type}._${ep.protocol}.${domainName}`),
285
286
  "SRV",
286
- this.priority ?? 10,
287
+ dnsPriority(this.priority),
287
288
  this.weight,
288
289
  ep.port,
289
290
  dnsFullName(this.domainName)
@@ -311,7 +312,7 @@ export class Service extends Base {
311
312
  DNSRecord(
312
313
  dnsFullName(domainName),
313
314
  dnsRecord.type,
314
- this.priority ?? 10,
315
+ dnsPriority(this.priority),
315
316
  ".",
316
317
  dnsFormatParameters(parameters)
317
318
  )
@@ -321,7 +322,7 @@ export class Service extends Base {
321
322
  DNSRecord(
322
323
  "@",
323
324
  dnsRecord.type,
324
- this.priority ?? 10,
325
+ dnsPriority(this.priority),
325
326
  dnsFullName(domainName)
326
327
  )
327
328
  );
@@ -236,7 +236,7 @@ export class BindService extends ExtraSourceService {
236
236
  };
237
237
 
238
238
  const forwarders = serviceEndpoints(this.source, {
239
- services: { type: "dns", priority: ">=20" },
239
+ services: { type: "dns", priority: ">=300" },
240
240
  select: e => e.address,
241
241
  limit: 5
242
242
  });
@@ -535,7 +535,7 @@ export class BindService extends ExtraSourceService {
535
535
  }
536
536
 
537
537
  get defaultRecords() {
538
- const nameService = this.findService({ type: "dns", priority: "<10" });
538
+ const nameService = this.findService({ type: "dns", priority: ">=300" });
539
539
 
540
540
  const SOARecord = DNSRecord(
541
541
  "@",
@@ -58,7 +58,7 @@ export class ChronyService extends ExtraSourceService {
58
58
  ...serviceEndpoints(this, {
59
59
  services: {
60
60
  type: "ntp",
61
- priority: "<10"
61
+ priority: ">=200"
62
62
  },
63
63
  endpoints: e =>
64
64
  e.service.host !== host &&
@@ -125,6 +125,14 @@ export class KeaService extends Service {
125
125
  }
126
126
 
127
127
  async *preparePackages(dir) {
128
+ const ctrlAgentEndpoint = this.endpoint(
129
+ e => e.type === "kea-control-agent"
130
+ );
131
+
132
+ if (!ctrlAgentEndpoint) {
133
+ return;
134
+ }
135
+
128
136
  const network = this.network;
129
137
  const host = this.host;
130
138
  const name = host.name;
@@ -134,7 +142,7 @@ export class KeaService extends Service {
134
142
  const dnsServerEndpoints = serviceEndpoints(network, {
135
143
  services: {
136
144
  type: "dns",
137
- priority: "<10"
145
+ priority: ">=300"
138
146
  },
139
147
  endpoints: endpoint => endpoint.networkInterface.kind !== "loopback"
140
148
  });
@@ -151,14 +159,10 @@ export class KeaService extends Service {
151
159
  }
152
160
  };
153
161
 
154
- const ctrlAgentEndpoint = this.endpoint(
155
- e => e.type === "kea-control-agent"
156
- );
157
-
158
162
  const peers = async family =>
159
163
  (
160
164
  await Array.fromAsync(
161
- network.findServices({ type: "dhcp", priority: "<20" })
165
+ network.findServices({ type: "dhcp", priority: ">=200" })
162
166
  )
163
167
  )
164
168
  .sort(sortInverseByPriority)
@@ -171,13 +175,16 @@ export class KeaService extends Service {
171
175
  : "kea-control-agent")
172
176
  );
173
177
 
174
- return {
175
- name: dhcp.host.name,
176
- role: i === 0 ? "primary" : i > 1 ? "backup" : "standby",
177
- url: ctrlAgentEndpoint.url,
178
- "auto-failover": i <= 1
179
- };
180
- });
178
+ if (ctrlAgentEndpoint) {
179
+ return {
180
+ name: dhcp.host.name,
181
+ role: i === 0 ? "primary" : i > 1 ? "backup" : "standby",
182
+ url: ctrlAgentEndpoint.url,
183
+ "auto-failover": i <= 1
184
+ };
185
+ }
186
+ })
187
+ .filter(p => p != null);
181
188
 
182
189
  const loggers = [
183
190
  {
package/types/base.d.mts CHANGED
@@ -94,14 +94,7 @@ export class Base {
94
94
  get packaging(): Set<any>;
95
95
  get derivedPackaging(): any;
96
96
  get outputs(): Set<typeof import("npm-pkgbuild").ARCH | typeof import("npm-pkgbuild").DOCKER>;
97
- preparePackages(stagingDir: any): AsyncGenerator<{
98
- sources: any[];
99
- outputs: Set<typeof import("npm-pkgbuild").ARCH | typeof import("npm-pkgbuild").DOCKER>;
100
- properties: {
101
- description: string;
102
- access: string;
103
- };
104
- }, void, unknown>;
97
+ preparePackages(stagingDir: any): AsyncGenerator<never, void, unknown>;
105
98
  set tags(value: Set<any>);
106
99
  get tags(): Set<any>;
107
100
  get isTemplate(): boolean;
@@ -109,7 +102,7 @@ export class Base {
109
102
  finalize(action: any): void;
110
103
  execFinalize(): void;
111
104
  _execFinalize(): void;
112
- traverse(visitor: any, ...args: any[]): void;
105
+ traverse(visitor: any, ...args: any[]): Set<any>;
113
106
  _traverse(visited: any, visitor: any, ...args: any[]): boolean;
114
107
  error(...args: any[]): void;
115
108
  info(...args: any[]): void;
@@ -11,3 +11,4 @@ export function dnsFormatParameters(parameters: any): string;
11
11
  export function dnsMergeParameters(a: any, b: any): {
12
12
  [k: string]: Set<any>;
13
13
  };
14
+ export function dnsPriority(priority: any): number;
package/types/owner.d.mts CHANGED
@@ -134,6 +134,7 @@ export class Owner extends Base {
134
134
  _membersByType: Map<any, any>;
135
135
  _bridges: Set<any>;
136
136
  _traverse(...args: any[]): boolean;
137
+ find(pattern: any): Generator<any, void, unknown>;
137
138
  named(name: any): any;
138
139
  typeObject(typeName: any): any;
139
140
  typeList(typeName: any): any;