Repository navigation
Conversation
|
Download the artifacts for this pull request:
See Testing a PR. |
|
Just want to make sure this is allow listing only official addons otherwise this can be a security concern. The advantage of the one off approach was that each one gets an intentional addon. |
|
Yes, official add-ons only, I updated the PR description. |
|
How would this map custom commands to add-ons? It wasn't clear to me in a quick read. For |
|
It doesn't search by commands, that add-ons might have, it looks at the add-on name. It's just a simpler approach. The name of the phpMyAdmin repo is |
| suggestAddonForUnknownCommand(os.Args[1]) | ||
| } | ||
|
|
||
| if err := RootCmd.Execute(); err != nil { |
There was a problem hiding this comment.
Should it perhaps try to execute first, and only do the fuzzy search if there's an error? Or is this just an unnecessary micro-optimization?
There was a problem hiding this comment.
That's because RootCmd.Execute() throws some error message that I can't prevent from being shown without intercepting it, which would make the code more complex.
$ ddev foobar
Error: unknown command "foobar" for "ddev"
Run 'ddev --help' for usage.
The above happens before the code goes inside the if you're asking about.
|
Could it perhaps do a search of all addons, but add some indication when a result is not an official addon? Or perhaps this is something that could be user-configured, either globally or per-project? People might like the discovery-aspect of something like this. Or, alternatively, perhaps a separate fuzzy search could be implemented to do a manual search within I tried Aqua out the other day, and it allows you to instantly search and install from its 1000+ binaries. https://aquaproj.github.io/. Very nice. In fact, i could see it being very useful to integrate into DDEV, so as to be able to easily install dependencies (I just wasted a lot of time writing bash scripts to install cloudflared (for cf tunnels) and flarectl (for managing dns records for the tunnels). Likewise I needed to do some workaround for yq not being available outside the containers. So, having the ability to install binaries into ~/.ddev/bin would have been exceptionally useful. I'm happy to open two separate issues (1. fuzzy search |
|
Thank you for working on this @stasadev
|
|
Tried: ✅ |
I think we can start with official for now, see how it goes, and maybe expand it later.
Yes, these are good ideas, I'm not sure about the second one with aqua (since it adds another dependency for DDEV), but you can open new issues to discuss them.
Yeah, I thought about that too, I'll add something for that. (Not a normal DDEV warning, as it contains the I should also add:
That's correct. |
|
One side effect I noticed is that when you type Should it be here (this can be considered a feature)? |
|
Maybe you can exclude the common ddev- prefix in each name? |
Yes, I'll remove |
|
Ha. After playing with $ ddev down
Do you want to install ddev/ddev-browsersync add-on? [Y/n] (yes): |
|
I guess we don't need a fuzzy search with such confusing results, Ddev-brOWsersyNc, but a partial match would be fine. |
f3bca85 to
bc26fa2
Compare
|
I refactored the logic:
|
Co-authored-by: nLightened Development LLC <[email protected]> Co-authored-by: nlighteneddesign <[email protected]>
Co-authored-by: tyler36 <[email protected]>
bc26fa2 to
dc81f5d
Compare
|
i think the utility of this would be quite minimal without fuzzy search. There's all sorts of things that could be done to address the issue you found. some ideas:
|
|
@nickchomey, thanks for the suggestion, but after much thought, I wouldn't add it.
I don't think it's necessary, on a large scale it only adds complexity for small benefits. For example, Of course, this applies to all the commands we have and adds even more confusion.
This is completely customizable on the user side. If a user needs fzf, they should make it work for the entire shell to get 100% benefit. Personally, I use this plugin https://github.com/Aloxaf/fzf-tab for Zsh. And we have an open issue about UI: |
|
I'm wondering if my minimal approach has more utility in the end. The approach I have does require someone adding the list of commands for each addon, but you know for sure which addon is being requested for a given command because it is defined. The approach I had works even when the common command does not match the addon name which this approach does not cover. This still gives me a nagging concern for security, especially if fuzzy searching gets added back in. It just makes it easier for an unintended addon to be added. There is more work to be done to match all of the current official addons with my approach, but it is finite and you can make adding the global command part of the adoption process it becomes more maintainable. Also my PR covers the most popular addon at the moment so it's a good test if it is something the community will like. I worry this approach will accidentally request installs of things more often and become annoying. If I mistype a command now it just says unrecognized, where this approach increases the likely hood I have to answer a prompt instead of just fixing my typo. There is also a clean MR to reference to add or modify these install commands if you need to enhance or modify a specific one whereas I do not see a hook to modify behavior in this option. |
|
A related experiment was abandoned because of unpredictable results. Here we were trying to let people automatically run any command that existed inside the web container: |
|
I wasn't aware about that experiment. After reading it, I see that I'm trying to get it to work for an unknown scope, and it's undocumented. It works fine, but maybe it should be in the scope of Something like |
|
That definitely scope it, but it defeats the purpose of the original PR. I think both could work. The So you have a more convenient install command and a more convenient fail state for running an addon command when the addon does not exist. |
This is probably too fragile, and if we have it, it could have bad consequences when implementing commands in the future.
We already have a lot of flags for The idea presented in the PR for the Perhaps a better option that we should focus on is an Add-on Registry where people can find what they need. Closing this in favor of: @tyler36, if you agree, please also close: |
The Issue
How This PR Solves The Issue
Tries to find a matching official add-on for unknown command and installs it.
Manual Testing Instructions
Try things from
ddev get --listin the DDEV project folder:ddev phpmyadminddev redisddev adminerddev redis-7After installing the add-on, repeat the same command, i.e. install the Redis add-on using
ddev redisand then runddev redisagain to check.Automated Testing Overview
Release/Deployment Notes