@theia/dev-container 1.52.0 → 1.53.0-next.55
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/README.md +43 -43
- package/package.json +7 -7
- package/src/dev-container-server/dev-container-server.ts +53 -53
- package/src/electron-browser/container-connection-contribution.ts +103 -103
- package/src/electron-browser/container-info-contribution.ts +46 -46
- package/src/electron-browser/container-output-provider.ts +36 -36
- package/src/electron-browser/dev-container-frontend-module.ts +38 -38
- package/src/electron-common/container-output-provider.ts +19 -19
- package/src/electron-common/remote-container-connection-provider.ts +51 -51
- package/src/electron-node/dev-container-backend-module.ts +58 -58
- package/src/electron-node/dev-container-file-service.ts +72 -72
- package/src/electron-node/devcontainer-contributions/cli-enhancing-creation-contributions.ts +68 -68
- package/src/electron-node/devcontainer-contributions/main-container-creation-contributions.ts +191 -191
- package/src/electron-node/devcontainer-contributions/profile-file-modification-contribution.ts +35 -35
- package/src/electron-node/devcontainer-file.ts +411 -411
- package/src/electron-node/docker-container-service.ts +132 -132
- package/src/electron-node/remote-container-connection-provider.ts +311 -311
- package/src/package.spec.ts +28 -28
package/README.md
CHANGED
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
<div align='center'>
|
|
2
|
-
|
|
3
|
-
<br />
|
|
4
|
-
|
|
5
|
-
<img src='https://raw.githubusercontent.com/eclipse-theia/theia/master/logo/theia.svg?sanitize=true' alt='theia-ext-logo' width='100px' />
|
|
6
|
-
|
|
7
|
-
<h2>ECLIPSE THEIA - DEV-CONTAINER EXTENSION</h2>
|
|
8
|
-
|
|
9
|
-
<hr />
|
|
10
|
-
|
|
11
|
-
</div>
|
|
12
|
-
|
|
13
|
-
## Description
|
|
14
|
-
|
|
15
|
-
The `@theia/dev-container` extension provides functionality to create, start and connect to development containers similiar to the
|
|
16
|
-
[vscode Dev Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers).
|
|
17
|
-
|
|
18
|
-
The full devcontainer.json Schema can be found [here](https://containers.dev/implementors/json_reference/).
|
|
19
|
-
Currently only a small number of configuration file properties are implemented. Those include the following:
|
|
20
|
-
- name
|
|
21
|
-
- Image
|
|
22
|
-
- dockerfile/build.dockerfile
|
|
23
|
-
- build.context
|
|
24
|
-
- location
|
|
25
|
-
- forwardPorts
|
|
26
|
-
- mounts
|
|
27
|
-
|
|
28
|
-
see `main-container-creation-contributions.ts` for how to implementations or how to implement additional ones.
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
## Additional Information
|
|
32
|
-
|
|
33
|
-
- [Theia - GitHub](https://github.com/eclipse-theia/theia)
|
|
34
|
-
- [Theia - Website](https://theia-ide.org/)
|
|
35
|
-
|
|
36
|
-
## License
|
|
37
|
-
|
|
38
|
-
- [Eclipse Public License 2.0](http://www.eclipse.org/legal/epl-2.0/)
|
|
39
|
-
- [一 (Secondary) GNU General Public License, version 2 with the GNU Classpath Exception](https://projects.eclipse.org/license/secondary-gpl-2.0-cp)
|
|
40
|
-
|
|
41
|
-
## Trademark
|
|
42
|
-
"Theia" is a trademark of the Eclipse Foundation
|
|
43
|
-
https://www.eclipse.org/theia
|
|
1
|
+
<div align='center'>
|
|
2
|
+
|
|
3
|
+
<br />
|
|
4
|
+
|
|
5
|
+
<img src='https://raw.githubusercontent.com/eclipse-theia/theia/master/logo/theia.svg?sanitize=true' alt='theia-ext-logo' width='100px' />
|
|
6
|
+
|
|
7
|
+
<h2>ECLIPSE THEIA - DEV-CONTAINER EXTENSION</h2>
|
|
8
|
+
|
|
9
|
+
<hr />
|
|
10
|
+
|
|
11
|
+
</div>
|
|
12
|
+
|
|
13
|
+
## Description
|
|
14
|
+
|
|
15
|
+
The `@theia/dev-container` extension provides functionality to create, start and connect to development containers similiar to the
|
|
16
|
+
[vscode Dev Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers).
|
|
17
|
+
|
|
18
|
+
The full devcontainer.json Schema can be found [here](https://containers.dev/implementors/json_reference/).
|
|
19
|
+
Currently only a small number of configuration file properties are implemented. Those include the following:
|
|
20
|
+
- name
|
|
21
|
+
- Image
|
|
22
|
+
- dockerfile/build.dockerfile
|
|
23
|
+
- build.context
|
|
24
|
+
- location
|
|
25
|
+
- forwardPorts
|
|
26
|
+
- mounts
|
|
27
|
+
|
|
28
|
+
see `main-container-creation-contributions.ts` for how to implementations or how to implement additional ones.
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
## Additional Information
|
|
32
|
+
|
|
33
|
+
- [Theia - GitHub](https://github.com/eclipse-theia/theia)
|
|
34
|
+
- [Theia - Website](https://theia-ide.org/)
|
|
35
|
+
|
|
36
|
+
## License
|
|
37
|
+
|
|
38
|
+
- [Eclipse Public License 2.0](http://www.eclipse.org/legal/epl-2.0/)
|
|
39
|
+
- [一 (Secondary) GNU General Public License, version 2 with the GNU Classpath Exception](https://projects.eclipse.org/license/secondary-gpl-2.0-cp)
|
|
40
|
+
|
|
41
|
+
## Trademark
|
|
42
|
+
"Theia" is a trademark of the Eclipse Foundation
|
|
43
|
+
https://www.eclipse.org/theia
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theia/dev-container",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.53.0-next.55+d1a989a68c",
|
|
4
4
|
"description": "Theia - Editor Preview Extension",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"@theia/core": "1.
|
|
7
|
-
"@theia/output": "1.
|
|
8
|
-
"@theia/remote": "1.
|
|
9
|
-
"@theia/workspace": "1.
|
|
6
|
+
"@theia/core": "1.53.0-next.55+d1a989a68c",
|
|
7
|
+
"@theia/output": "1.53.0-next.55+d1a989a68c",
|
|
8
|
+
"@theia/remote": "1.53.0-next.55+d1a989a68c",
|
|
9
|
+
"@theia/workspace": "1.53.0-next.55+d1a989a68c",
|
|
10
10
|
"dockerode": "^4.0.2",
|
|
11
11
|
"jsonc-parser": "^2.2.0",
|
|
12
12
|
"uuid": "^8.0.0"
|
|
@@ -45,11 +45,11 @@
|
|
|
45
45
|
"watch": "theiaext watch"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@theia/ext-scripts": "1.
|
|
48
|
+
"@theia/ext-scripts": "1.53.0",
|
|
49
49
|
"@types/dockerode": "^3.3.23"
|
|
50
50
|
},
|
|
51
51
|
"nyc": {
|
|
52
52
|
"extends": "../../configs/nyc.json"
|
|
53
53
|
},
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "d1a989a68c1b5ec1f9098e9126653c6346844769"
|
|
55
55
|
}
|
|
@@ -1,53 +1,53 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2024 Typefox and others.
|
|
3
|
-
//
|
|
4
|
-
// This program and the accompanying materials are made available under the
|
|
5
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
-
//
|
|
8
|
-
// This Source Code may also be made available under the following Secondary
|
|
9
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
-
// with the GNU Classpath Exception which is available at
|
|
12
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
-
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
-
// *****************************************************************************
|
|
16
|
-
|
|
17
|
-
import { createConnection } from 'net';
|
|
18
|
-
import { stdin, argv, stdout } from 'process';
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* this node.js Program is supposed to be executed by an docker exec session inside a docker container.
|
|
22
|
-
* It uses a tty session to listen on stdin and send on stdout all communication with the theia backend running inside the container.
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
let backendPort: number | undefined = undefined;
|
|
26
|
-
argv.slice(2).forEach(arg => {
|
|
27
|
-
if (arg.startsWith('-target-port')) {
|
|
28
|
-
backendPort = parseInt(arg.split('=')[1]);
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
if (!backendPort) {
|
|
33
|
-
throw new Error('please start with -target-port={port number}');
|
|
34
|
-
}
|
|
35
|
-
if (stdin.isTTY) {
|
|
36
|
-
stdin.setRawMode(true);
|
|
37
|
-
}
|
|
38
|
-
const connection = createConnection(backendPort, '0.0.0.0');
|
|
39
|
-
|
|
40
|
-
connection.pipe(stdout);
|
|
41
|
-
stdin.pipe(connection);
|
|
42
|
-
|
|
43
|
-
connection.on('error', error => {
|
|
44
|
-
console.error('connection error', error);
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
connection.on('close', () => {
|
|
48
|
-
console.log('connection closed');
|
|
49
|
-
process.exit(0);
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
// keep the process running
|
|
53
|
-
setInterval(() => { }, 1 << 30);
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2024 Typefox and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import { createConnection } from 'net';
|
|
18
|
+
import { stdin, argv, stdout } from 'process';
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* this node.js Program is supposed to be executed by an docker exec session inside a docker container.
|
|
22
|
+
* It uses a tty session to listen on stdin and send on stdout all communication with the theia backend running inside the container.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
let backendPort: number | undefined = undefined;
|
|
26
|
+
argv.slice(2).forEach(arg => {
|
|
27
|
+
if (arg.startsWith('-target-port')) {
|
|
28
|
+
backendPort = parseInt(arg.split('=')[1]);
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
if (!backendPort) {
|
|
33
|
+
throw new Error('please start with -target-port={port number}');
|
|
34
|
+
}
|
|
35
|
+
if (stdin.isTTY) {
|
|
36
|
+
stdin.setRawMode(true);
|
|
37
|
+
}
|
|
38
|
+
const connection = createConnection(backendPort, '0.0.0.0');
|
|
39
|
+
|
|
40
|
+
connection.pipe(stdout);
|
|
41
|
+
stdin.pipe(connection);
|
|
42
|
+
|
|
43
|
+
connection.on('error', error => {
|
|
44
|
+
console.error('connection error', error);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
connection.on('close', () => {
|
|
48
|
+
console.log('connection closed');
|
|
49
|
+
process.exit(0);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
// keep the process running
|
|
53
|
+
setInterval(() => { }, 1 << 30);
|
|
@@ -1,103 +1,103 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2024 Typefox and others.
|
|
3
|
-
//
|
|
4
|
-
// This program and the accompanying materials are made available under the
|
|
5
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
-
//
|
|
8
|
-
// This Source Code may also be made available under the following Secondary
|
|
9
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
-
// with the GNU Classpath Exception which is available at
|
|
12
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
-
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
-
// *****************************************************************************
|
|
16
|
-
|
|
17
|
-
import { inject, injectable } from '@theia/core/shared/inversify';
|
|
18
|
-
import { AbstractRemoteRegistryContribution, RemoteRegistry } from '@theia/remote/lib/electron-browser/remote-registry-contribution';
|
|
19
|
-
import { LastContainerInfo, RemoteContainerConnectionProvider } from '../electron-common/remote-container-connection-provider';
|
|
20
|
-
import { RemotePreferences } from '@theia/remote/lib/electron-browser/remote-preferences';
|
|
21
|
-
import { WorkspaceStorageService } from '@theia/workspace/lib/browser/workspace-storage-service';
|
|
22
|
-
import { Command, QuickInputService } from '@theia/core';
|
|
23
|
-
import { WorkspaceService } from '@theia/workspace/lib/browser/workspace-service';
|
|
24
|
-
import { ContainerOutputProvider } from './container-output-provider';
|
|
25
|
-
|
|
26
|
-
export namespace RemoteContainerCommands {
|
|
27
|
-
export const REOPEN_IN_CONTAINER = Command.toLocalizedCommand({
|
|
28
|
-
id: 'dev-container:reopen-in-container',
|
|
29
|
-
label: 'Reopen in Container',
|
|
30
|
-
category: 'Dev Container'
|
|
31
|
-
}, 'theia/dev-container/connect');
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const LAST_USED_CONTAINER = 'lastUsedContainer';
|
|
35
|
-
@injectable()
|
|
36
|
-
export class ContainerConnectionContribution extends AbstractRemoteRegistryContribution {
|
|
37
|
-
|
|
38
|
-
@inject(RemoteContainerConnectionProvider)
|
|
39
|
-
protected readonly connectionProvider: RemoteContainerConnectionProvider;
|
|
40
|
-
|
|
41
|
-
@inject(RemotePreferences)
|
|
42
|
-
protected readonly remotePreferences: RemotePreferences;
|
|
43
|
-
|
|
44
|
-
@inject(WorkspaceStorageService)
|
|
45
|
-
protected readonly workspaceStorageService: WorkspaceStorageService;
|
|
46
|
-
|
|
47
|
-
@inject(WorkspaceService)
|
|
48
|
-
protected readonly workspaceService: WorkspaceService;
|
|
49
|
-
|
|
50
|
-
@inject(QuickInputService)
|
|
51
|
-
protected readonly quickInputService: QuickInputService;
|
|
52
|
-
|
|
53
|
-
@inject(ContainerOutputProvider)
|
|
54
|
-
protected readonly containerOutputProvider: ContainerOutputProvider;
|
|
55
|
-
|
|
56
|
-
registerRemoteCommands(registry: RemoteRegistry): void {
|
|
57
|
-
registry.registerCommand(RemoteContainerCommands.REOPEN_IN_CONTAINER, {
|
|
58
|
-
execute: () => this.openInContainer()
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
async openInContainer(): Promise<void> {
|
|
63
|
-
const devcontainerFile = await this.getOrSelectDevcontainerFile();
|
|
64
|
-
if (!devcontainerFile) {
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
const lastContainerInfoKey = `${LAST_USED_CONTAINER}:${devcontainerFile}`;
|
|
68
|
-
const lastContainerInfo = await this.workspaceStorageService.getData<LastContainerInfo | undefined>(lastContainerInfoKey);
|
|
69
|
-
|
|
70
|
-
this.containerOutputProvider.openChannel();
|
|
71
|
-
|
|
72
|
-
const connectionResult = await this.connectionProvider.connectToContainer({
|
|
73
|
-
nodeDownloadTemplate: this.remotePreferences['remote.nodeDownloadTemplate'],
|
|
74
|
-
lastContainerInfo,
|
|
75
|
-
devcontainerFile
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
this.workspaceStorageService.setData<LastContainerInfo>(lastContainerInfoKey, {
|
|
79
|
-
id: connectionResult.containerId,
|
|
80
|
-
lastUsed: Date.now()
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
this.openRemote(connectionResult.port, false, connectionResult.workspacePath);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
async getOrSelectDevcontainerFile(): Promise<string | undefined> {
|
|
87
|
-
const devcontainerFiles = await this.connectionProvider.getDevContainerFiles();
|
|
88
|
-
|
|
89
|
-
if (devcontainerFiles.length === 1) {
|
|
90
|
-
return devcontainerFiles[0].path;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
return (await this.quickInputService.pick(devcontainerFiles.map(file => ({
|
|
94
|
-
type: 'item',
|
|
95
|
-
label: file.name,
|
|
96
|
-
description: file.path,
|
|
97
|
-
file: file.path,
|
|
98
|
-
})), {
|
|
99
|
-
title: 'Select a devcontainer.json file'
|
|
100
|
-
}))?.file;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
}
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2024 Typefox and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import { inject, injectable } from '@theia/core/shared/inversify';
|
|
18
|
+
import { AbstractRemoteRegistryContribution, RemoteRegistry } from '@theia/remote/lib/electron-browser/remote-registry-contribution';
|
|
19
|
+
import { LastContainerInfo, RemoteContainerConnectionProvider } from '../electron-common/remote-container-connection-provider';
|
|
20
|
+
import { RemotePreferences } from '@theia/remote/lib/electron-browser/remote-preferences';
|
|
21
|
+
import { WorkspaceStorageService } from '@theia/workspace/lib/browser/workspace-storage-service';
|
|
22
|
+
import { Command, QuickInputService } from '@theia/core';
|
|
23
|
+
import { WorkspaceService } from '@theia/workspace/lib/browser/workspace-service';
|
|
24
|
+
import { ContainerOutputProvider } from './container-output-provider';
|
|
25
|
+
|
|
26
|
+
export namespace RemoteContainerCommands {
|
|
27
|
+
export const REOPEN_IN_CONTAINER = Command.toLocalizedCommand({
|
|
28
|
+
id: 'dev-container:reopen-in-container',
|
|
29
|
+
label: 'Reopen in Container',
|
|
30
|
+
category: 'Dev Container'
|
|
31
|
+
}, 'theia/dev-container/connect');
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const LAST_USED_CONTAINER = 'lastUsedContainer';
|
|
35
|
+
@injectable()
|
|
36
|
+
export class ContainerConnectionContribution extends AbstractRemoteRegistryContribution {
|
|
37
|
+
|
|
38
|
+
@inject(RemoteContainerConnectionProvider)
|
|
39
|
+
protected readonly connectionProvider: RemoteContainerConnectionProvider;
|
|
40
|
+
|
|
41
|
+
@inject(RemotePreferences)
|
|
42
|
+
protected readonly remotePreferences: RemotePreferences;
|
|
43
|
+
|
|
44
|
+
@inject(WorkspaceStorageService)
|
|
45
|
+
protected readonly workspaceStorageService: WorkspaceStorageService;
|
|
46
|
+
|
|
47
|
+
@inject(WorkspaceService)
|
|
48
|
+
protected readonly workspaceService: WorkspaceService;
|
|
49
|
+
|
|
50
|
+
@inject(QuickInputService)
|
|
51
|
+
protected readonly quickInputService: QuickInputService;
|
|
52
|
+
|
|
53
|
+
@inject(ContainerOutputProvider)
|
|
54
|
+
protected readonly containerOutputProvider: ContainerOutputProvider;
|
|
55
|
+
|
|
56
|
+
registerRemoteCommands(registry: RemoteRegistry): void {
|
|
57
|
+
registry.registerCommand(RemoteContainerCommands.REOPEN_IN_CONTAINER, {
|
|
58
|
+
execute: () => this.openInContainer()
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
async openInContainer(): Promise<void> {
|
|
63
|
+
const devcontainerFile = await this.getOrSelectDevcontainerFile();
|
|
64
|
+
if (!devcontainerFile) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
const lastContainerInfoKey = `${LAST_USED_CONTAINER}:${devcontainerFile}`;
|
|
68
|
+
const lastContainerInfo = await this.workspaceStorageService.getData<LastContainerInfo | undefined>(lastContainerInfoKey);
|
|
69
|
+
|
|
70
|
+
this.containerOutputProvider.openChannel();
|
|
71
|
+
|
|
72
|
+
const connectionResult = await this.connectionProvider.connectToContainer({
|
|
73
|
+
nodeDownloadTemplate: this.remotePreferences['remote.nodeDownloadTemplate'],
|
|
74
|
+
lastContainerInfo,
|
|
75
|
+
devcontainerFile
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
this.workspaceStorageService.setData<LastContainerInfo>(lastContainerInfoKey, {
|
|
79
|
+
id: connectionResult.containerId,
|
|
80
|
+
lastUsed: Date.now()
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
this.openRemote(connectionResult.port, false, connectionResult.workspacePath);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
async getOrSelectDevcontainerFile(): Promise<string | undefined> {
|
|
87
|
+
const devcontainerFiles = await this.connectionProvider.getDevContainerFiles();
|
|
88
|
+
|
|
89
|
+
if (devcontainerFiles.length === 1) {
|
|
90
|
+
return devcontainerFiles[0].path;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return (await this.quickInputService.pick(devcontainerFiles.map(file => ({
|
|
94
|
+
type: 'item',
|
|
95
|
+
label: file.name,
|
|
96
|
+
description: file.path,
|
|
97
|
+
file: file.path,
|
|
98
|
+
})), {
|
|
99
|
+
title: 'Select a devcontainer.json file'
|
|
100
|
+
}))?.file;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
}
|
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2024 Typefox and others.
|
|
3
|
-
//
|
|
4
|
-
// This program and the accompanying materials are made available under the
|
|
5
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
-
//
|
|
8
|
-
// This Source Code may also be made available under the following Secondary
|
|
9
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
-
// with the GNU Classpath Exception which is available at
|
|
12
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
-
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
-
// *****************************************************************************
|
|
16
|
-
|
|
17
|
-
import { inject, injectable } from '@theia/core/shared/inversify';
|
|
18
|
-
import { FrontendApplicationContribution } from '@theia/core/lib/browser';
|
|
19
|
-
import type { ContainerInspectInfo } from 'dockerode';
|
|
20
|
-
import { RemoteContainerConnectionProvider } from '../electron-common/remote-container-connection-provider';
|
|
21
|
-
import { PortForwardingService } from '@theia/remote/lib/electron-browser/port-forwarding/port-forwarding-service';
|
|
22
|
-
|
|
23
|
-
@injectable()
|
|
24
|
-
export class ContainerInfoContribution implements FrontendApplicationContribution {
|
|
25
|
-
|
|
26
|
-
@inject(RemoteContainerConnectionProvider)
|
|
27
|
-
protected readonly connectionProvider: RemoteContainerConnectionProvider;
|
|
28
|
-
|
|
29
|
-
@inject(PortForwardingService)
|
|
30
|
-
protected readonly portForwardingService: PortForwardingService;
|
|
31
|
-
|
|
32
|
-
containerInfo: ContainerInspectInfo | undefined;
|
|
33
|
-
|
|
34
|
-
async onStart(): Promise<void> {
|
|
35
|
-
this.containerInfo = await this.connectionProvider.getCurrentContainerInfo(parseInt(new URLSearchParams(location.search).get('port') ?? '0'));
|
|
36
|
-
|
|
37
|
-
this.portForwardingService.forwardedPorts = Object.entries(this.containerInfo?.NetworkSettings.Ports ?? {}).flatMap(([_, ports]) => (
|
|
38
|
-
ports.map(port => ({
|
|
39
|
-
editing: false,
|
|
40
|
-
address: port.HostIp ?? '',
|
|
41
|
-
localPort: parseInt(port.HostPort ?? '0'),
|
|
42
|
-
origin: 'container'
|
|
43
|
-
}))));
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
}
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2024 Typefox and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import { inject, injectable } from '@theia/core/shared/inversify';
|
|
18
|
+
import { FrontendApplicationContribution } from '@theia/core/lib/browser';
|
|
19
|
+
import type { ContainerInspectInfo } from 'dockerode';
|
|
20
|
+
import { RemoteContainerConnectionProvider } from '../electron-common/remote-container-connection-provider';
|
|
21
|
+
import { PortForwardingService } from '@theia/remote/lib/electron-browser/port-forwarding/port-forwarding-service';
|
|
22
|
+
|
|
23
|
+
@injectable()
|
|
24
|
+
export class ContainerInfoContribution implements FrontendApplicationContribution {
|
|
25
|
+
|
|
26
|
+
@inject(RemoteContainerConnectionProvider)
|
|
27
|
+
protected readonly connectionProvider: RemoteContainerConnectionProvider;
|
|
28
|
+
|
|
29
|
+
@inject(PortForwardingService)
|
|
30
|
+
protected readonly portForwardingService: PortForwardingService;
|
|
31
|
+
|
|
32
|
+
containerInfo: ContainerInspectInfo | undefined;
|
|
33
|
+
|
|
34
|
+
async onStart(): Promise<void> {
|
|
35
|
+
this.containerInfo = await this.connectionProvider.getCurrentContainerInfo(parseInt(new URLSearchParams(location.search).get('port') ?? '0'));
|
|
36
|
+
|
|
37
|
+
this.portForwardingService.forwardedPorts = Object.entries(this.containerInfo?.NetworkSettings.Ports ?? {}).flatMap(([_, ports]) => (
|
|
38
|
+
ports.map(port => ({
|
|
39
|
+
editing: false,
|
|
40
|
+
address: port.HostIp ?? '',
|
|
41
|
+
localPort: parseInt(port.HostPort ?? '0'),
|
|
42
|
+
origin: 'container'
|
|
43
|
+
}))));
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
}
|
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2024 Typefox and others.
|
|
3
|
-
//
|
|
4
|
-
// This program and the accompanying materials are made available under the
|
|
5
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
-
//
|
|
8
|
-
// This Source Code may also be made available under the following Secondary
|
|
9
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
-
// with the GNU Classpath Exception which is available at
|
|
12
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
-
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
-
// *****************************************************************************
|
|
16
|
-
|
|
17
|
-
import { injectable, inject } from '@theia/core/shared/inversify';
|
|
18
|
-
import { OutputChannel, OutputChannelManager } from '@theia/output/lib/browser/output-channel';
|
|
19
|
-
|
|
20
|
-
@injectable()
|
|
21
|
-
export class ContainerOutputProvider implements ContainerOutputProvider {
|
|
22
|
-
|
|
23
|
-
@inject(OutputChannelManager)
|
|
24
|
-
protected readonly outputChannelManager: OutputChannelManager;
|
|
25
|
-
|
|
26
|
-
protected currentChannel?: OutputChannel;
|
|
27
|
-
|
|
28
|
-
openChannel(): void {
|
|
29
|
-
this.currentChannel = this.outputChannelManager.getChannel('Container');
|
|
30
|
-
this.currentChannel.show();
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
onRemoteOutput(output: string): void {
|
|
34
|
-
this.currentChannel?.appendLine(output);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2024 Typefox and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import { injectable, inject } from '@theia/core/shared/inversify';
|
|
18
|
+
import { OutputChannel, OutputChannelManager } from '@theia/output/lib/browser/output-channel';
|
|
19
|
+
|
|
20
|
+
@injectable()
|
|
21
|
+
export class ContainerOutputProvider implements ContainerOutputProvider {
|
|
22
|
+
|
|
23
|
+
@inject(OutputChannelManager)
|
|
24
|
+
protected readonly outputChannelManager: OutputChannelManager;
|
|
25
|
+
|
|
26
|
+
protected currentChannel?: OutputChannel;
|
|
27
|
+
|
|
28
|
+
openChannel(): void {
|
|
29
|
+
this.currentChannel = this.outputChannelManager.getChannel('Container');
|
|
30
|
+
this.currentChannel.show();
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
onRemoteOutput(output: string): void {
|
|
34
|
+
this.currentChannel?.appendLine(output);
|
|
35
|
+
}
|
|
36
|
+
}
|