diff --git a/dockerfiles/theia/Dockerfile b/dockerfiles/theia/Dockerfile index 28f30ac00..8a3be5226 100644 --- a/dockerfiles/theia/Dockerfile +++ b/dockerfiles/theia/Dockerfile @@ -113,7 +113,7 @@ RUN adduser --disabled-password -S -u 1001 -G root -h ${HOME} -s /bin/sh theia \ # Download yeoman generator plug-in && curl -L -o /default-theia-plugins/theia_yeoman_plugin.theia https://github.com/eclipse/theia-yeoman-plugin/releases/download/untagged-04f28ee329e479cc465b/theia_yeoman_plugin.theia \ && curl -L -o /default-theia-plugins/eclipse_che_theia_factory_plugin.theia https://github.com/eclipse/che-theia/releases/download/0.0.1/eclipse_che_theia_factory_plugin.theia \ - && curl -L -o /default-theia-plugins/eclipse_che_theia_containers_plugin.theia https://github.com/eclipse/che-theia/releases/download/0.0.1/eclipse_che_theia_containers_plugin.theia \ + && curl -L -o /default-theia-plugins/eclipse_che_theia_containers_plugin.theia https://github.com/eclipse/che-theia/releases/download/0.0.2/eclipse_che_theia_containers_plugin.theia \ && for f in "${HOME}" "/etc/passwd" "/etc/group /node_modules /default-theia-plugins /projects"; do\ sudo chgrp -R 0 ${f} && \ sudo chmod -R g+rwX ${f}; \ diff --git a/plugins/containers-plugin/src/containers-service.ts b/plugins/containers-plugin/src/containers-service.ts index 6285d1c0f..fc86b37da 100644 --- a/plugins/containers-plugin/src/containers-service.ts +++ b/plugins/containers-plugin/src/containers-service.ts @@ -19,6 +19,13 @@ export interface IContainer { url?: string; } }; + env?: { [key: string]: string; }, + volumes?: { + [key: string]: { + path?: string; + }; + }, + commands?: string[] } const MAX_FAILED_ATTEMPTS = 5; @@ -50,6 +57,19 @@ export class ContainersService { status: machine.status, isDev: devMachines[name] !== undefined }; + if (devMachines[name]) { + container.volumes = devMachines[name].volumes; + container.env = devMachines[name].env; + } + if (workspace!.config!.commands) { + container.commands = []; + workspace!.config!.commands.forEach(command => { + if (command.attributes && command.attributes.machineName && command.attributes.machineName !== name) { + return; + } + container.commands.push(command.name); + }); + } if (machine && machine.servers) { container.servers = {}; Object.keys(machine.servers).forEach((serverName: string) => { diff --git a/plugins/containers-plugin/src/containers-tree-data-provider.ts b/plugins/containers-plugin/src/containers-tree-data-provider.ts index 55a746bbe..e55b431aa 100644 --- a/plugins/containers-plugin/src/containers-tree-data-provider.ts +++ b/plugins/containers-plugin/src/containers-tree-data-provider.ts @@ -89,42 +89,113 @@ export class ContainersTreeDataProvider implements theia.TreeDataProvider { + const server = container.servers[serverName]; + if (!server) { + return; + } + const treeNodeItem: ITreeNodeItem = { + id: this.getRandId(), + parentId: endpointsId, + name: serverName, + iconPath: 'fa-info-circle medium-blue', + tooltip: server.url ? server.url : 'endpoint' + }; + if (server.url && server.url.startsWith('http')) { + treeNodeItem.name = serverName; + treeNodeItem.iconPath = 'fa-share medium-blue'; + treeNodeItem.command = { id: 'theia.open', arguments: [server.url] }; + treeNodeItem.tooltip = 'open in a new tab ' + treeNodeItem.tooltip; + } + this.treeNodeItems.push(treeNodeItem); + }); } - const serverKeys = Object.keys(servers); - if (!serverKeys.length) { - return; + const envKeys = container.env ? Object.keys(container.env) : []; + if (envKeys.length) { + const envsId = this.getRandId(); + this.treeNodeItems.push({ + id: envsId, + parentId: treeItem.id, + name: 'env', + tooltip: 'environment variables', + isExpanded: false + }); + envKeys.forEach((envName: string) => { + this.treeNodeItems.push({ + id: this.getRandId(), + parentId: envsId, + name: `${envName} : ${container.env[envName]}`, + tooltip: `environment variable ${envName}`, + iconPath: 'fa-info-circle medium-blue' + }); + }); + } + const volumesKeys = container.volumes ? Object.keys(container.volumes) : []; + if (volumesKeys.length) { + const volumesId = this.getRandId(); + this.treeNodeItems.push({ + id: volumesId, + parentId: treeItem.id, + name: 'volumes', + tooltip: 'volumes', + isExpanded: false + }); + volumesKeys.forEach((volumeName: string) => { + const volume: { + [paramRef: string]: string; + } = container.volumes[volumeName]; + if (!volume) { + return; + } + const volumeId = this.getRandId(); + this.treeNodeItems.push({ + id: volumeId, + parentId: volumesId, + name: volumeName, + tooltip: 'volume name', + isExpanded: true + }); + Object.keys(volume).forEach((key: string) => { + this.treeNodeItems.push({ + id: this.getRandId(), + parentId: volumeId, + name: `${key} : ${volume[key]}`, + tooltip: `volume ${volumeName}`, + iconPath: 'fa-info-circle medium-blue' + }); + }); + }); + } + if (container.commands && container.commands.length) { + const commandsId = this.getRandId(); + this.treeNodeItems.push({ + id: commandsId, + parentId: treeItem.id, + name: 'commands', + tooltip: 'commands', + isExpanded: false + }); + container.commands.forEach((commandName: string) => { + this.treeNodeItems.push({ + id: this.getRandId(), + parentId: commandsId, + name: commandName, + tooltip: 'execute the command', + iconPath: 'fa-terminal medium-yellow', + command: { id: 'task:run', arguments: ['che', commandName] } + }); + }); } - const endpointsId = this.getRandId(); - this.treeNodeItems.push({ - id: endpointsId, - parentId: treeItem.id, - name: 'endpoints', - tooltip: 'endpoints', - isExpanded: true - }); - serverKeys.forEach((serverName: string) => { - const server = servers[serverName]; - if (!server) { - return; - } - const treeNodeItem: ITreeNodeItem = { - id: this.getRandId(), - parentId: endpointsId, - name: serverName, - iconPath: 'fa-info-circle medium-blue', - tooltip: server.url ? server.url : 'endpoint' - }; - if (server.url && server.url.startsWith('http')) { - treeNodeItem.name = serverName; - treeNodeItem.iconPath = 'fa-share medium-blue'; - treeNodeItem.command = { id: 'theia.open', arguments: [server.url] }; - treeNodeItem.tooltip = 'open in a new tab ' + treeNodeItem.tooltip; - } - this.treeNodeItems.push(treeNodeItem); - }); }); if (hasPlugin) { this.treeNodeItems.push(pluginsDir);