@kapeta/local-cluster-service 0.21.5 → 0.22.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.22.0](https://github.com/kapetacom/local-cluster-service/compare/v0.21.5...v0.22.0) (2023-10-17)
|
2
|
+
|
3
|
+
|
4
|
+
### Features
|
5
|
+
|
6
|
+
* Allow local containers to add Binds ([#85](https://github.com/kapetacom/local-cluster-service/issues/85)) ([c7b46e9](https://github.com/kapetacom/local-cluster-service/commit/c7b46e94412da1eec82503f7d30957fc665e71e6))
|
7
|
+
|
1
8
|
## [0.21.5](https://github.com/kapetacom/local-cluster-service/compare/v0.21.4...v0.21.5) (2023-09-26)
|
2
9
|
|
3
10
|
|
@@ -14,6 +14,7 @@ const LogData_1 = require("./LogData");
|
|
14
14
|
const clusterService_1 = require("../clusterService");
|
15
15
|
const types_1 = require("../types");
|
16
16
|
const definitionsManager_1 = require("../definitionsManager");
|
17
|
+
const node_os_1 = __importDefault(require("node:os"));
|
17
18
|
const KIND_BLOCK_TYPE_OPERATOR = 'core/block-type-operator';
|
18
19
|
const KAPETA_SYSTEM_ID = 'KAPETA_SYSTEM_ID';
|
19
20
|
const KAPETA_BLOCK_REF = 'KAPETA_BLOCK_REF';
|
@@ -46,7 +47,8 @@ function getProviderPorts(assetVersion, providerVersion) {
|
|
46
47
|
}
|
47
48
|
return [serviceManager_1.DEFAULT_PORT_TYPE];
|
48
49
|
}
|
49
|
-
|
50
|
+
// Duplicated port types are not allowed
|
51
|
+
return Array.from(new Set(out));
|
50
52
|
}
|
51
53
|
class BlockInstanceRunner {
|
52
54
|
_systemId;
|
@@ -148,6 +150,8 @@ class BlockInstanceRunner {
|
|
148
150
|
const homeDir = localContainer.userHome ? localContainer.userHome : '/root';
|
149
151
|
const workingDir = localContainer.workingDir ? localContainer.workingDir : '/workspace';
|
150
152
|
const customHostConfigs = localContainer.HostConfig ?? {};
|
153
|
+
const Binds = customHostConfigs.Binds ?? [];
|
154
|
+
delete customHostConfigs.Binds;
|
151
155
|
const customLabels = localContainer.Labels ?? {};
|
152
156
|
const customEnvs = localContainer.Env ?? [];
|
153
157
|
delete localContainer.HostConfig;
|
@@ -160,7 +164,7 @@ class BlockInstanceRunner {
|
|
160
164
|
}
|
161
165
|
const realLocalPath = node_fs_1.default.realpathSync(baseDir);
|
162
166
|
const Mounts = containerManager_1.containerManager.toDockerMounts({
|
163
|
-
[workingDir]: (0, containerManager_1.toLocalBindVolume)(realLocalPath)
|
167
|
+
[workingDir]: (0, containerManager_1.toLocalBindVolume)(realLocalPath),
|
164
168
|
});
|
165
169
|
const systemUri = (0, nodejs_utils_1.parseKapetaUri)(this._systemId);
|
166
170
|
return this.ensureContainer({
|
@@ -189,10 +193,20 @@ class BlockInstanceRunner {
|
|
189
193
|
HostConfig: {
|
190
194
|
...customHostConfigs,
|
191
195
|
Binds: [
|
192
|
-
`${(0, containerManager_1.toLocalBindVolume)(local_cluster_config_1.default.getKapetaBasedir())}:${homeDir}/.kapeta
|
196
|
+
`${(0, containerManager_1.toLocalBindVolume)(local_cluster_config_1.default.getKapetaBasedir())}:${homeDir}/.kapeta`,
|
197
|
+
...Binds.map((bind) => {
|
198
|
+
let [host, container] = bind.split(':');
|
199
|
+
if (host.startsWith('~')) {
|
200
|
+
host = node_os_1.default.homedir() + host.substring(1);
|
201
|
+
}
|
202
|
+
if (container.startsWith('~')) {
|
203
|
+
container = homeDir + container.substring(1);
|
204
|
+
}
|
205
|
+
return `${(0, containerManager_1.toLocalBindVolume)(host)}:${container}`;
|
206
|
+
}),
|
193
207
|
],
|
194
208
|
PortBindings,
|
195
|
-
Mounts
|
209
|
+
Mounts,
|
196
210
|
},
|
197
211
|
});
|
198
212
|
}
|
@@ -14,6 +14,7 @@ const LogData_1 = require("./LogData");
|
|
14
14
|
const clusterService_1 = require("../clusterService");
|
15
15
|
const types_1 = require("../types");
|
16
16
|
const definitionsManager_1 = require("../definitionsManager");
|
17
|
+
const node_os_1 = __importDefault(require("node:os"));
|
17
18
|
const KIND_BLOCK_TYPE_OPERATOR = 'core/block-type-operator';
|
18
19
|
const KAPETA_SYSTEM_ID = 'KAPETA_SYSTEM_ID';
|
19
20
|
const KAPETA_BLOCK_REF = 'KAPETA_BLOCK_REF';
|
@@ -46,7 +47,8 @@ function getProviderPorts(assetVersion, providerVersion) {
|
|
46
47
|
}
|
47
48
|
return [serviceManager_1.DEFAULT_PORT_TYPE];
|
48
49
|
}
|
49
|
-
|
50
|
+
// Duplicated port types are not allowed
|
51
|
+
return Array.from(new Set(out));
|
50
52
|
}
|
51
53
|
class BlockInstanceRunner {
|
52
54
|
_systemId;
|
@@ -148,6 +150,8 @@ class BlockInstanceRunner {
|
|
148
150
|
const homeDir = localContainer.userHome ? localContainer.userHome : '/root';
|
149
151
|
const workingDir = localContainer.workingDir ? localContainer.workingDir : '/workspace';
|
150
152
|
const customHostConfigs = localContainer.HostConfig ?? {};
|
153
|
+
const Binds = customHostConfigs.Binds ?? [];
|
154
|
+
delete customHostConfigs.Binds;
|
151
155
|
const customLabels = localContainer.Labels ?? {};
|
152
156
|
const customEnvs = localContainer.Env ?? [];
|
153
157
|
delete localContainer.HostConfig;
|
@@ -160,7 +164,7 @@ class BlockInstanceRunner {
|
|
160
164
|
}
|
161
165
|
const realLocalPath = node_fs_1.default.realpathSync(baseDir);
|
162
166
|
const Mounts = containerManager_1.containerManager.toDockerMounts({
|
163
|
-
[workingDir]: (0, containerManager_1.toLocalBindVolume)(realLocalPath)
|
167
|
+
[workingDir]: (0, containerManager_1.toLocalBindVolume)(realLocalPath),
|
164
168
|
});
|
165
169
|
const systemUri = (0, nodejs_utils_1.parseKapetaUri)(this._systemId);
|
166
170
|
return this.ensureContainer({
|
@@ -189,10 +193,20 @@ class BlockInstanceRunner {
|
|
189
193
|
HostConfig: {
|
190
194
|
...customHostConfigs,
|
191
195
|
Binds: [
|
192
|
-
`${(0, containerManager_1.toLocalBindVolume)(local_cluster_config_1.default.getKapetaBasedir())}:${homeDir}/.kapeta
|
196
|
+
`${(0, containerManager_1.toLocalBindVolume)(local_cluster_config_1.default.getKapetaBasedir())}:${homeDir}/.kapeta`,
|
197
|
+
...Binds.map((bind) => {
|
198
|
+
let [host, container] = bind.split(':');
|
199
|
+
if (host.startsWith('~')) {
|
200
|
+
host = node_os_1.default.homedir() + host.substring(1);
|
201
|
+
}
|
202
|
+
if (container.startsWith('~')) {
|
203
|
+
container = homeDir + container.substring(1);
|
204
|
+
}
|
205
|
+
return `${(0, containerManager_1.toLocalBindVolume)(host)}:${container}`;
|
206
|
+
}),
|
193
207
|
],
|
194
208
|
PortBindings,
|
195
|
-
Mounts
|
209
|
+
Mounts,
|
196
210
|
},
|
197
211
|
});
|
198
212
|
}
|
package/package.json
CHANGED
@@ -15,6 +15,7 @@ import { clusterService } from '../clusterService';
|
|
15
15
|
import { AnyMap, BlockProcessParams, InstanceType, ProcessInfo, StringMap } from '../types';
|
16
16
|
import { definitionsManager } from '../definitionsManager';
|
17
17
|
import Docker from 'dockerode';
|
18
|
+
import OS from 'node:os';
|
18
19
|
|
19
20
|
const KIND_BLOCK_TYPE_OPERATOR = 'core/block-type-operator';
|
20
21
|
const KAPETA_SYSTEM_ID = 'KAPETA_SYSTEM_ID';
|
@@ -53,8 +54,8 @@ function getProviderPorts(assetVersion: DefinitionInfo, providerVersion: Definit
|
|
53
54
|
}
|
54
55
|
return [DEFAULT_PORT_TYPE];
|
55
56
|
}
|
56
|
-
|
57
|
-
return out;
|
57
|
+
// Duplicated port types are not allowed
|
58
|
+
return Array.from(new Set<string>(out));
|
58
59
|
}
|
59
60
|
|
60
61
|
export class BlockInstanceRunner {
|
@@ -194,6 +195,8 @@ export class BlockInstanceRunner {
|
|
194
195
|
const workingDir = localContainer.workingDir ? localContainer.workingDir : '/workspace';
|
195
196
|
|
196
197
|
const customHostConfigs = localContainer.HostConfig ?? {};
|
198
|
+
const Binds = customHostConfigs.Binds ?? [];
|
199
|
+
delete customHostConfigs.Binds;
|
197
200
|
const customLabels = localContainer.Labels ?? {};
|
198
201
|
const customEnvs = localContainer.Env ?? [];
|
199
202
|
delete localContainer.HostConfig;
|
@@ -214,7 +217,7 @@ export class BlockInstanceRunner {
|
|
214
217
|
const realLocalPath = FS.realpathSync(baseDir);
|
215
218
|
|
216
219
|
const Mounts = containerManager.toDockerMounts({
|
217
|
-
[workingDir]: toLocalBindVolume(realLocalPath)
|
220
|
+
[workingDir]: toLocalBindVolume(realLocalPath),
|
218
221
|
});
|
219
222
|
|
220
223
|
const systemUri = parseKapetaUri(this._systemId);
|
@@ -245,10 +248,22 @@ export class BlockInstanceRunner {
|
|
245
248
|
HostConfig: {
|
246
249
|
...customHostConfigs,
|
247
250
|
Binds: [
|
248
|
-
`${toLocalBindVolume(ClusterConfig.getKapetaBasedir())}:${homeDir}/.kapeta
|
251
|
+
`${toLocalBindVolume(ClusterConfig.getKapetaBasedir())}:${homeDir}/.kapeta`,
|
252
|
+
...Binds.map((bind: string) => {
|
253
|
+
let [host, container] = bind.split(':');
|
254
|
+
if (host.startsWith('~')) {
|
255
|
+
host = OS.homedir() + host.substring(1);
|
256
|
+
}
|
257
|
+
|
258
|
+
if (container.startsWith('~')) {
|
259
|
+
container = homeDir + container.substring(1);
|
260
|
+
}
|
261
|
+
|
262
|
+
return `${toLocalBindVolume(host)}:${container}`;
|
263
|
+
}),
|
249
264
|
],
|
250
265
|
PortBindings,
|
251
|
-
Mounts
|
266
|
+
Mounts,
|
252
267
|
},
|
253
268
|
});
|
254
269
|
}
|