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

WIP: Allow for custom registries urls #1434

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

THenry14
Copy link
Member

@THenry14 THenry14 commented Jul 9, 2024

WIP: please do not review yet

The PR aims to allow scarb to use a custom registry, by defining an env variable

static DEFAULT_REGISTRY_INDEX: Lazy<&'static str> = Lazy::new(|| {
let registry_url = env::var("SCARB_REGISTRY_URL")
.unwrap_or_else(|_| "https://there-is-no-default-registry-yet.com".into());
Box::leak(registry_url.into_boxed_str())
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would be happy to hear any thoughts about this, as I'm not sure about its implications. Box::leak is used to convert the String to a &'static str by leaking the heap-allocated memory. This should be safe in this context because Lazy ensures the value is only initialized once and lives for the entire program duration, but still this may not be THE optimal way to achieve this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can technically keep Lazy<String> there and it'd be more collect.

But I think this is not the best approach for implementing this. I'd rather put this into Config, so that this could eventually be stored in some kind of a file. After all, someone might want to use a custom proxy for example and they'd like to write the URL once to some file and leave it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, could make more sense, thanks for pointers.
btw is this something that, in your opinion, could be settable from the manifest file? Just wondering how I should approach this

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely not from the manifest because this is something user-specific, not project

Cargo has this: https://doc.rust-lang.org/cargo/reference/config.html

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok cool! so based on this, and after discussing things with @maciektr , let's plan the work accordingly:

Sounds good?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds good

@THenry14 THenry14 marked this pull request as draft July 19, 2024 07:37
@THenry14 THenry14 changed the title Allow for custom registries urls WIP: Allow for custom registries urls Jul 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants