@kapeta/local-cluster-service 0.42.1 → 0.43.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/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ # [0.43.0](https://github.com/kapetacom/local-cluster-service/compare/v0.42.1...v0.43.0) (2024-05-01)
2
+
3
+
4
+ ### Features
5
+
6
+ * Add support for optional binds in local definitions ([#142](https://github.com/kapetacom/local-cluster-service/issues/142)) ([2406aac](https://github.com/kapetacom/local-cluster-service/commit/2406aac9d34d625e07dd98debb67cbcec642deeb))
7
+
1
8
  ## [0.42.1](https://github.com/kapetacom/local-cluster-service/compare/v0.42.0...v0.42.1) (2024-05-01)
2
9
 
3
10
 
@@ -252,15 +252,25 @@ class BlockInstanceRunner {
252
252
  Binds: [
253
253
  `${(0, containerManager_1.toLocalBindVolume)(local_cluster_config_1.default.getKapetaBasedir())}:${homeDir}/.kapeta`,
254
254
  ...Binds.map((bind) => {
255
- let [host, container] = bind.split(':');
255
+ let options = bind.split(':');
256
+ let host = options.shift();
257
+ let container = options.shift();
256
258
  if (host.startsWith('~')) {
257
259
  host = node_os_1.default.homedir() + host.substring(1);
258
260
  }
259
261
  if (container.startsWith('~')) {
260
262
  container = homeDir + container.substring(1);
261
263
  }
262
- return `${(0, containerManager_1.toLocalBindVolume)(host)}:${container}`;
263
- }),
264
+ if (options.includes('optional')) {
265
+ // If the bind is optional, we skip it if the host path does not exist
266
+ options = options.filter((opt) => opt !== 'optional');
267
+ if (!fs_extra_1.default.existsSync(host)) {
268
+ console.log(`Skipping optional bind: ${bind} for block: ${blockInstance.id}`);
269
+ return '';
270
+ }
271
+ }
272
+ return `${(0, containerManager_1.toLocalBindVolume)(host)}:${container}${options.length > 0 ? ':' + options.join(':') : ''}`;
273
+ }).filter((bind) => Boolean(bind)),
264
274
  ],
265
275
  PortBindings,
266
276
  Mounts,
@@ -252,15 +252,25 @@ class BlockInstanceRunner {
252
252
  Binds: [
253
253
  `${(0, containerManager_1.toLocalBindVolume)(local_cluster_config_1.default.getKapetaBasedir())}:${homeDir}/.kapeta`,
254
254
  ...Binds.map((bind) => {
255
- let [host, container] = bind.split(':');
255
+ let options = bind.split(':');
256
+ let host = options.shift();
257
+ let container = options.shift();
256
258
  if (host.startsWith('~')) {
257
259
  host = node_os_1.default.homedir() + host.substring(1);
258
260
  }
259
261
  if (container.startsWith('~')) {
260
262
  container = homeDir + container.substring(1);
261
263
  }
262
- return `${(0, containerManager_1.toLocalBindVolume)(host)}:${container}`;
263
- }),
264
+ if (options.includes('optional')) {
265
+ // If the bind is optional, we skip it if the host path does not exist
266
+ options = options.filter((opt) => opt !== 'optional');
267
+ if (!fs_extra_1.default.existsSync(host)) {
268
+ console.log(`Skipping optional bind: ${bind} for block: ${blockInstance.id}`);
269
+ return '';
270
+ }
271
+ }
272
+ return `${(0, containerManager_1.toLocalBindVolume)(host)}:${container}${options.length > 0 ? ':' + options.join(':') : ''}`;
273
+ }).filter((bind) => Boolean(bind)),
264
274
  ],
265
275
  PortBindings,
266
276
  Mounts,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kapeta/local-cluster-service",
3
- "version": "0.42.1",
3
+ "version": "0.43.0",
4
4
  "description": "Manages configuration, ports and service discovery for locally running Kapeta systems",
5
5
  "type": "commonjs",
6
6
  "exports": {
@@ -351,7 +351,10 @@ export class BlockInstanceRunner {
351
351
  Binds: [
352
352
  `${toLocalBindVolume(ClusterConfig.getKapetaBasedir())}:${homeDir}/.kapeta`,
353
353
  ...Binds.map((bind: string) => {
354
- let [host, container] = bind.split(':');
354
+ let options = bind.split(':');
355
+ let host = options.shift()!;
356
+ let container = options.shift()!;
357
+
355
358
  if (host.startsWith('~')) {
356
359
  host = OS.homedir() + host.substring(1);
357
360
  }
@@ -360,8 +363,17 @@ export class BlockInstanceRunner {
360
363
  container = homeDir + container.substring(1);
361
364
  }
362
365
 
363
- return `${toLocalBindVolume(host)}:${container}`;
364
- }),
366
+ if (options.includes('optional')) {
367
+ // If the bind is optional, we skip it if the host path does not exist
368
+ options = options.filter((opt) => opt !== 'optional');
369
+ if (!FSExtra.existsSync(host)) {
370
+ console.log(`Skipping optional bind: ${bind} for block: ${blockInstance.id}`)
371
+ return '';
372
+ }
373
+ }
374
+
375
+ return `${toLocalBindVolume(host)}:${container}${options.length > 0 ? ':' + options.join(':') : ''}`;
376
+ }).filter((bind: string) => Boolean(bind)),
365
377
  ],
366
378
  PortBindings,
367
379
  Mounts,