Skip to content

Commit

Permalink
Rename "provider" to "type" in an Identifier
Browse files Browse the repository at this point in the history
Also see the related purl discussion at [1]. What we were meaning by
"provider" actually more resembles purl's "type".

[1] package-url/purl-spec#33

Signed-off-by: Sebastian Schuberth <sebastian.schuberth@here.com>
  • Loading branch information
sschuberth committed Dec 3, 2018
1 parent 9ff3437 commit 1a44e0e
Show file tree
Hide file tree
Showing 34 changed files with 89 additions and 90 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import java.io.File
class DrupalIntegrationTest : AbstractIntegrationSpec() {
override val pkg: Package = Package(
id = Identifier(
provider = "PhpComposer",
type = "PhpComposer",
namespace = "",
name = "Drupal",
version = ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import java.io.File
class GradleIntegrationTest : AbstractIntegrationSpec() {
override val pkg: Package = Package(
id = Identifier(
provider = "Maven",
type = "Maven",
namespace = "org.gradle",
name = "Gradle",
version = "4.4.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import java.io.File
class PolymerIntegrationTest : AbstractIntegrationSpec() {
override val pkg: Package = Package(
id = Identifier(
provider = "Bower",
type = "Bower",
namespace = "",
name = "polymer",
version = "2.4.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import java.io.File
class SimpleFormIntegrationTest : AbstractIntegrationSpec() {
override val pkg: Package = Package(
id = Identifier(
provider = "Bundler",
type = "Bundler",
namespace = "",
name = "Simple Form",
version = ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import java.io.File
class VueJsIntegrationTest : AbstractIntegrationSpec() {
override val pkg: Package = Package(
id = Identifier(
provider = "NPM",
type = "NPM",
namespace = "",
name = "Vue.js",
version = ""
Expand Down
2 changes: 1 addition & 1 deletion analyzer/src/main/kotlin/MavenSupport.kt
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ class MavenSupport(workspaceReader: WorkspaceReader) {

return Package(
id = Identifier(
provider = "Maven",
type = "Maven",
namespace = mavenProject.groupId,
name = mavenProject.artifactId,
version = mavenProject.version
Expand Down
2 changes: 1 addition & 1 deletion analyzer/src/main/kotlin/PackageManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ abstract class PackageManager(

val errorProject = Project.EMPTY.copy(
id = Identifier(
provider = toString(),
type = toString(),
namespace = "",
name = relativePath,
version = ""
Expand Down
6 changes: 3 additions & 3 deletions analyzer/src/main/kotlin/managers/Bower.kt
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ class Bower(analyzerConfig: AnalyzerConfiguration, repoConfig: RepositoryConfigu
private const val REQUIRED_BOWER_VERSION = "1.8.4"
private const val SCOPE_NAME_DEPENDENCIES = "dependencies"
private const val SCOPE_NAME_DEV_DEPENDENCIES = "devDependencies"
private const val PROVIDER_NAME = "Bower"
private const val PACKAGE_TYPE = "Bower"

private fun extractPackageId(node: JsonNode) = Identifier(
provider = PROVIDER_NAME,
type = PACKAGE_TYPE,
namespace = "",
name = node["pkgMeta"]["name"].textValueOrEmpty(),
version = node["pkgMeta"]["version"].textValueOrEmpty()
Expand Down Expand Up @@ -206,7 +206,7 @@ class Bower(analyzerConfig: AnalyzerConfiguration, repoConfig: RepositoryConfigu
Bower(analyzerConfig, repoConfig)
}

override fun toString() = PROVIDER_NAME
override fun toString() = PACKAGE_TYPE

override fun command(workingDir: File?) = if (OS.isWindows) "bower.cmd" else "bower"

Expand Down
6 changes: 3 additions & 3 deletions analyzer/src/main/kotlin/managers/GoDep.kt
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class GoDep(analyzerConfig: AnalyzerConfiguration, repoConfig: RepositoryConfigu
val projects = parseProjects(workingDir, gopath)
val packages = mutableListOf<Package>()
val packageRefs = mutableListOf<PackageReference>()
val provider = toString()
val packageType = toString()

for (project in projects) {
// parseProjects() made sure that all entries contain these keys
Expand All @@ -104,7 +104,7 @@ class GoDep(analyzerConfig: AnalyzerConfiguration, repoConfig: RepositoryConfigu
}

val pkg = Package(
id = Identifier(provider, "", name, version),
id = Identifier(packageType, "", name, version),
declaredLicenses = sortedSetOf(),
description = "",
homepageUrl = "",
Expand All @@ -126,7 +126,7 @@ class GoDep(analyzerConfig: AnalyzerConfiguration, repoConfig: RepositoryConfigu

return ProjectAnalyzerResult(
project = Project(
id = Identifier(provider, "", projectDir.name, projectVcs.revision),
id = Identifier(packageType, "", projectDir.name, projectVcs.revision),
definitionFilePath = VersionControlSystem.getPathInfo(definitionFile).path,
declaredLicenses = sortedSetOf(),
vcs = VcsInfo.EMPTY,
Expand Down
4 changes: 2 additions & 2 deletions analyzer/src/main/kotlin/managers/Gradle.kt
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ class Gradle(analyzerConfig: AnalyzerConfiguration, repoConfig: RepositoryConfig

val project = Project(
id = Identifier(
provider = toString(),
type = toString(),
namespace = dependencyTreeModel.group,
name = dependencyTreeModel.name,
version = dependencyTreeModel.version
Expand Down Expand Up @@ -174,7 +174,7 @@ class Gradle(analyzerConfig: AnalyzerConfiguration, repoConfig: RepositoryConfig
val rawPackage by lazy {
Package(
id = Identifier(
provider = "Maven",
type = "Maven",
namespace = dependency.groupId,
name = dependency.artifactId,
version = dependency.version
Expand Down
2 changes: 1 addition & 1 deletion analyzer/src/main/kotlin/managers/Maven.kt
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ class Maven(analyzerConfig: AnalyzerConfiguration, repoConfig: RepositoryConfigu

val project = Project(
id = Identifier(
provider = if (sbtMode) "SBT" else "Maven",
type = if (sbtMode) "SBT" else "Maven",
namespace = mavenProject.groupId,
name = mavenProject.artifactId,
version = mavenProject.version
Expand Down
4 changes: 2 additions & 2 deletions analyzer/src/main/kotlin/managers/NPM.kt
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ open class NPM(analyzerConfig: AnalyzerConfiguration, repoConfig: RepositoryConf

val module = Package(
id = Identifier(
provider = "NPM",
type = "NPM",
namespace = namespace,
name = name,
version = version
Expand Down Expand Up @@ -476,7 +476,7 @@ open class NPM(analyzerConfig: AnalyzerConfiguration, repoConfig: RepositoryConf

val project = Project(
id = Identifier(
provider = toString(),
type = toString(),
namespace = namespace,
name = name,
version = version
Expand Down
4 changes: 2 additions & 2 deletions analyzer/src/main/kotlin/managers/PIP.kt
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ class PIP(analyzerConfig: AnalyzerConfiguration, repoConfig: RepositoryConfigura

val project = Project(
id = Identifier(
provider = toString(),
type = toString(),
namespace = "",
name = projectName,
version = projectVersion
Expand Down Expand Up @@ -439,7 +439,7 @@ class PIP(analyzerConfig: AnalyzerConfiguration, repoConfig: RepositoryConfigura

val pkg = Package(
id = Identifier(
provider = "PyPI",
type = "PyPI",
namespace = "",
name = name,
version = version
Expand Down
4 changes: 2 additions & 2 deletions analyzer/src/main/kotlin/managers/PhpComposer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ class PhpComposer(analyzerConfig: AnalyzerConfiguration, repoConfig: RepositoryC

return Project(
id = Identifier(
provider = toString(),
type = toString(),
namespace = rawName.substringBefore("/"),
name = rawName.substringAfter("/"),
version = json["version"].textValueOrEmpty()
Expand Down Expand Up @@ -225,7 +225,7 @@ class PhpComposer(analyzerConfig: AnalyzerConfiguration, repoConfig: RepositoryC

packages[rawName] = Package(
id = Identifier(
provider = toString(),
type = toString(),
namespace = rawName.substringBefore("/"),
name = rawName.substringAfter("/"),
version = version
Expand Down
8 changes: 4 additions & 4 deletions analyzer/src/main/kotlin/managers/Stack.kt
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class Stack(analyzerConfig: AnalyzerConfiguration, repoConfig: RepositoryConfigu
}

val projectPackage = parseCabalFile(cabalFile.readText())
val projectId = projectPackage.id.copy(provider = toString())
val projectId = projectPackage.id.copy(type = toString())

// Parse package information from the stack.yaml file.
fun runStack(vararg command: String): ProcessCapture {
Expand Down Expand Up @@ -168,7 +168,7 @@ class Stack(analyzerConfig: AnalyzerConfiguration, repoConfig: RepositoryConfigu
id = Identifier(
// The runtime system ships with the Glasgow Haskell Compiler (GHC) and is not hosted
// on Hackage.
provider = if (childName == "rts") "GHC" else "Hackage",
type = if (childName == "rts") "GHC" else "Hackage",
namespace = "",
name = childName,
version = versionMap[childName] ?: ""
Expand All @@ -182,7 +182,7 @@ class Stack(analyzerConfig: AnalyzerConfiguration, repoConfig: RepositoryConfigu
)

val pkg = allPackages.getOrPut(pkgTemplate) {
if (pkgTemplate.id.provider == "Hackage") {
if (pkgTemplate.id.type == "Hackage") {
// Enrich the package with additional meta-data from Hackage.
downloadCabalFile(pkgTemplate)?.let {
parseCabalFile(it)
Expand Down Expand Up @@ -315,7 +315,7 @@ class Stack(analyzerConfig: AnalyzerConfiguration, repoConfig: RepositoryConfigu
val map = parseKeyValue(cabal.lines().listIterator())

val id = Identifier(
provider = "Hackage",
type = "Hackage",
namespace = map["category"] ?: "",
name = map["name"] ?: "",
version = map["version"] ?: ""
Expand Down
2 changes: 1 addition & 1 deletion analyzer/src/main/kotlin/managers/Unmanaged.kt
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class Unmanaged(analyzerConfig: AnalyzerConfiguration, repoConfig: RepositoryCon
override fun resolveDependencies(definitionFile: File): ProjectAnalyzerResult? {
val project = Project(
id = Identifier(
provider = toString(),
type = toString(),
namespace = "",
name = definitionFile.name,
version = ""
Expand Down
2 changes: 1 addition & 1 deletion cli/src/main/kotlin/commands/DownloaderCommand.kt
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ object DownloaderCommand : CommandWithHelp() {

if (archive) {
val zipFile = File(outputDir,
"${pkg.id.provider.encodeOrUnknown()}-${pkg.id.namespace.encodeOrUnknown()}-" +
"${pkg.id.type.encodeOrUnknown()}-${pkg.id.namespace.encodeOrUnknown()}-" +
"${pkg.id.name.encodeOrUnknown()}-${pkg.id.version.encodeOrUnknown()}.zip")

log.info {
Expand Down
2 changes: 1 addition & 1 deletion downloader/src/funTest/kotlin/BabelTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class BabelTest : StringSpec() {

val pkg = Package(
id = Identifier(
provider = "NPM",
type = "NPM",
namespace = "",
name = "babel-cli",
version = "6.26.0"
Expand Down
2 changes: 1 addition & 1 deletion downloader/src/funTest/kotlin/BeanUtilsTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class BeanUtilsTest : StringSpec() {

val pkg = Package(
id = Identifier(
provider = "Maven",
type = "Maven",
namespace = "commons-beanutils",
name = "commons-beanutils-bean-collections",
version = "1.8.3"
Expand Down
4 changes: 2 additions & 2 deletions downloader/src/funTest/kotlin/DirectoryTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class DirectoryTest : StringSpec() {
"Creates directories for Gradle submodules" {
val pkg = Package(
id = Identifier(
provider = "provider",
type = "type",
namespace = "namespace",
name = "name",
version = "version"
Expand All @@ -68,7 +68,7 @@ class DirectoryTest : StringSpec() {
}

outputDir.list().size shouldBe 1
outputDir.list().first() shouldBe pkg.id.provider.fileSystemEncode()
outputDir.list().first() shouldBe pkg.id.type.fileSystemEncode()

val namespaceDir = File(outputDir, outputDir.list().first())
namespaceDir.list().size shouldBe 1
Expand Down
8 changes: 4 additions & 4 deletions downloader/src/funTest/kotlin/DownloaderTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class DownloaderTest : StringSpec() {
"Downloads and unpacks JAR source package".config(tags = setOf(ExpensiveTag)) {
val pkg = Package(
id = Identifier(
provider = "Maven",
type = "Maven",
namespace = "junit",
name = "junit",
version = "4.12"
Expand Down Expand Up @@ -85,7 +85,7 @@ class DownloaderTest : StringSpec() {
"Download of JAR source package fails when hash is incorrect".config(tags = setOf(ExpensiveTag)) {
val pkg = Package(
id = Identifier(
provider = "Maven",
type = "Maven",
namespace = "junit",
name = "junit",
version = "4.12"
Expand Down Expand Up @@ -113,7 +113,7 @@ class DownloaderTest : StringSpec() {
"Falls back to downloading source package when download from VCS fails".config(tags = setOf(ExpensiveTag)) {
val pkg = Package(
id = Identifier(
provider = "Maven",
type = "Maven",
namespace = "junit",
name = "junit",
version = "4.12"
Expand Down Expand Up @@ -152,7 +152,7 @@ class DownloaderTest : StringSpec() {
val url = "https://master.dl.sourceforge.net/project/tyrex/tyrex/Tyrex%201.0.1/tyrex-1.0.1-src.tgz"
val pkg = Package(
id = Identifier(
provider = "Maven",
type = "Maven",
namespace = "tyrex",
name = "tyrex",
version = "1.0.1"
Expand Down
2 changes: 1 addition & 1 deletion downloader/src/main/kotlin/Downloader.kt
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ class Downloader {

try {
if (target.vcsProcessed.url.isBlank()) {
val details = when (target.id.provider) {
val details = when (target.id.type) {
"Bundler" -> " Please define the \"source_code_uri\" in the \"metadata\" of the Gemspec, see: " +
"https://guides.rubygems.org/specification-reference/#metadata"
"Gradle" -> " Please make sure the release POM file includes the SCM connection, see: " +
Expand Down
Loading

0 comments on commit 1a44e0e

Please sign in to comment.