Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow one config to extend another configuration #268

Closed
Playit3110 opened this issue Jun 28, 2021 · 6 comments
Closed

Allow one config to extend another configuration #268

Playit3110 opened this issue Jun 28, 2021 · 6 comments
Labels
enhancement New feature or request good first issue Issues/features involving simple code changes

Comments

@Playit3110
Copy link

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
Copy link
Owner

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 SchoofsKelvin changed the title Feature Request Allow one config to extend another configuration Jun 29, 2021
@SchoofsKelvin SchoofsKelvin added enhancement New feature or request good first issue Issues/features involving simple code changes labels Jun 29, 2021
@jrbgit
Copy link

jrbgit commented Oct 2, 2021

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
Copy link
Owner

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
Copy link

jrbgit commented Oct 4, 2021

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

@dery168
Copy link

dery168 commented Mar 16, 2023

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
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Issues/features involving simple code changes
Projects
None yet
Development

No branches or pull requests

4 participants