Use JSON schemas for sshfs-configs in settings and ssh://<config> files

pull/13/head
Kelvin Schoofs 7 years ago
parent 82d8e065be
commit 75558fcdf3

@ -97,6 +97,7 @@ This will add a Workspace folder linked to a SSH (SFTP) session:
* ~~Fix bug where saving a file resets the permissions (when owner/root at least)~~ **DONE**
* ~~Allow loading PuTTY sessions when on windows~~ **DONE**
* Also have a command to directly use a PuTTY session (**TODO**)
* ~~Add proper JSON schema/validation for SSH FS configurations~~ **DONE**
* Fix bug where the Explorer shows a loading bar forever
* Fix bug where VSCode shows an error message about `no provider for ssh://NAME/`
* Allow loading (or automatically use) sessions from .ssh/config

@ -130,81 +130,26 @@
"title": "SSH FS Configuration",
"properties": {
"sshfs.configs": {
"type": "array",
"$schema": "http://json-schema.org/draft-06/schema#",
"$ref": "https://raw.githubusercontent.com/SchoofsKelvin/vscode-sshfs/c58a5432afb77f3dd97951245821eea589963227/settingsschema.json",
"default": [
{
"root": "/",
"root": "/tmp",
"host": "localhost",
"port": 22,
"username": "root",
"password": "CorrectHorseBatteryStaple"
}
],
"description": "A list of SSH FS configurations",
"items": {
"type": "object",
"required": [
"name",
"host",
"username"
],
"properties": {
"name": {
"type": "string",
"description": "The unique name for this configuration"
},
"root": {
"type": "string",
"description": "The remote folder to act as root folder",
"default": "/"
},
"host": {
"type": "string",
"description": "Hostname or IP address of the server"
},
"port": {
"type": "number",
"description": "Port number of the server",
"default": 22
},
"username": {
"type": "string",
"description": "Username for authentication"
},
"password": {
"type": [
"string",
"boolean"
],
"description": "Password for password-based user authentication"
},
"agent": {
"type": "string",
"description": "Path to ssh-agent's UNIX socket for ssh-agent-based user authentication (or 'pageant' when using Pagent on Windows)"
},
"privateKey": {
"type": "string",
"description": "String that contains a private key for either key-based or hostbased user authentication (OpenSSH format)"
},
"passphrase": {
"type": [
"string",
"boolean"
],
"description": "For an encrypted private key, this is the passphrase used to decrypt it"
},
"putty": {
"type": [
"string",
"boolean"
],
"description": "(Windows only) Use the settings from the given PuTTY session (set this to true to find one using the other settings)"
}
}
}
]
}
}
},
"jsonValidation": [
{
"fileMatch": "*.sshfs.json",
"url": "https://raw.githubusercontent.com/SchoofsKelvin/vscode-sshfs/c58a5432afb77f3dd97951245821eea589963227/configschema.json"
}
]
},
"scripts": {
"vscode:prepublish": "npm run compile",

@ -41,13 +41,13 @@ function createConfigFs(manager: Manager): SSHFileSystem {
authority: '<config>',
stat: (uri: vscode.Uri) => ({ type: vscode.FileType.File, ctime: 0, mtime: 0, size: 0 } as vscode.FileStat),
readFile: (uri: vscode.Uri) => {
const name = uri.path.substring(1, uri.path.length - 5);
const name = uri.path.substring(1, uri.path.length - 11);
let config = manager.getConfig(name) || defaultConfig;
config = { ...config, name: undefined! };
return new Uint8Array(new Buffer(JSON.stringify(config, undefined, 4)));
},
writeFile: (uri: vscode.Uri, content: Uint8Array) => {
const name = uri.path.substring(1, uri.path.length - 5);
const name = uri.path.substring(1, uri.path.length - 11);
try {
const config = JSON.parse(new Buffer(content).toString());
config.name = name;
@ -315,7 +315,7 @@ export class Manager implements vscode.FileSystemProvider, vscode.TreeDataProvid
this.onDidChangeTreeDataEmitter.fire();
}
public async commandConfigure(name: string) {
vscode.window.showTextDocument(vscode.Uri.parse(`ssh://<config>/${name}.json`), { preview: false });
vscode.window.showTextDocument(vscode.Uri.parse(`ssh://<config>/${name}.sshfs.json`), { preview: false });
}
public commandConfigDelete(name: string) {
this.commandDisconnect(name);

Loading…
Cancel
Save