Configure ssh.clientOptions using environment variables. Fixes go-git#411. #517
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I stumbled upon #411 (which is actually caused by golang/go#29286) and I did not like the idea of relying solely on editing the "known_hosts" file as a workaround. So I tried to see if I could set ssh client parameters in code.
Although a work in progress, I think this might be a worthy (very small) contribution.
I chose to do it with environment variables at first to minimize changes in existing code, but I also think this approach may be better suited for applications that use go-git in container environments (as opposed to a configuration file) and ones that deal with a limited set of remote repositories.
Maybe a more general approach might be reading a standard ssh client (ssh_config) file; the file format already allows setting different parameters for different remote hosts. However, in containers/kubernetes scenarios, creating a file and making it available as a volume seems to be too much, unless you really need many different "profiles" in your use case.