Skip to content

Commit

Permalink
refactor(scanner)!: Rename the package based storages
Browse files Browse the repository at this point in the history
Rename the package based file and Postgres storage to match the names of
their provenance based counterparts.

Signed-off-by: Martin Nonnenmacher <[email protected]>
  • Loading branch information
mnonnenmacher committed Mar 17, 2024
1 parent f854f1c commit af4a747
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import com.github.ajalt.clikt.parameters.options.required
import com.github.ajalt.clikt.parameters.types.file

import org.ossreviewtoolkit.helper.utils.readOrtResult
import org.ossreviewtoolkit.scanner.storages.FileBasedStorage
import org.ossreviewtoolkit.scanner.storages.PackageBasedFileStorage
import org.ossreviewtoolkit.utils.common.expandTilde
import org.ossreviewtoolkit.utils.ort.storage.LocalFileStorage

Expand All @@ -51,7 +51,7 @@ internal class ImportScanResultsCommand : CliktCommand(

override fun run() {
val ortResult = readOrtResult(ortFile)
val scanResultsStorage = FileBasedStorage(LocalFileStorage(scanResultsStorageDir))
val scanResultsStorage = PackageBasedFileStorage(LocalFileStorage(scanResultsStorageDir))

Check warning on line 54 in helper-cli/src/main/kotlin/commands/ImportScanResultsCommand.kt

View check run for this annotation

Codecov / codecov/patch

helper-cli/src/main/kotlin/commands/ImportScanResultsCommand.kt#L54

Added line #L54 was not covered by tests
val ids = ortResult.getProjects().map { it.id } + ortResult.getPackages().map { it.metadata.id }

ids.forEach { id ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ import org.ossreviewtoolkit.model.config.PackageConfiguration
import org.ossreviewtoolkit.model.config.VcsMatcher
import org.ossreviewtoolkit.model.licenses.LicenseClassifications
import org.ossreviewtoolkit.model.readValue
import org.ossreviewtoolkit.scanner.storages.FileBasedStorage
import org.ossreviewtoolkit.scanner.storages.PackageBasedFileStorage
import org.ossreviewtoolkit.utils.common.expandTilde
import org.ossreviewtoolkit.utils.common.safeMkdirs
import org.ossreviewtoolkit.utils.ort.storage.LocalFileStorage
Expand Down Expand Up @@ -119,7 +119,7 @@ internal class CreateCommand : CliktCommand(
override fun run() {
outputDir.safeMkdirs()

val scanResultsStorage = FileBasedStorage(LocalFileStorage(scanResultsStorageDir))
val scanResultsStorage = PackageBasedFileStorage(LocalFileStorage(scanResultsStorageDir))

Check warning on line 122 in helper-cli/src/main/kotlin/commands/packageconfig/CreateCommand.kt

View check run for this annotation

Codecov / codecov/patch

helper-cli/src/main/kotlin/commands/packageconfig/CreateCommand.kt#L122

Added line #L122 was not covered by tests
val scanResults = scanResultsStorage.read(Package.EMPTY.copy(id = packageId)).getOrThrow().run {
listOfNotNull(
find { it.provenance is RepositoryProvenance },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ import io.kotest.engine.spec.tempdir

import org.ossreviewtoolkit.utils.ort.storage.LocalFileStorage

class FileBasedStorageFunTest : AbstractPackageBasedScanStorageFunTest() {
override fun createStorage() = FileBasedStorage(LocalFileStorage(tempdir()))
class PackageBasedFileStorageFunTest : AbstractPackageBasedScanStorageFunTest() {
override fun createStorage() = PackageBasedFileStorage(LocalFileStorage(tempdir()))
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ import org.ossreviewtoolkit.utils.test.PostgresListener

private val postgresListener = PostgresListener()

class PostgresStorageFunTest : AbstractPackageBasedScanStorageFunTest(postgresListener) {
override fun createStorage() = PostgresStorage(dataSource = postgresListener.dataSource)
class PackageBasedPostgresStorageFunTest : AbstractPackageBasedScanStorageFunTest(postgresListener) {
override fun createStorage() = PackageBasedPostgresStorage(dataSource = postgresListener.dataSource)
}
8 changes: 4 additions & 4 deletions scanner/src/main/kotlin/ScanStorages.kt
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ import org.ossreviewtoolkit.scanner.provenance.ResolvedArtifactProvenance
import org.ossreviewtoolkit.scanner.provenance.ResolvedRepositoryProvenance
import org.ossreviewtoolkit.scanner.provenance.UnresolvedPackageProvenance
import org.ossreviewtoolkit.scanner.storages.ClearlyDefinedStorage
import org.ossreviewtoolkit.scanner.storages.FileBasedStorage
import org.ossreviewtoolkit.scanner.storages.PostgresStorage
import org.ossreviewtoolkit.scanner.storages.PackageBasedFileStorage
import org.ossreviewtoolkit.scanner.storages.PackageBasedPostgresStorage
import org.ossreviewtoolkit.scanner.storages.ProvenanceBasedFileStorage
import org.ossreviewtoolkit.scanner.storages.ProvenanceBasedPostgresStorage
import org.ossreviewtoolkit.scanner.storages.Sw360Storage
Expand Down Expand Up @@ -132,13 +132,13 @@ private fun createStorage(config: ScanStorageConfiguration): ScanStorage =

private fun createFileBasedStorage(config: FileBasedStorageConfiguration) =
when (config.type) {
StorageType.PACKAGE_BASED -> FileBasedStorage(config.backend.createFileStorage())
StorageType.PACKAGE_BASED -> PackageBasedFileStorage(config.backend.createFileStorage())
StorageType.PROVENANCE_BASED -> ProvenanceBasedFileStorage(config.backend.createFileStorage())
}

private fun createPostgresStorage(config: PostgresStorageConfiguration) =
when (config.type) {
StorageType.PACKAGE_BASED -> PostgresStorage(
StorageType.PACKAGE_BASED -> PackageBasedPostgresStorage(
DatabaseUtils.createHikariDataSource(config = config.connection, applicationNameSuffix = TOOL_NAME)
)
StorageType.PROVENANCE_BASED -> ProvenanceBasedPostgresStorage(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const val SCAN_RESULTS_FILE_NAME = "scan-results.yml"
/**
* A [PackageBasedScanStorage] using a [FileStorage] as backend. Scan results are serialized using [YAML][yamlMapper].
*/
class FileBasedStorage(
class PackageBasedFileStorage(
/**
* The [FileStorage] to use for storing scan results.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ private val TABLE_NAME = ScanResults.tableName
/**
* The Postgres storage back-end.
*/
class PostgresStorage(
class PackageBasedPostgresStorage(
/**
* The JDBC data source to obtain database connections.
*/
Expand Down

0 comments on commit af4a747

Please sign in to comment.