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

chore(model): Avoid a Hoplite deprecation warning #9283

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions model/src/main/kotlin/config/OrtConfiguration.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
package org.ossreviewtoolkit.model.config

import com.sksamuel.hoplite.ConfigLoaderBuilder
import com.sksamuel.hoplite.ExperimentalHoplite
import com.sksamuel.hoplite.PropertySource
import com.sksamuel.hoplite.addEnvironmentSource
import com.sksamuel.hoplite.fp.getOrElse
Expand Down Expand Up @@ -153,6 +154,7 @@ data class OrtConfiguration(
* The configuration file is optional and does not have to exist. However, if it exists, but does not
* contain a valid configuration, an [IllegalArgumentException] is thrown.
*/
@OptIn(ExperimentalHoplite::class)
fun load(args: Map<String, String>? = null, file: File? = null): OrtConfiguration {
val sources = listOfNotNull(
args?.filterKeys { it.startsWith("ort.") }?.takeUnless { it.isEmpty() }?.let {
Expand All @@ -174,6 +176,7 @@ data class OrtConfiguration(
.addEnvironmentSource()
.addPropertySources(sources)
.withContextResolverMode(ContextResolverMode.SkipUnresolved)
.withExplicitSealedTypes()
Copy link
Member

Choose a reason for hiding this comment

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

I think the ScanStorageConfiguration is the only sealed class we use in the config, but I don't think that we use discriminator fields there. I'm not sure if this is properly tested.

.build()

val config = loader.loadConfig<OrtConfigurationWrapper>()
Expand Down
Loading