← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~andersson123/lpci:component-restriction into lpci:main

 

Tim Andersson has proposed merging ~andersson123/lpci:component-restriction into lpci:main.

Commit message:
remove 'component' restriction in 'package-repositories' config

Fixes bug LP: #2039303

With this change, any value can be placed in the 'component' field of
the 'package-repositories' section of the lpci config.

This enables users with custom PPA's, with component names that are not
in ["main", "restricted", "universe", "multiverse"].

This commit also amends all the unit tests in line with the described
change.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #2039303 in lpci: "lift restriction on 'component' in 'package-repositories' properties of config"
  https://bugs.launchpad.net/lpci/+bug/2039303

For more details, see:
https://code.launchpad.net/~andersson123/lpci/+git/lpci/+merge/469942

Fixes a stale bug, should help with teams using LPCI with private repositories with components outside of what is in the ubuntu archive
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~andersson123/lpci:component-restriction into lpci:main.
diff --git a/lpci/config.py b/lpci/config.py
index ccedfdc..96eb2db 100644
--- a/lpci/config.py
+++ b/lpci/config.py
@@ -102,15 +102,6 @@ class PackageFormat(str, Enum):
     deb_src = "deb-src"
 
 
-class PackageComponent(str, Enum):
-    """Specifies the component of the package repository."""
-
-    main = "main"
-    restricted = "restricted"
-    universe = "universe"
-    multiverse = "multiverse"
-
-
 class PackageSuite(str, Enum):
     """Specifies the suite of the package repository.
 
@@ -156,7 +147,7 @@ class PackageRepository(ModelConfigDefaults):
     type: PackageType  # e.g. `apt``
     ppa: Optional[PPAShortFormURL] = None  # e.g. `launchpad/ubuntu/ppa`
     formats: Optional[List[PackageFormat]] = None  # e.g. `[deb, deb-src]`
-    components: Optional[List[PackageComponent]] = None  # e.g. `[main]`
+    components: Optional[List[str]] = None  # e.g. `[main]`
     suites: Optional[List[PackageSuite]] = None  # e.g. `[bionic, focal]`
     url: Optional[AnyHttpUrl] = None
     trusted: Optional[bool] = False
@@ -192,8 +183,8 @@ class PackageRepository(ModelConfigDefaults):
 
     @validator("components", pre=True, always=True)
     def infer_components_if_ppa_is_set(
-        cls, v: List[PackageComponent], values: Dict[str, Any]
-    ) -> List[PackageComponent]:
+        cls, v: List[str], values: Dict[str, Any]
+    ) -> List[str]:
         if v is None and values["ppa"]:
             return ["main"]
         return v
diff --git a/lpci/tests/test_config.py b/lpci/tests/test_config.py
index 4c9d10a..0e686ef 100644
--- a/lpci/tests/test_config.py
+++ b/lpci/tests/test_config.py
@@ -20,7 +20,6 @@ from lpci.config import (
     LAUNCHPAD_PPA_BASE_URL,
     Config,
     OutputDistributeEnum,
-    PackageComponent,
     PackageFormat,
     PackageRepository,
     PackageSuite,
@@ -492,7 +491,7 @@ class TestConfig(TestCase):
                 PackageRepository(
                     type=PackageType.apt,
                     formats=[PackageFormat.deb],
-                    components=[PackageComponent.main],
+                    components=["main"],
                     suites=[PackageSuite.focal],
                     url=AnyHttpUrl(
                         "https://canonical.example.org/artifactory/jammy-golang-backport";,  # noqa: E501
@@ -506,7 +505,7 @@ class TestConfig(TestCase):
                 PackageRepository(
                     type=PackageType.apt,
                     formats=[PackageFormat.deb],
-                    components=[PackageComponent.main],
+                    components=["main"],
                     suites=[PackageSuite.focal],
                     url=AnyHttpUrl(
                         "https://canonical.example.org/artifactory/jammy-golang-backport";,  # noqa: E501
@@ -573,7 +572,7 @@ class TestConfig(TestCase):
                 PackageRepository(
                     type=PackageType.apt,
                     formats=[PackageFormat.deb],
-                    components=[PackageComponent.main],
+                    components=["main"],
                     suites=[PackageSuite.bionic],
                     url=AnyHttpUrl(
                         "https://canonical.example.org/artifactory/bionic-golang-backport";,  # noqa: E501
@@ -587,7 +586,7 @@ class TestConfig(TestCase):
                 PackageRepository(
                     type=PackageType.apt,
                     formats=[PackageFormat.deb],
-                    components=[PackageComponent.main],
+                    components=["main"],
                     suites=[PackageSuite.focal],
                     url=AnyHttpUrl(
                         "https://canonical.example.org/artifactory/focal-golang-backport";,  # noqa: E501
@@ -601,7 +600,7 @@ class TestConfig(TestCase):
                 PackageRepository(
                     type=PackageType.apt,
                     formats=[PackageFormat.deb],
-                    components=[PackageComponent.main],
+                    components=["main"],
                     suites=[PackageSuite.jammy],
                     url=AnyHttpUrl(
                         "https://canonical.example.org/artifactory/jammy-golang-backport";,  # noqa: E501
@@ -615,7 +614,7 @@ class TestConfig(TestCase):
                 PackageRepository(
                     type=PackageType.apt,
                     formats=[PackageFormat.deb],
-                    components=[PackageComponent.main],
+                    components=["main"],
                     suites=[PackageSuite.noble],
                     url=AnyHttpUrl(
                         "https://canonical.example.org/artifactory/noble-golang-backport";,  # noqa: E501