@kapeta/local-cluster-service 0.7.2 → 0.7.3
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 +7 -0
- package/dist/cjs/src/containerManager.d.ts +8 -0
- package/dist/cjs/src/containerManager.js +21 -2
- package/dist/cjs/src/utils/BlockInstanceRunner.js +7 -5
- package/dist/esm/src/containerManager.d.ts +8 -0
- package/dist/esm/src/containerManager.js +19 -1
- package/dist/esm/src/utils/BlockInstanceRunner.js +8 -6
- package/package.json +1 -1
- package/src/containerManager.ts +20 -2
- package/src/utils/BlockInstanceRunner.ts +8 -6
package/CHANGELOG.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
## [0.7.3](https://github.com/kapetacom/local-cluster-service/compare/v0.7.2...v0.7.3) (2023-07-17)
|
2
|
+
|
3
|
+
|
4
|
+
### Bug Fixes
|
5
|
+
|
6
|
+
* Handle windows paths ([45eedcb](https://github.com/kapetacom/local-cluster-service/commit/45eedcb4b95a1d403d88dd63d74fa98b2c949559))
|
7
|
+
|
1
8
|
## [0.7.2](https://github.com/kapetacom/local-cluster-service/compare/v0.7.1...v0.7.2) (2023-07-16)
|
2
9
|
|
3
10
|
|
@@ -85,5 +85,13 @@ export declare class ContainerInfo {
|
|
85
85
|
getStatus(): Promise<any>;
|
86
86
|
getPorts(): Promise<PortMap | false>;
|
87
87
|
}
|
88
|
+
/**
|
89
|
+
* Ensure that the volume is in the correct format for the docker daemon on the host
|
90
|
+
*
|
91
|
+
* Windows: c:\path\to\volume -> /c/path/to/volume
|
92
|
+
* Linux: /path/to/volume -> /path/to/volume
|
93
|
+
* Mac: /path/to/volume -> /path/to/volume
|
94
|
+
*/
|
95
|
+
export declare function toLocalBindVolume(volume: string): string;
|
88
96
|
export declare const containerManager: ContainerManager;
|
89
97
|
export {};
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
4
|
};
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
exports.containerManager = exports.ContainerInfo = void 0;
|
6
|
+
exports.containerManager = exports.toLocalBindVolume = exports.ContainerInfo = void 0;
|
7
7
|
const path_1 = __importDefault(require("path"));
|
8
8
|
const storageService_1 = require("./storageService");
|
9
9
|
const os_1 = __importDefault(require("os"));
|
@@ -143,7 +143,7 @@ class ContainerManager {
|
|
143
143
|
lodash_1.default.forEach(mounts, (Source, Target) => {
|
144
144
|
Mounts.push({
|
145
145
|
Target,
|
146
|
-
Source,
|
146
|
+
Source: toLocalBindVolume(Source),
|
147
147
|
Type: 'bind',
|
148
148
|
ReadOnly: false,
|
149
149
|
Consistency: 'consistent',
|
@@ -362,4 +362,23 @@ class ContainerInfo {
|
|
362
362
|
}
|
363
363
|
}
|
364
364
|
exports.ContainerInfo = ContainerInfo;
|
365
|
+
/**
|
366
|
+
* Ensure that the volume is in the correct format for the docker daemon on the host
|
367
|
+
*
|
368
|
+
* Windows: c:\path\to\volume -> /c/path/to/volume
|
369
|
+
* Linux: /path/to/volume -> /path/to/volume
|
370
|
+
* Mac: /path/to/volume -> /path/to/volume
|
371
|
+
*/
|
372
|
+
function toLocalBindVolume(volume) {
|
373
|
+
if (process.platform === 'win32') {
|
374
|
+
//On Windows we need to convert c:\ to /c/
|
375
|
+
return volume
|
376
|
+
.replace(/^([a-z]):\\/i, (match, drive) => {
|
377
|
+
return '/' + drive.toLowerCase() + '/';
|
378
|
+
})
|
379
|
+
.replace(/\\(\S)/g, '/$1');
|
380
|
+
}
|
381
|
+
return volume;
|
382
|
+
}
|
383
|
+
exports.toLocalBindVolume = toLocalBindVolume;
|
365
384
|
exports.containerManager = new ContainerManager();
|
@@ -204,8 +204,8 @@ class BlockInstanceRunner {
|
|
204
204
|
],
|
205
205
|
HostConfig: {
|
206
206
|
Binds: [
|
207
|
-
`${local_cluster_config_1.default.getKapetaBasedir()}:${homeDir}/.kapeta`,
|
208
|
-
`${baseDir}:${workingDir}`, //We mount
|
207
|
+
`${(0, containerManager_1.toLocalBindVolume)(local_cluster_config_1.default.getKapetaBasedir())}:${homeDir}/.kapeta`,
|
208
|
+
`${(0, containerManager_1.toLocalBindVolume)(baseDir)}:${workingDir}`, //We mount
|
209
209
|
],
|
210
210
|
PortBindings,
|
211
211
|
},
|
@@ -315,7 +315,9 @@ class BlockInstanceRunner {
|
|
315
315
|
...Object.entries(env).map(([key, value]) => `${key}=${value}`),
|
316
316
|
],
|
317
317
|
HostConfig: {
|
318
|
-
Binds: [
|
318
|
+
Binds: [
|
319
|
+
`${(0, containerManager_1.toLocalBindVolume)(local_cluster_config_1.default.getKapetaBasedir())}:${local_cluster_config_1.default.getKapetaBasedir()}`,
|
320
|
+
],
|
319
321
|
},
|
320
322
|
});
|
321
323
|
try {
|
@@ -426,8 +428,8 @@ class BlockInstanceRunner {
|
|
426
428
|
HealthCheck,
|
427
429
|
HostConfig: {
|
428
430
|
Binds: [
|
429
|
-
`${kapetaYmlPath}:/kapeta.yml:ro`,
|
430
|
-
`${local_cluster_config_1.default.getKapetaBasedir()}:${local_cluster_config_1.default.getKapetaBasedir()}`,
|
431
|
+
`${(0, containerManager_1.toLocalBindVolume)(kapetaYmlPath)}:/kapeta.yml:ro`,
|
432
|
+
`${(0, containerManager_1.toLocalBindVolume)(local_cluster_config_1.default.getKapetaBasedir())}:${local_cluster_config_1.default.getKapetaBasedir()}`,
|
431
433
|
],
|
432
434
|
PortBindings,
|
433
435
|
Mounts,
|
@@ -85,5 +85,13 @@ export declare class ContainerInfo {
|
|
85
85
|
getStatus(): Promise<any>;
|
86
86
|
getPorts(): Promise<PortMap | false>;
|
87
87
|
}
|
88
|
+
/**
|
89
|
+
* Ensure that the volume is in the correct format for the docker daemon on the host
|
90
|
+
*
|
91
|
+
* Windows: c:\path\to\volume -> /c/path/to/volume
|
92
|
+
* Linux: /path/to/volume -> /path/to/volume
|
93
|
+
* Mac: /path/to/volume -> /path/to/volume
|
94
|
+
*/
|
95
|
+
export declare function toLocalBindVolume(volume: string): string;
|
88
96
|
export declare const containerManager: ContainerManager;
|
89
97
|
export {};
|
@@ -137,7 +137,7 @@ class ContainerManager {
|
|
137
137
|
_.forEach(mounts, (Source, Target) => {
|
138
138
|
Mounts.push({
|
139
139
|
Target,
|
140
|
-
Source,
|
140
|
+
Source: toLocalBindVolume(Source),
|
141
141
|
Type: 'bind',
|
142
142
|
ReadOnly: false,
|
143
143
|
Consistency: 'consistent',
|
@@ -355,4 +355,22 @@ export class ContainerInfo {
|
|
355
355
|
return ports;
|
356
356
|
}
|
357
357
|
}
|
358
|
+
/**
|
359
|
+
* Ensure that the volume is in the correct format for the docker daemon on the host
|
360
|
+
*
|
361
|
+
* Windows: c:\path\to\volume -> /c/path/to/volume
|
362
|
+
* Linux: /path/to/volume -> /path/to/volume
|
363
|
+
* Mac: /path/to/volume -> /path/to/volume
|
364
|
+
*/
|
365
|
+
export function toLocalBindVolume(volume) {
|
366
|
+
if (process.platform === 'win32') {
|
367
|
+
//On Windows we need to convert c:\ to /c/
|
368
|
+
return volume
|
369
|
+
.replace(/^([a-z]):\\/i, (match, drive) => {
|
370
|
+
return '/' + drive.toLowerCase() + '/';
|
371
|
+
})
|
372
|
+
.replace(/\\(\S)/g, '/$1');
|
373
|
+
}
|
374
|
+
return volume;
|
375
|
+
}
|
358
376
|
export const containerManager = new ContainerManager();
|
@@ -3,7 +3,7 @@ import ClusterConfig from '@kapeta/local-cluster-config';
|
|
3
3
|
import { readYML } from './utils';
|
4
4
|
import { parseKapetaUri } from '@kapeta/nodejs-utils';
|
5
5
|
import { serviceManager } from '../serviceManager';
|
6
|
-
import { containerManager } from '../containerManager';
|
6
|
+
import { containerManager, toLocalBindVolume } from '../containerManager';
|
7
7
|
import { LogData } from './LogData';
|
8
8
|
import EventEmitter from 'events';
|
9
9
|
import md5 from 'md5';
|
@@ -198,8 +198,8 @@ export class BlockInstanceRunner {
|
|
198
198
|
],
|
199
199
|
HostConfig: {
|
200
200
|
Binds: [
|
201
|
-
`${ClusterConfig.getKapetaBasedir()}:${homeDir}/.kapeta`,
|
202
|
-
`${baseDir}:${workingDir}`, //We mount
|
201
|
+
`${toLocalBindVolume(ClusterConfig.getKapetaBasedir())}:${homeDir}/.kapeta`,
|
202
|
+
`${toLocalBindVolume(baseDir)}:${workingDir}`, //We mount
|
203
203
|
],
|
204
204
|
PortBindings,
|
205
205
|
},
|
@@ -309,7 +309,9 @@ export class BlockInstanceRunner {
|
|
309
309
|
...Object.entries(env).map(([key, value]) => `${key}=${value}`),
|
310
310
|
],
|
311
311
|
HostConfig: {
|
312
|
-
Binds: [
|
312
|
+
Binds: [
|
313
|
+
`${toLocalBindVolume(ClusterConfig.getKapetaBasedir())}:${ClusterConfig.getKapetaBasedir()}`,
|
314
|
+
],
|
313
315
|
},
|
314
316
|
});
|
315
317
|
try {
|
@@ -420,8 +422,8 @@ export class BlockInstanceRunner {
|
|
420
422
|
HealthCheck,
|
421
423
|
HostConfig: {
|
422
424
|
Binds: [
|
423
|
-
`${kapetaYmlPath}:/kapeta.yml:ro`,
|
424
|
-
`${ClusterConfig.getKapetaBasedir()}:${ClusterConfig.getKapetaBasedir()}`,
|
425
|
+
`${toLocalBindVolume(kapetaYmlPath)}:/kapeta.yml:ro`,
|
426
|
+
`${toLocalBindVolume(ClusterConfig.getKapetaBasedir())}:${ClusterConfig.getKapetaBasedir()}`,
|
425
427
|
],
|
426
428
|
PortBindings,
|
427
429
|
Mounts,
|
package/package.json
CHANGED
package/src/containerManager.ts
CHANGED
@@ -189,7 +189,7 @@ class ContainerManager {
|
|
189
189
|
_.forEach(mounts, (Source, Target) => {
|
190
190
|
Mounts.push({
|
191
191
|
Target,
|
192
|
-
Source,
|
192
|
+
Source: toLocalBindVolume(Source),
|
193
193
|
Type: 'bind',
|
194
194
|
ReadOnly: false,
|
195
195
|
Consistency: 'consistent',
|
@@ -252,7 +252,6 @@ class ContainerManager {
|
|
252
252
|
Hostname: name + '.kapeta',
|
253
253
|
Labels,
|
254
254
|
Cmd: opts.cmd,
|
255
|
-
|
256
255
|
ExposedPorts,
|
257
256
|
Env,
|
258
257
|
HealthCheck,
|
@@ -463,4 +462,23 @@ export class ContainerInfo {
|
|
463
462
|
}
|
464
463
|
}
|
465
464
|
|
465
|
+
/**
|
466
|
+
* Ensure that the volume is in the correct format for the docker daemon on the host
|
467
|
+
*
|
468
|
+
* Windows: c:\path\to\volume -> /c/path/to/volume
|
469
|
+
* Linux: /path/to/volume -> /path/to/volume
|
470
|
+
* Mac: /path/to/volume -> /path/to/volume
|
471
|
+
*/
|
472
|
+
export function toLocalBindVolume(volume: string): string {
|
473
|
+
if (process.platform === 'win32') {
|
474
|
+
//On Windows we need to convert c:\ to /c/
|
475
|
+
return volume
|
476
|
+
.replace(/^([a-z]):\\/i, (match, drive) => {
|
477
|
+
return '/' + drive.toLowerCase() + '/';
|
478
|
+
})
|
479
|
+
.replace(/\\(\S)/g, '/$1');
|
480
|
+
}
|
481
|
+
return volume;
|
482
|
+
}
|
483
|
+
|
466
484
|
export const containerManager = new ContainerManager();
|
@@ -3,7 +3,7 @@ import ClusterConfig, { DefinitionInfo } from '@kapeta/local-cluster-config';
|
|
3
3
|
import { readYML } from './utils';
|
4
4
|
import { KapetaURI, parseKapetaUri } from '@kapeta/nodejs-utils';
|
5
5
|
import { serviceManager } from '../serviceManager';
|
6
|
-
import { containerManager, DockerMounts } from '../containerManager';
|
6
|
+
import { containerManager, DockerMounts, toLocalBindVolume } from '../containerManager';
|
7
7
|
import { LogData } from './LogData';
|
8
8
|
import EventEmitter from 'events';
|
9
9
|
import md5 from 'md5';
|
@@ -247,8 +247,8 @@ export class BlockInstanceRunner {
|
|
247
247
|
],
|
248
248
|
HostConfig: {
|
249
249
|
Binds: [
|
250
|
-
`${ClusterConfig.getKapetaBasedir()}:${homeDir}/.kapeta`,
|
251
|
-
`${baseDir}:${workingDir}`, //We mount
|
250
|
+
`${toLocalBindVolume(ClusterConfig.getKapetaBasedir())}:${homeDir}/.kapeta`,
|
251
|
+
`${toLocalBindVolume(baseDir)}:${workingDir}`, //We mount
|
252
252
|
],
|
253
253
|
PortBindings,
|
254
254
|
},
|
@@ -374,7 +374,9 @@ export class BlockInstanceRunner {
|
|
374
374
|
...Object.entries(env).map(([key, value]) => `${key}=${value}`),
|
375
375
|
],
|
376
376
|
HostConfig: {
|
377
|
-
Binds: [
|
377
|
+
Binds: [
|
378
|
+
`${toLocalBindVolume(ClusterConfig.getKapetaBasedir())}:${ClusterConfig.getKapetaBasedir()}`,
|
379
|
+
],
|
378
380
|
},
|
379
381
|
});
|
380
382
|
|
@@ -508,8 +510,8 @@ export class BlockInstanceRunner {
|
|
508
510
|
HealthCheck,
|
509
511
|
HostConfig: {
|
510
512
|
Binds: [
|
511
|
-
`${kapetaYmlPath}:/kapeta.yml:ro`,
|
512
|
-
`${ClusterConfig.getKapetaBasedir()}:${ClusterConfig.getKapetaBasedir()}`,
|
513
|
+
`${toLocalBindVolume(kapetaYmlPath)}:/kapeta.yml:ro`,
|
514
|
+
`${toLocalBindVolume(ClusterConfig.getKapetaBasedir())}:${ClusterConfig.getKapetaBasedir()}`,
|
513
515
|
],
|
514
516
|
PortBindings,
|
515
517
|
Mounts,
|