Make the Disco URL configurable in ORT - #12257
m-suchecki wants to merge 2 commits into
Conversation
e98c11c to
48be018
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #12257 +/- ##
=========================================
Coverage 59.21% 59.21%
Complexity 1892 1892
=========================================
Files 366 366
Lines 13839 13839
Branches 1462 1462
=========================================
Hits 8195 8195
Misses 5115 5115
Partials 529 529
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
d09a3ee to
a8eb1ab
Compare
sschuberth
left a comment
There was a problem hiding this comment.
I'm not sure about this. Do we really need to be able to customize the foojay discoapi URL, or would it be sufficient to use the existing customJdkUrl feature (to point to a download URL on a custom discoapi server)?
| * Return it on success, or an exception on failure. If [discoUrl] is null, use the default Disco API URL. | ||
| */ | ||
| internal fun findJdkPackage(distributionName: String, version: String): Result<Package> { | ||
| internal fun findJdkPackage(distributionName: String, version: String, discoUrl: String? = null): Result<Package> { |
There was a problem hiding this comment.
So far, it (deliberately) was an implementation detail that the JavaBootstrapper uses the foojay discoapi, but now you're exposing that via the signature. The idea was that we could switch from foojay discoapi (which had several issues in the past months) to something else without breaking changes in public API.
There was a problem hiding this comment.
I can rename it to something else, like jdkApiUrl or jdkRepoServerUrl, to remove the Foojay exposure.
There was a problem hiding this comment.
That would change nothing about the fact that the URL needs to point to a Disco-API-compatible server.
There was a problem hiding this comment.
Yes, that is true. But we are missing the point that said URL will be a mirror or custom server compatible with currently used API. Be it DiscoAPI or something else in the future. Here, we are providing a possibility to use a similar service, based on the officially used one. After all, it's an optional parameter and don't have to be used.
There was a problem hiding this comment.
Ah, so if the idea is to evolve JavaBootstrapper into a service-agnostic bootstrapper for JDKs that could also use something else than the Disco API service in the future, I'll all for it. But then then object should probably be turned into a class with a constructor argument that added the service URL (for whatever service it is) to here:
To override:
There was a problem hiding this comment.
So I made JavaBootstrapper service-agnostic. It takes JdkService interface and calls findPackage(). FoojayJdkService implements it and uses DiscoService to fetch JDKs.
There was a problem hiding this comment.
I am not sure about the current approach with the JdkService abstraction. As it is now, consumers still need to know the underlying implementation since they have to create a JavaBootstrapper instance passing in the service. Also, I am not sure that we are already in the position to design a flexible abstraction as long as we only know a single discovery service implementation.
The original plan was much less ambitious: to only make the URL of the disco service used by JavaBootstrapper configurable. I think, the main problem is that in places whether JavaBootstrapper is used, no configuration mechanism is available that could be used for this purpose.
@sschuberth, do you have an idea how this could be solved without inventing a complete abstraction layer?
| /** | ||
| * The URL of the Foojay Disco API. If unset, the Disco client's default URL is used. | ||
| */ | ||
| val discoUrl: String? = null |
There was a problem hiding this comment.
I'm not sure whether we should add this on the AnalyzerConfiguration level. Not all analyzers / package managers need to be able to bootstrap a JDK, and also the related javaVersion property is defined per-package-manager.
There was a problem hiding this comment.
Using AnalyzerConfiguration is the easiest way to set this variable, easily accessible by all package managers and didn't require too many changes. If you insist, it could probably be defined per-package-manager, similar to javaVersion. But it would be a duplicated entry, as I don't think anyone would use different servers for each package manager.
There was a problem hiding this comment.
Using
AnalyzerConfigurationis the easiest way to set this variable,
I believe this is one of the cases where the solution with the least amount of code changes is not the best solution in the sense of maintainability and need-to-know-principle.
There was a problem hiding this comment.
I see your point. Then it could be defined per-package-manager, in their config. Would that suffice?
There was a problem hiding this comment.
That would certainly be better in my view. But personally, I'm still not convinced that this feature is of general use / interest on top of the customJdkUrl feature we already have, at least for GradleInspector.
What about other @oss-review-toolkit/core-devs?
There was a problem hiding this comment.
I defined the URL variable (jdkRepositoryUrl) per-package-manager instead of using AnalyzerConfiguration.
a8eb1ab to
d58af13
Compare
d58af13 to
4c1814c
Compare
6ea8d3e to
94cb0ae
Compare
Evolve JavaBootstrapper into service-agnostic bootstrapper for JDKs that can use different JDK repositories. Some environments may want or need to route Disco API calls through custom endpoint. The URL was previously hardcoded in JavaBootstrapper to default DiscoService URL making it impossible to use a custom proxy or self-hosted mirror. Signed-off-by: Marek Suchecki <Marek.Suchecki@pl.bosch.com>
Update JavaBootstrapperFunTest.kt test case to include new JDK service. Add new FoojayJdkServiceFunTest.kt test class. Signed-off-by: Marek Suchecki <Marek.Suchecki@pl.bosch.com>
94cb0ae to
b4c1d71
Compare
This PR makes the Disco service URL configurable in JavaBootstrapper class. Refer to the single commits for further information.
Part of #12249.