-
Notifications
You must be signed in to change notification settings - Fork 1
feat(package_config): Add classes for config package_configurations #13
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,77 @@ | ||||||
| # SPDX-FileCopyrightText: 2025 Helio Chissini de Castro <heliocastro@gmail.com> | ||||||
| # SPDX-License-Identifier: MIT | ||||||
|
|
||||||
|
|
||||||
| from pydantic import BaseModel, ConfigDict, Field | ||||||
|
|
||||||
| from ort.models.config.package_manager_configuration import PackageManagerConfiguration | ||||||
|
|
||||||
| _package_managers: list[str] = [ | ||||||
| "Bazel", | ||||||
| "Bower", | ||||||
| "Bundler", | ||||||
| "Cargo", | ||||||
| "Carthage", | ||||||
| "CocoaPods", | ||||||
| "Composer", | ||||||
| "Conan", | ||||||
| "GoMod", | ||||||
| "GradleInspector", | ||||||
| "Maven", | ||||||
| "NPM", | ||||||
| "NuGet", | ||||||
| "PIP", | ||||||
| "Pipenv", | ||||||
| "PNPM", | ||||||
| "Poetry", | ||||||
| "Pub", | ||||||
| "SBT", | ||||||
| "SpdxDocumentFile", | ||||||
| "Stack", | ||||||
| "SwiftPM", | ||||||
| "Tycho", | ||||||
| "Unmanaged", | ||||||
| "Yarn", | ||||||
| "Yarn2", | ||||||
| ] | ||||||
|
|
||||||
|
|
||||||
| class AnalyzerConfiguration(BaseModel): | ||||||
| """ | ||||||
| Enable the analysis of projects that use version ranges to declare their dependencies. If set to true, | ||||||
| dependencies of exactly the same project might change with another scan done at a later time if any of the | ||||||
| (transitive) dependencies are declared using version ranges and a new version of such a dependency was | ||||||
| published in the meantime. If set to false, analysis of projects that use version ranges will fail. Defaults to | ||||||
| false. | ||||||
| """ | ||||||
|
|
||||||
| model_config = ConfigDict( | ||||||
| extra="forbid", | ||||||
| ) | ||||||
| allow_dynamic_versions: bool = Field( | ||||||
| default=False, | ||||||
| description="Enable the analysis of projects that use version ranges to declare their dependencies." | ||||||
| "If set to true, dependencies of exactly the same project might change with another scan done at a later time" | ||||||
|
||||||
| "if any of the (transitive) dependencies are declared using version ranges and a new version of such a" | ||||||
| "dependency was published in the meantime. If set to false, analysis of projects that use version ranges will" | ||||||
| "fail. Defaults to false.", | ||||||
| ) | ||||||
| enabled_package_managers: list[str] = Field( | ||||||
| default=_package_managers, | ||||||
| description="A list of the case-insensitive names of package managers that are enabled." | ||||||
| "Disabling a package manager in [disabledPackageManagers] overrides enabling it here.", | ||||||
|
Comment on lines
+61
to
+62
|
||||||
| ) | ||||||
| disabled_package_managers: list[str] | None = Field( | ||||||
| default=None, | ||||||
| description="A list of the case-insensitive names of package managers that are disabled." | ||||||
| "Disabling a package manager in this list overrides [enabledPackageManagers].", | ||||||
| ) | ||||||
| package_managers: dict[str, PackageManagerConfiguration] | None = Field( | ||||||
| default=None, | ||||||
| description="Get a [PackageManagerConfiguration] from [packageManagers]. The difference to accessing the map" | ||||||
|
||||||
| description="Get a [PackageManagerConfiguration] from [packageManagers]. The difference to accessing the map" | |
| description="Get a [PackageManagerConfiguration] from [packageManagers]. The difference to accessing the map " |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,68 @@ | ||||||
| # SPDX-FileCopyrightText: 2025 Helio Chissini de Castro <heliocastro@gmail.com> | ||||||
| # SPDX-License-Identifier: MIT | ||||||
|
|
||||||
|
|
||||||
| from pydantic import BaseModel, ConfigDict, Field | ||||||
|
|
||||||
| from ort.models.config.license_finding_curation import LicenseFindingCuration | ||||||
| from ort.models.config.path_exclude import PathExclude | ||||||
| from ort.models.config.vcsmatcher import VcsMatcher | ||||||
| from ort.models.identifier import Identifier | ||||||
| from ort.models.source_code_origin import SourceCodeOrigin | ||||||
|
|
||||||
|
|
||||||
| class PackageConfiguration(BaseModel): | ||||||
| """ | ||||||
| A class used in the [OrtConfiguration] to configure [PathExclude]s and [LicenseFindingCuration]s for a specific | ||||||
| [Package]'s [Identifier] (and [Provenance]). | ||||||
| Note that [PathExclude]s and [LicenseFindingCuration]s for [Project]s are configured by a | ||||||
| [RepositoryConfiguration]'s excludes and curations properties instead. | ||||||
| Attributes: | ||||||
| id (Identifier): The [Identifier] which must match with the identifier of the package in | ||||||
| order for this package curation to apply. The [version][Identifier.version] can be | ||||||
| either a plain version string matched for equality, or an Ivy-style version matchers. | ||||||
| * The other components of the [identifier][id] are matched by equality. | ||||||
| source_artifact_url (str | None): The source artifact this configuration applies to. | ||||||
| vcs (VcsMatcher | None): The vcs and revision this configuration applies to. | ||||||
| source_code_origin (SourceCodeOrigin | None): The source code origin this configuration | ||||||
| applies to. | ||||||
| path_excludes (list[PathExclude]): Path excludes. | ||||||
| license_finding_curations (list[LicenseFindingCuration]): License finding curations. | ||||||
| """ | ||||||
|
|
||||||
| model_config = ConfigDict( | ||||||
| extra="forbid", | ||||||
| ) | ||||||
|
|
||||||
| id: Identifier = Field( | ||||||
| description="The [Identifier] which must match with the identifier of the package in order for this package" | ||||||
|
||||||
| description="The [Identifier] which must match with the identifier of the package in order for this package" | |
| description="The [Identifier] which must match with the identifier of the package in order for this package " |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| # SPDX-FileCopyrightText: 2025 Helio Chissini de Castro <heliocastro@gmail.com> | ||
| # SPDX-License-Identifier: MIT | ||
|
|
||
|
|
||
| from pydantic import BaseModel, ConfigDict, Field | ||
|
|
||
|
|
||
| class PackageManagerConfiguration(BaseModel): | ||
| model_config = ConfigDict( | ||
| extra="forbid", | ||
| ) | ||
|
|
||
| must_run_after: list[str] | None = Field( | ||
| default=None, | ||
| description="The configuration model for a package manager. This class is (de-)serialized in the following" | ||
| "places:" | ||
| "- Deserialized from config.yml as part of [OrtConfiguration] (via Hoplite)." | ||
| "- Deserialized from .ort.yml as part of [RepositoryAnalyzerConfiguration] (via Jackson)" | ||
| "- (De-)Serialized as part of [org.ossreviewtoolkit.model.OrtResult] (via Jackson).", | ||
| ) | ||
|
Comment on lines
+13
to
+20
|
||
|
|
||
| options: dict[str, str] | None = Field( | ||
| default=None, | ||
| description="Custom configuration options for the package manager. See the documentation of the respective" | ||
| "class for available options.", | ||
| ) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing space after period in description text. Should be "The path inside the VCS to take into account. If the VCS supports" instead of "The path inside the VCS to take into account.If the VCS supports".