@kapeta/local-cluster-service 0.7.1 → 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 +14 -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/cjs/src/utils/LogData.js +0 -1
- 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/dist/esm/src/utils/LogData.js +0 -1
- package/package.json +1 -1
- package/src/containerManager.ts +20 -2
- package/src/operatorManager.ts +1 -2
- package/src/repositoryManager.ts +1 -1
- package/src/utils/BlockInstanceRunner.ts +8 -11
- package/src/utils/LogData.ts +0 -3
package/CHANGELOG.md
CHANGED
@@ -1,3 +1,17 @@
|
|
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
|
+
|
8
|
+
## [0.7.2](https://github.com/kapetacom/local-cluster-service/compare/v0.7.1...v0.7.2) (2023-07-16)
|
9
|
+
|
10
|
+
|
11
|
+
### Bug Fixes
|
12
|
+
|
13
|
+
* Removed missed module.exports from TS module ([d6d85af](https://github.com/kapetacom/local-cluster-service/commit/d6d85af4823960baa52d3a87243d2639dd4cdab4))
|
14
|
+
|
1
15
|
## [0.7.1](https://github.com/kapetacom/local-cluster-service/compare/v0.7.0...v0.7.1) (2023-07-16)
|
2
16
|
|
3
17
|
|
@@ -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();
|
package/src/operatorManager.ts
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
import ClusterConfiguration, { DefinitionInfo } from '@kapeta/local-cluster-config';
|
2
|
-
import _ from 'lodash';
|
3
2
|
import Path from 'path';
|
4
3
|
import md5 from 'md5';
|
5
4
|
import { parseKapetaUri } from '@kapeta/nodejs-utils';
|
@@ -8,7 +7,7 @@ import { storageService } from './storageService';
|
|
8
7
|
import { ContainerInfo, containerManager } from './containerManager';
|
9
8
|
import FSExtra from 'fs-extra';
|
10
9
|
import { AnyMap, EnvironmentType, OperatorInfo } from './types';
|
11
|
-
import { BlockInstance,
|
10
|
+
import { BlockInstance, Resource } from '@kapeta/schemas';
|
12
11
|
|
13
12
|
const KIND_OPERATOR = 'core/resource-type-operator';
|
14
13
|
|
package/src/repositoryManager.ts
CHANGED
@@ -1,19 +1,14 @@
|
|
1
|
-
import { spawn } from 'node:child_process';
|
2
1
|
import FS from 'node:fs';
|
3
|
-
import Path from 'node:path';
|
4
|
-
import { Docker } from 'node-docker-api';
|
5
2
|
import ClusterConfig, { DefinitionInfo } from '@kapeta/local-cluster-config';
|
6
3
|
import { readYML } from './utils';
|
7
4
|
import { KapetaURI, parseKapetaUri } from '@kapeta/nodejs-utils';
|
8
5
|
import { serviceManager } from '../serviceManager';
|
9
|
-
import { containerManager, DockerMounts } from '../containerManager';
|
6
|
+
import { containerManager, DockerMounts, toLocalBindVolume } from '../containerManager';
|
10
7
|
import { LogData } from './LogData';
|
11
8
|
import EventEmitter from 'events';
|
12
9
|
import md5 from 'md5';
|
13
|
-
import { execSync } from 'child_process';
|
14
10
|
import { clusterService } from '../clusterService';
|
15
11
|
import { AnyMap, BlockProcessParams, ProcessDetails, ProcessInfo, StringMap } from '../types';
|
16
|
-
import { BlockDefinition, BlockInstance, BlockInstanceConfiguration, BlockResource } from '@kapeta/schemas';
|
17
12
|
import { Container } from 'node-docker-api/lib/container';
|
18
13
|
|
19
14
|
const KIND_BLOCK_TYPE_OPERATOR = 'core/block-type-operator';
|
@@ -252,8 +247,8 @@ export class BlockInstanceRunner {
|
|
252
247
|
],
|
253
248
|
HostConfig: {
|
254
249
|
Binds: [
|
255
|
-
`${ClusterConfig.getKapetaBasedir()}:${homeDir}/.kapeta`,
|
256
|
-
`${baseDir}:${workingDir}`, //We mount
|
250
|
+
`${toLocalBindVolume(ClusterConfig.getKapetaBasedir())}:${homeDir}/.kapeta`,
|
251
|
+
`${toLocalBindVolume(baseDir)}:${workingDir}`, //We mount
|
257
252
|
],
|
258
253
|
PortBindings,
|
259
254
|
},
|
@@ -379,7 +374,9 @@ export class BlockInstanceRunner {
|
|
379
374
|
...Object.entries(env).map(([key, value]) => `${key}=${value}`),
|
380
375
|
],
|
381
376
|
HostConfig: {
|
382
|
-
Binds: [
|
377
|
+
Binds: [
|
378
|
+
`${toLocalBindVolume(ClusterConfig.getKapetaBasedir())}:${ClusterConfig.getKapetaBasedir()}`,
|
379
|
+
],
|
383
380
|
},
|
384
381
|
});
|
385
382
|
|
@@ -513,8 +510,8 @@ export class BlockInstanceRunner {
|
|
513
510
|
HealthCheck,
|
514
511
|
HostConfig: {
|
515
512
|
Binds: [
|
516
|
-
`${kapetaYmlPath}:/kapeta.yml:ro`,
|
517
|
-
`${ClusterConfig.getKapetaBasedir()}:${ClusterConfig.getKapetaBasedir()}`,
|
513
|
+
`${toLocalBindVolume(kapetaYmlPath)}:/kapeta.yml:ro`,
|
514
|
+
`${toLocalBindVolume(ClusterConfig.getKapetaBasedir())}:${ClusterConfig.getKapetaBasedir()}`,
|
518
515
|
],
|
519
516
|
PortBindings,
|
520
517
|
Mounts,
|
package/src/utils/LogData.ts
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
import { LogEntry, LogLevel, LogSource } from '../types';
|
2
2
|
|
3
3
|
const MAX_LINES = 1000;
|
4
|
-
|
5
4
|
export class LogData {
|
6
5
|
public static readonly MAX_LINES = MAX_LINES;
|
7
6
|
private readonly entries: LogEntry[] = [];
|
@@ -43,5 +42,3 @@ export class LogData {
|
|
43
42
|
.join('\n');
|
44
43
|
}
|
45
44
|
}
|
46
|
-
|
47
|
-
module.exports = LogData;
|