Skip to content

Commit

Permalink
feat(DockerHost): Added first part of support for remote docker host
Browse files Browse the repository at this point in the history
  • Loading branch information
kine committed Oct 15, 2018
1 parent 545aee4 commit d5e6bd8
Show file tree
Hide file tree
Showing 5 changed files with 119 additions and 41 deletions.
20 changes: 20 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,21 @@
"type": "string",
"default": "C:\\Users\\ksacek.NAVERTICA\\Documents\\AL\\",
"description": "GIT Repository which will be cloned when new App folder is created"
},
"navertical.DockerHost": {
"type": "string",
"default": "localhost",
"description": "Host name of the remote docker host"
},
"navertical.DockerHostUseSSL": {
"type": "boolean",
"default": false,
"description": "Set if remote docker host uses SSL connection"
},
"navertical.DockerHostFolderMap": {
"type": "string",
"default": "s:\\;c:\\source",
"description": "Mapping between docker host local folder and local path used in VSCode (in form '<localpath>;<remotelocalpath>')"
}
}
}
Expand Down Expand Up @@ -135,6 +150,11 @@
"command": "navertical.ForceDownload",
"title": "Download System Packages",
"category": "Navertical"
},
{
"command": "navertical.SetupRemoteDockerFolder",
"title": "Setup Remote Docker Folder",
"category": "Navertical"
}
]
},
Expand Down
57 changes: 17 additions & 40 deletions src/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,37 +4,24 @@ import * as terminal from './terminal';
import * as path from "path";
import * as fs from "fs";
import * as guid from './guid';
import * as settings from "./settings"

import { workspace, WorkspaceEdit, ShellExecution } from 'vscode';
import { execFile } from "child_process";

function GetCurrentRootPath():string
{
if (vscode.workspace.workspaceFolders.length === 1) {
return vscode.workspace.workspaceFolders[0].uri.fsPath+'\\..';
}
if (vscode.window.activeTextEditor===undefined) {
return vscode.workspace.workspaceFolders[0].uri.fsPath+'\\..';
}
const fileUri = vscode.window.activeTextEditor.document.uri;
const workspace = vscode.workspace.getWorkspaceFolder(fileUri);
console.log(`Navertical: current workspace folder is: ${workspace.uri.fsPath}`);
return workspace.uri.fsPath+'\\..';
}

export function CompileTree() {
terminal.PSTerminal.show(true);
const currentRoot = GetCurrentRootPath();
terminal.SendPSText(`Read-ALConfiguration -Path ${currentRoot} | Download-ALSystemPackages -AlPackagesPath ${currentRoot} -UseDefaultCred $True -Password 'something'`);
terminal.SendPSText(`Read-ALConfiguration -Path ${currentRoot} | Compile-ALProjectTree -OrderedApps (Get-ALAppOrder -Path ${currentRoot}) -PackagesPath ${currentRoot}`);
const currentRoot = settings.GetCurrentRootPath();
terminal.SendPSText(`${settings.GetConfigCommand(false)} | Download-ALSystemPackages -AlPackagesPath ${currentRoot} -UseDefaultCred $True -Password 'something'`);
terminal.SendPSText(`${settings.GetConfigCommand(true)} | Compile-ALProjectTree -OrderedApps (Get-ALAppOrder -Path ${currentRoot}) -PackagesPath ${currentRoot}`);

}

export function ForceDownload() {
terminal.PSTerminal.show(true);
const currentRoot = GetCurrentRootPath();
terminal.SendPSText(`Read-ALConfiguration -Path ${currentRoot} | Download-ALSystemPackages -AlPackagesPath ${currentRoot} -UseDefaultCred $True -Password 'something' -Force`);
//terminal.SendPSText(`Read-ALConfiguration -Path ${currentRoot} | Compile-ALProjectTree -OrderedApps (Get-ALAppOrder -Path ${currentRoot}) -PackagesPath ${currentRoot}`);
const currentRoot = settings.GetCurrentRootPath();
terminal.SendPSText(`${settings.GetConfigCommand(false)} | Download-ALSystemPackages -AlPackagesPath ${currentRoot} -UseDefaultCred $True -Password 'something' -Force`);
//terminal.SendPSText(`${settings.GetConfigCommand(false)} | Compile-ALProjectTree -OrderedApps (Get-ALAppOrder -Path ${currentRoot}) -PackagesPath ${currentRoot}`);
}

export function InstallTree() {
Expand All @@ -47,28 +34,25 @@ export function UninstallTree() {

export function PublishTree() {
terminal.PSTerminal.show(true);
const currentRoot = GetCurrentRootPath();
var skipVerification = 'false';
if (vscode.workspace.getConfiguration().get('navertical.IgnoreVerification')) {
skipVerification = 'true';
}
terminal.SendPSText(`Read-ALConfiguration -Path ${currentRoot} | Publish-ALAppTree -OrderedApps (Get-ALAppOrder -Path ${currentRoot}) -PackagesPath ${currentRoot} -SkipVerification ${skipVerification}`);
const currentRoot = settings.GetCurrentRootPath();
terminal.SendPSText(`${settings.GetConfigCommand(true)} | Publish-ALAppTree -OrderedApps (Get-ALAppOrder -Path ${currentRoot}) -PackagesPath ${currentRoot} -SkipVerification ${skipVerification}`);

}

export function UnpublishTree() {
terminal.PSTerminal.show(true);
const currentRoot = GetCurrentRootPath();

terminal.SendPSText(`Read-ALConfiguration -Path ${currentRoot} | Unpublish-ALAppTree -OrderedApps (Get-ALAppOrder -Path ${currentRoot})`);
const currentRoot = settings.GetCurrentRootPath();
terminal.SendPSText(`${settings.GetConfigCommand(true)} | Unpublish-ALAppTree -OrderedApps (Get-ALAppOrder -Path ${currentRoot})`);

}

export function GetConfiguration() {
terminal.PSTerminal.show(true);
const currentRoot = GetCurrentRootPath();

terminal.SendPSText(`Read-ALConfiguration -Path ${currentRoot}`);
terminal.SendPSText(`${settings.GetConfigCommand(true)}`);

}

Expand All @@ -78,29 +62,22 @@ export function CreatePackage() {
}

export function CreateEnvironment() {
const currentRoot = GetCurrentRootPath();
terminal.PSTerminal.show(true);
terminal.SendPSText(`Read-ALConfiguration -Path ${currentRoot} | Init-ALEnvironment`);

terminal.SendPSText(`${settings.GetConfigCommand(true)} | Init-ALEnvironment`);
}

export function RemoveEnvironment() {
const currentRoot = GetCurrentRootPath();
terminal.PSTerminal.show(true);
terminal.SendPSText(`Read-ALConfiguration -Path ${currentRoot} | Remove-ALEnvironment`);

terminal.SendPSText(`${settings.GetConfigCommand(true)} | Remove-ALEnvironment`);
}

export function StartEnvironment() {
const currentRoot = GetCurrentRootPath();
terminal.PSTerminal.show(true);
terminal.SendPSText(`Read-ALConfiguration -Path ${currentRoot} | Start-ALEnvironment`);

terminal.SendPSText(`${settings.GetConfigCommand(true)} | Start-ALEnvironment`);
}

export function StopEnvironment() {
const currentRoot = GetCurrentRootPath();
terminal.PSTerminal.show(true);
terminal.SendPSText(`Read-ALConfiguration -Path ${currentRoot} | Stop-ALEnvironment`);

terminal.SendPSText(`${settings.GetConfigCommand(true)} | Stop-ALEnvironment`);
}

5 changes: 4 additions & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import * as vscode from 'vscode';
import * as terminal from './terminal';
import * as actions from './actions';
import * as newapp from './newapp';
import * as remote from './remote';
import { workspace, WorkspaceEdit, ShellExecution } from 'vscode';
import { removeListener } from 'cluster';

// this method is called when your extension is activated
// your extension is activated the very first time the command is executed
Expand Down Expand Up @@ -34,7 +36,8 @@ export function activate(context: vscode.ExtensionContext) {
vscode.commands.registerCommand('navertical.StartEnvironment',()=>{actions.StartEnvironment()}),
vscode.commands.registerCommand('navertical.InitNewAppFolder',()=>{newapp.InitNewAppFolder()}),
vscode.commands.registerCommand('navertical.GetConfiguration',()=>{actions.GetConfiguration()}),
vscode.commands.registerCommand('navertical.ForceDownload',()=>{actions.ForceDownload()})
vscode.commands.registerCommand('navertical.ForceDownload',()=>{actions.ForceDownload()}),
vscode.commands.registerCommand('navertical.SetupRemoteDockerFolder',()=>{remote.SetupRemoteDockerFolder()})
];

context.subscriptions.concat(commandList);
Expand Down
21 changes: 21 additions & 0 deletions src/remote.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
'use strict';
import * as vscode from "vscode";
import * as terminal from './terminal';
import * as path from "path";
import * as fs from "fs";
import * as guid from './guid';
import * as settings from "./settings"

import { workspace, WorkspaceEdit, ShellExecution } from 'vscode';
import { execFile } from "child_process";

export function SetupRemoteDockerFolder()
{
terminal.PSTerminal.show(true);
const currentRoot = settings.GetCurrentRootPath();
const hostPath = 'c:\\sources\\';
const shareName = 'sources';
const mapAs = 'S';
terminal.SendPSText(`${settings.GetConfigCommand(true)} | Set-ALDockerHostFolder -HostPath ${hostPath} -ShareName ${shareName} -ShareMapAs ${mapAs}`);

}
57 changes: 57 additions & 0 deletions src/settings.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
'use strict';
import * as vscode from "vscode";
import * as terminal from './terminal';
import * as path from "path";
import * as fs from "fs";
import * as guid from './guid';

import { workspace, WorkspaceEdit, ShellExecution } from 'vscode';
import { execFile } from "child_process";

export function GetCurrentRootPath():string
{
if (vscode.workspace.workspaceFolders.length === 1) {
return vscode.workspace.workspaceFolders[0].uri.fsPath+'\\..';
}
if (vscode.window.activeTextEditor===undefined) {
return vscode.workspace.workspaceFolders[0].uri.fsPath+'\\..';
}
const fileUri = vscode.window.activeTextEditor.document.uri;
const workspace = vscode.workspace.getWorkspaceFolder(fileUri);
console.log(`Navertical: current workspace folder is: ${workspace.uri.fsPath}`);
return workspace.uri.fsPath+'\\..';
}

export function IsRemoteDocker():boolean
{
const remoteHost = vscode.workspace.getConfiguration().get('navertical.DockerHost').toString();
return (remoteHost.toLowerCase()!=='localhost');
}

export function GetRemoteDockerName():string
{
const remoteHost = vscode.workspace.getConfiguration().get('navertical.DockerHost').toString();
return remoteHost;
}

export function GetRemoteDockerSSL():boolean
{
const remoteHostSSL = <boolean>vscode.workspace.getConfiguration().get('navertical.DockerHostUseSSL');
return remoteHostSSL;
}

export function GetRemoteMapping():string
{
const remoteHostMapping = vscode.workspace.getConfiguration().get('navertical.DockerHostFolderMap').toString();
return remoteHostMapping;
}

export function GetConfigCommand(remote:boolean):string
{
const currentRoot = GetCurrentRootPath();
if (!remote || !IsRemoteDocker()) {
return `Read-ALConfiguration -Path ${currentRoot}`
} else {
return `Read-ALConfiguration -Path ${currentRoot} -DockerHost ${GetRemoteDockerName()} -DockerHostSSL $${GetRemoteDockerSSL()} -PathMapString '${GetRemoteMapping()}'`
}
}

0 comments on commit d5e6bd8

Please sign in to comment.