Skip to content

feat(ubi): add support for self-hosted GitHub/GitLab #4765

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

Merged
merged 3 commits into from
Apr 14, 2025
Merged

Conversation

roele
Copy link
Contributor

@roele roele commented Apr 1, 2025

Fixes #4749

@roele roele force-pushed the issues/4749 branch 3 times, most recently from 844bbff to be3c5bd Compare April 2, 2025 13:45
@roele
Copy link
Contributor Author

roele commented Apr 11, 2025

I just gave this a spin this morning with a test binary.

[tools]
"ubi:gitlab-org/cli" = { version = "latest", exe = "glab", provider = "gitlab" }

Just adding the UBI forge support is not enough since mise fetches release versions to do the outdated check. So we also need an implementation of the GitLab API to fetch releases/tags and incorporate this into _list_remote_versions implementation. This extends further to the GitHub/GitLab implementations we use with a fixed API URL. Allowing for enterprise support would mean that we also need to fetch releases/tags from a custom URL. Thinking even further some enterprises are usually not on the latest API versions etc.

What i have a hard time with is that self.ba.opts() does not return anything within _list_remote_versions, so also the opts.get("tag_regex") in this method would not work.

@roele
Copy link
Contributor Author

roele commented Apr 12, 2025

@jdx Maybe you can shed some light on the concept of options. There is a BackendArg.opts() and a ToolRequest.options(). They seem to be the same thing but are not synced.

If i add the following example to my mise.toml

"ubi:gitlab-org/cli" = { version = "1.54.0", exe = "glab", provider = "gitlab" }

i get the error

cd mise
mise ERROR [~/Downloads/mise/mise.toml] ubi:gitlab-org/[email protected]: HTTP status client error (404 Not Found) for url (https://api.github.com/repos/gitlab-org/cli/releases)
mise ERROR error resolving versions
mise ERROR Run with --verbose or MISE_VERBOSE=1 for more information

this is due to the fact that BackendArgs.opts() used when listing remote versions is empty, it would expect options in the backend string like ubi:gitlab-org/cli[exe=glab,provider=gitlab]

Currently to get this working without errors one might need to define the following which IMO is redundant.

"ubi:gitlab-org/cli[exe=glab,provider=gitlab]" = { version = "1.54.0", exe = "glab", provider = "gitlab" }

@jdx
Copy link
Owner

jdx commented Apr 12, 2025

yeah I think what we should do is probably have tool options include all of the backend opts

@roele
Copy link
Contributor Author

roele commented Apr 12, 2025

The problem i currently face is the other way around. Under some circumstances (uncached tool) the following code block is called, where BackendArgs.opts() is empty and i don't have access to the ToolRequest which contains the options for the provider and API URL.

let opts = self.ba.opts();

@jdx
Copy link
Owner

jdx commented Apr 12, 2025

I see. I don't think it would be possible to get the tool options at that point since mise doesn't necessarily have a specific tool when finding the versions. Maybe when we parse the toml we could include the tool options on the backend arg?

@roele roele force-pushed the issues/4749 branch 4 times, most recently from d8cb87e to 722e45c Compare April 13, 2025 11:19
@roele
Copy link
Contributor Author

roele commented Apr 13, 2025

Turned out to be more work than anticipated but it should be working by now. Had to extend http.rs slightly since Github authentication was hardcoded. Only thing i could not test/verify properly is the token handling for the self-hosted URLs.

@roele roele marked this pull request as ready for review April 13, 2025 11:37
@roele roele force-pushed the issues/4749 branch 3 times, most recently from 1f8aa9c to bb586b7 Compare April 14, 2025 20:18
@jdx jdx merged commit 384e35e into jdx:main Apr 14, 2025
18 of 19 checks passed
jdx pushed a commit that referenced this pull request Apr 15, 2025
### 🚀 Features

- **(aqua)** support SLSA source_uri setting by
[@scop](https://github.com/scop) in
[#4833](#4833)
- **(aqua)** use source tag in SLSA verification by
[@scop](https://github.com/scop) in
[#4836](#4836)
- **(ubi)** add support for self-hosted GitHub/GitLab by
[@roele](https://github.com/roele) in
[#4765](#4765)

### 📚 Documentation

- Update configuration.md by [@jdx](https://github.com/jdx) in
[#4829](#4829)
- correct `mise use` paths by [@jdx](https://github.com/jdx) in
[c8374c0](c8374c0)
@roele roele deleted the issues/4749 branch April 15, 2025 08:09
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.

Ubi support of GitLab
2 participants