✨ Allow using a different Hex deployment #5173
Open
+150
−98
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.
Closes #2817
This PR adds support for hex mirrors using the
HEXPM_REPOSITORY_URLandHEXPM_API_URLenvironment variables.If they are set, the respective base URLs will be used read operations like version resolution and fetching of packages. Note that these are only mirrors. Fully private repositories are not supported, so package publishing, updating, etc. disregards these variables.
I've manually tested these changes and made sure the only remaining calls to
hexpm::Config::newhappen in the publish, retire, etc. commands, but please let me know if you can think of a way to add automated tests.Please also let me know of any places where I should document these environment variables!
(Lack of) Authentication
I initially wanted to implement authentication as well. This would have been easy before, but unfortunately the addition of mirrors complicated things quite a bit. As the repository and api mirror don't necessarily belong together, we would have to juggle up to 3 different authentication tokens ("main" hexpm instance for publishing operations, api mirror, and repository mirror.)
Therefore, I think we would need two additional configuration options to set authentication tokens. Something like
HEXPM_REPOSITORY_MIRROR_API_KEY. On top of that,hexpm-rustrequires you pass it two URLs but only a single token, so that would also need to be adapted.