vscode-sshfs icon indicating copy to clipboard operation
vscode-sshfs copied to clipboard

Allow one config to extend another configuration

Open Playit3110 opened this issue 4 years ago • 4 comments

I really like your extension, but it is hard to allways copy the credentials to the new connection. Is it possible to move the credentials like Username, Password, Host, ... to the group and only leave the path in the entry itself? So that you can open multiple folders on one remote server?

Playit3110 avatar Jun 28 '21 15:06 Playit3110

Having a way of defining common properties for a bunch of configs at once sounds like a useful feature, so I'll change this issue into adding that feature.

So for this feature request:

  • Add an "extendsConfig" field or something similar that specifies the name of another config
  • In calculateActualConfig, have it first pre-fill the calculated config with the calculated of its extendsConfig
  • Add a dropdown field to the settings UI for this new field (still need to actually transmit config names to UI webview)
  • Need to make sure to check for cyclic dependencies, both in calculateActualConfig and the UI

For your specific problem, you can actually reuse the same config if it's just the path you want to change:

  • Your config Root can be set to e.g. /root
  • You can connect the workspace folder, which will add ssh://config-name/ as a workspace folder
  • If you open your workspace settings in JSON (Open Workspace Settings (JSON) command), you'll see something like:
{
	"folders": [
		{
			"name": "SSH FS - config-name",
			"uri": "ssh://config-name/"
		}
	],
}
  • You can change that uri to whatever you want
  • You can also copy-paste that object to have several folders pointing at several directories
  • Everything is relative to your Root folder, so e.g. ssh://config-name/test/ for /root/test

Alternatively, if you try to add a workspace folder (or open a terminal) using the Create instant connection option when prompted, you can type different-user@config-name/different/path to have a different user or path (relative to Root again) instead.

SchoofsKelvin avatar Jun 29 '21 22:06 SchoofsKelvin

This is a much better way than I had started to code it myself before I checked the roadmap. However, my suggestion might still be good to have since most people using the extension will have existing configurations that were not setup using the new method that extends a confguration.

I was simply going to add a 'Clone configuration' option to the command pallet (and possibly a clone option next to each existing configuration). If launched from the command pallet it would prompt with a dropdown to select an existing configuration. Then it would pass all the existing configuration's settings into the create new config screen. From there you could modify the settings according to your needs and save it as a new configuration.

The method you plan on creating is much better because in theory if you needed to update a connection option - all existing configurations would inherit the change. However, like I said earlier, this new feature wouldn't work for existing configs that were already configured before this new feature.

Additionally, there may be cases where you don't want the new configuration to inherit another connections configuration but starting with a cloned copy of another configuration could be helpful to quickly create a new one. Maybe I'm overthinking it but the option of cloning an existing configuration seems like it might be a quicker way to get exactly what you need, especially if the setting you want to keep isn't one that was set to be inherrited. Does that make sense?

EDIT: by the way, this extension rocks. I used to mount external drives over SSHFS via the command line and then open the directory in my editor of choice. This extension has saved me a lot of time and frustration. Not to mention that the speeds are significantly better than how I was mounting remote drives in the past! 🥇

jrbgit avatar Oct 02 '21 23:10 jrbgit

I'd probably add a clone button in the Settings UI, either as an inline button when selecting a config, or as some sort of "Click here to copy settings from another config" within the config editor itself. Perhaps even go fancy and have a side-by-side editor that lets you compare and pick which fields to copy over.

That's for copying configs. I'm of course still gonna add a way to extend configs, as I originally mentioned.

SchoofsKelvin avatar Oct 03 '21 17:10 SchoofsKelvin

Agreed - Extending configs is super useful. I like your fancy idea 😉 and your suggested implementation of copying configs is probably easier....

jrbgit avatar Oct 04 '21 00:10 jrbgit

Hi @SchoofsKelvin, could we proceed to implement this supper useful feature? As you suggested, we could start with simply add a a clone button in the Setting UI. Once user clicks it, everything will be clone into a new connection setting but rename it to a suffix of "- copy". I could work on it myself and raise a PR to you.

dery168 avatar Mar 16 '23 16:03 dery168

The config now supports an extend option accepting a name or an array of names of other configs to extend from (6eff0be). Support for this has also be added to the Settings UI (a5372a4) and should be relatively intuitive.

This feature will be added in the next version of the extension, which should be v1.26.0.

In case config A extends config B and C, first the options from config B are taken, then from config C (overriding anything that B specified that C also specifies), and finally options from config A are taken, again overriding anything that B/C already defined that A also defines. In short, priority in the extend list goes from front-to-back followed by the config itself.

Also it's valid for a config to extend another config which in turn extends another config. If you end up with a cycle though, all related configs will not be loaded and you'll get an error message.

SchoofsKelvin avatar Mar 25 '23 22:03 SchoofsKelvin