SchoofsKelvin / vscode-sshfs

Extension for Visual Studio Code: File system provider using SSH
GNU General Public License v3.0
543 stars 36 forks source link

Allow one config to extend another configuration #268

Closed Playit3110 closed 1 year ago

Playit3110 commented 3 years ago

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?

SchoofsKelvin commented 3 years ago

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:


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

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.

jrbgit commented 2 years ago

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! 🥇

SchoofsKelvin commented 2 years ago

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.

jrbgit commented 2 years ago

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

dery168 commented 1 year ago

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.

SchoofsKelvin commented 1 year ago

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.