diff --git a/pontos/github/api/packages.py b/pontos/github/api/packages.py index ff47f6d98..aa49b9810 100644 --- a/pontos/github/api/packages.py +++ b/pontos/github/api/packages.py @@ -199,7 +199,7 @@ async def package_versions( if versions: for version in versions: yield PackageVersion.from_dict(version) - + async def package_version_tags( self, organization: str, diff --git a/pontos/github/scripts/delete-package-with-tag.py b/pontos/github/scripts/delete-package-with-tag.py index 0b444be24..2f13445a4 100644 --- a/pontos/github/scripts/delete-package-with-tag.py +++ b/pontos/github/scripts/delete-package-with-tag.py @@ -7,11 +7,13 @@ from pontos.github.api import GitHubAsyncRESTApi from pontos.github.models.packages import PackageType + def package_type(value: str) -> PackageType: if isinstance(value, PackageType): return value return PackageType(value.lower()) + def add_script_arguments(parser: ArgumentParser) -> None: parser.add_argument("organization", help="organization name") parser.add_argument("package", help="package name") @@ -23,7 +25,8 @@ def add_script_arguments(parser: ArgumentParser) -> None: ) parser.add_argument('tag', help='The tag to be deleted.') -async def github_script(api: GitHubAsyncRESTApi, args: Namespace) -> None: + +async def github_script(api: GitHubAsyncRESTApi, args: Namespace) -> int: if not await api.packages.exists( organization=args.organization, package_name=args.package, @@ -41,4 +44,7 @@ async def github_script(api: GitHubAsyncRESTApi, args: Namespace) -> None: package_type=args.package_type, tag=args.tag, ) - print(f"Deleted tag {args.tag} from package {args.package} in organization {args.organization}") + print( + f"Deleted tag {args.tag} from package {args.package} in organization {args.organization}" + ) + return 0 diff --git a/tests/github/api/test_packages.py b/tests/github/api/test_packages.py index d99a1f65a..bf24fe465 100644 --- a/tests/github/api/test_packages.py +++ b/tests/github/api/test_packages.py @@ -164,7 +164,9 @@ async def test_package_version(self): async def test_package_version_tags(self): response = create_response() - response.json.return_value = {"metadata": {"container": {"tags": ["latest", "stable"]}}} + response.json.return_value = { + "metadata": {"container": {"tags": ["latest", "stable"]}} + } self.client.get.return_value = response @@ -248,7 +250,9 @@ async def test_delete_package_with_tag(self): ) tags_response = create_response() - tags_response.json.return_value = {"metadata": {"container": {"tags": ["latest", "stable"]}}} + tags_response.json.return_value = { + "metadata": {"container": {"tags": ["latest", "stable"]}} + } self.client.get.return_value = tags_response await self.api.delete_package_with_tag(