-
Notifications
You must be signed in to change notification settings - Fork 12
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
refactor search and implement replace command #69
Conversation
moves search functions to its own file and provides a struct common for search/replace operations. the struct is embedded with commands that utilize search so that the commands contain the search paramters and the commands implement an interface for retrieving the parameters. this allows common methods to be located on a `Searcher` struct that can reference the command via the interface.
I'll take a pass at codeclimate feedback tomorrow. |
Slightly refactored for codeclimate feedback. Not sure what to do with the test failing version check for dirty vs. not. I think this is in a good human review spot though. 👍🏻 |
@mattlqx this looks great! Thank you 🙇 Concerning the failing test: For some reason, It seems I cannot highlight/suggest changes here in files which were not changed. |
@mattlqx it seems That also explains why |
Thanks, I'm still a noob on golang dependency stuff. A |
Afaik I think the easiest way to resolve this, is to get the dep state from latest One way this could be done:
I will have a look at updating all dependencies on a different branch later. You dont need to fight through that :) |
the `replace` command will do a match in the same fashion as `grep` but instead of presenting results with search patterns highlighted, it will highlight matches in red followed immediately by replacement string in green. in this way, it is easy to identify on one line what will be matched and replaced. by default, the operation will ask for confirmation before writing back to vault. it is possible to use flags `-y` to write without confirmation, `-n` to skip confirmation and not write aka dry-run, and limit scope to keys (`-k`) and values (`-v`) in the same way as in `grep`.
Thanks. Looks like it's finally gotten past it. Maybe had something to do with my local go 1.16beta version on this Mac M1. I used a docker container of go 1.15.7 to build. Also just fyi, |
Wow To be very honest the way I handle the deps here is also outdated afaik. You shouldn't take that as a positive example of how to do stuff in go :) I will merge this PR later tonight and make a new release. Again, thank you @mattlqx for these awesome contributions. You have improved |
Thanks! This is going to be a very useful tool for managing our application configurations so I'm happy to help. |
just want to make sure that the replace operation is not wiping out the rest of the secret.
The
replace
command will do a match in the same fashion asgrep
but instead of presenting results with search patterns highlighted, it will highlight matches in red followed immediately by replacement string in green. In this way, it is easy to identify on one line what will be matched and replaced. by default, the operation will ask for confirmation before writing back to vault. it is possible to use flags-y
to write without confirmation,-n
to skip confirmation and not write aka dry-run, and limit scope to keys (-k
) and values (-v
) in the same way as ingrep
.Moves search functions to its own file and provides a struct common for search/replace operations. The struct is embedded with commands that utilize search so that the commands contain the search paramters and the commands implement an interface for retrieving the parameters. This allows common methods to be located on a
Searcher
struct that can reference the command via the interface.There's a lot of fat that can be trimmed from this implementation. I'm not super happy with it, but I think this is the kind of functionality I originally envisioned with #59 . I think in the future, it'd be nice to give the option of a traditional diff display instead of strictly inline color highlighting.