Skip to content

Commit

Permalink
refactor(model): Use PluginConfiguration as a class name
Browse files Browse the repository at this point in the history
Rename `PackageCurationProviderConfiguration` to `PluginConfiguration`
as a preparation for using it beyond `PackageCurationProvider`s.

Signed-off-by: Sebastian Schuberth <[email protected]>
  • Loading branch information
sschuberth committed Mar 5, 2023
1 parent 56400c1 commit 5cfca01
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 23 deletions.
4 changes: 2 additions & 2 deletions cli/src/funTest/kotlin/OrtMainFunTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import org.ossreviewtoolkit.downloader.VersionControlSystem
import org.ossreviewtoolkit.model.OrtResult
import org.ossreviewtoolkit.model.config.OrtConfiguration
import org.ossreviewtoolkit.model.config.OrtConfigurationWrapper
import org.ossreviewtoolkit.model.config.PackageCurationProviderConfiguration
import org.ossreviewtoolkit.model.config.PluginConfiguration
import org.ossreviewtoolkit.model.config.REFERENCE_CONFIG_FILENAME
import org.ossreviewtoolkit.model.readValue
import org.ossreviewtoolkit.model.writeValue
Expand Down Expand Up @@ -70,7 +70,7 @@ class OrtMainFunTest : StringSpec() {
OrtConfigurationWrapper(
OrtConfiguration(
packageCurationProviders = listOf(
PackageCurationProviderConfiguration(
PluginConfiguration(
type = "File",
config = mapOf("path" to projectDir.resolve("gradle/curations.yml").path)
)
Expand Down
6 changes: 3 additions & 3 deletions model/src/main/kotlin/config/OrtConfiguration.kt
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ data class OrtConfiguration(
* the priority of the providers: Providers that appear earlier in the list can overwrite curations for the same
* package from providers that appear later in the list.
*/
val packageCurationProviders: List<PackageCurationProviderConfiguration> = listOf(
PackageCurationProviderConfiguration(type = "DefaultDir"),
PackageCurationProviderConfiguration(type = "DefaultFile")
val packageCurationProviders: List<PluginConfiguration> = listOf(
PluginConfiguration(type = "DefaultDir"),
PluginConfiguration(type = "DefaultFile")
),

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,26 @@ import com.sksamuel.hoplite.ConfigAlias

import org.ossreviewtoolkit.utils.common.Plugin

data class PackageCurationProviderConfiguration(
data class PluginConfiguration(
/**
* The [type][Plugin.type] of the package curation provider.
* The [type][Plugin.type] of the plugin to configure.
*/
@ConfigAlias("name")
val type: String,

/**
* A unique identifier for the package curation provider.
* A unique identifier for the plugin instance to be created, to distinguish plugins of the same type but with
* different configuration.
*/
val id: String = type,

/**
* Whether this curation provider is enabled.
* A flag to indicate whether this plugin should be enabled or not.
*/
val enabled: Boolean = true,

/**
* The configuration of the package curation provider. See the specific implementation for available configuration
* options.
* The configuration of the plugin. See the specific implementations for available configuration options.
*/
val config: Map<String, String> = emptyMap()
)
14 changes: 7 additions & 7 deletions model/src/test/kotlin/config/OrtConfigurationTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -64,24 +64,24 @@ class OrtConfigurationTest : WordSpec({
}

ortConfig.packageCurationProviders should containExactly(
PackageCurationProviderConfiguration(type = "DefaultFile"),
PackageCurationProviderConfiguration(type = "DefaultDir"),
PackageCurationProviderConfiguration(
PluginConfiguration(type = "DefaultFile"),
PluginConfiguration(type = "DefaultDir"),
PluginConfiguration(
type = "File",
id = "SomeCurationsFile",
config = mapOf("path" to "/some-path/curations.yml", "mustExist" to "true")
),
PackageCurationProviderConfiguration(
PluginConfiguration(
type = "File",
id = "SomeCurationsDir",
config = mapOf("path" to "/some-path/curations-dir", "mustExist" to "false")
),
PackageCurationProviderConfiguration(type = "OrtConfig", enabled = true),
PackageCurationProviderConfiguration(
PluginConfiguration(type = "OrtConfig", enabled = true),
PluginConfiguration(
type = "ClearlyDefined",
config = mapOf("serverUrl" to "https://api.clearlydefined.io", "minTotalLicenseScore" to "80")
),
PackageCurationProviderConfiguration(
PluginConfiguration(
type = "SW360",
config = mapOf(
"restUrl" to "https://your-sw360-rest-url",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
package org.ossreviewtoolkit.plugins.packagecurationproviders.api

import org.ossreviewtoolkit.model.ResolvedPackageCurations.Companion.REPOSITORY_CONFIGURATION_PROVIDER_ID
import org.ossreviewtoolkit.model.config.PackageCurationProviderConfiguration
import org.ossreviewtoolkit.model.config.PluginConfiguration
import org.ossreviewtoolkit.model.utils.PackageCurationProvider
import org.ossreviewtoolkit.utils.common.ConfigurablePluginFactory
import org.ossreviewtoolkit.utils.common.Plugin
Expand All @@ -34,12 +34,12 @@ interface PackageCurationProviderFactory<CONFIG> : ConfigurablePluginFactory<Pac
val ALL = Plugin.getAll<PackageCurationProviderFactory<*>>()

/**
* Return a new (identifier, provider instance) tuple for each
* [enabled][PackageCurationProviderConfiguration.enabled] provider configuration in [configurations] ordered
* highest-priority first. The given [configurations] must be ordered highest-priority first as well.
* Return a new (identifier, provider instance) tuple for each [enabled][PluginConfiguration.enabled] provider
* configuration in [configurations] ordered highest-priority first. The given [configurations] must be ordered
* highest-priority first as well.
*/
fun create(
configurations: List<PackageCurationProviderConfiguration>
configurations: List<PluginConfiguration>
): List<Pair<String, PackageCurationProvider>> =
configurations.filter {
it.enabled
Expand Down

0 comments on commit 5cfca01

Please sign in to comment.