rust-lang / rustwide

Execute your code on the Rust ecosystem.
Apache License 2.0
182 stars 41 forks source link

Allow to pass registry ssh key #65

Closed l4l closed 2 years ago

pietroalbini commented 3 years ago

Hello, and thanks for the PR!

The code changes look good, but I'm worried about the extensibility of the API, as git2 supports more authentication methods than just in-memory SSH keys. I think the most extensible solution would be to make the AlternativeRegistry struct public, with an API similar to this:

use rustwide::{AlternativeRegistry, Crate};

let mut registry = AlternativeRegistry::new("https://github.com/rust-lang/crates.io-index");
registry.authenticate_with_ssh_key("key");

let krate = Crate::registry(&registry, "name", "version");
l4l commented 2 years ago

Oh, it seems I missed a notification for that thread, sorry for that.

AlternativeRegistry as a pub item makes a perfect sense, although it seems to be a breaking change. Is it fine?

UPD: it seems current changes are breaking anyway due to new Crate::registry arg. So I just proceed with the proposed option.

pietroalbini commented 2 years ago

Sounds good! We're also pre-1.0 on rustwide, so it's fine to make breaking changes, especially to make the API easier to extend in the future!

jyn514 commented 2 years ago

@pietroalbini I think this is waiting on your review.

gregvirgin commented 2 years ago

I'm currently working with cloudsmith.io, which will only support git credentials. We're configuring our own image to get around this, but want to see if this method could support adding to .git-credentials on the image as well.

pietroalbini commented 2 years ago

Sorry for the late merge, will release this soon!

pietroalbini commented 2 years ago

Released rustwide 0.15.0 with this change.