mirror of
https://github.com/arcan1s/ahriman.git
synced 2026-07-13 14:21:08 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| cd6fbaae31 |
@@ -26,10 +26,6 @@ jobs:
|
||||
|
||||
- uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Set image date
|
||||
id: args
|
||||
run: echo "::set-output name=date::$(date -d yesterday +'%Y-%m-%d')"
|
||||
|
||||
- name: Login to docker hub
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
@@ -57,8 +53,6 @@ jobs:
|
||||
- name: Build an image and push
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
build-args: |
|
||||
BUILD_DATE=${{ steps.args.outputs.date }}
|
||||
file: docker/Dockerfile
|
||||
push: true
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
|
||||
@@ -12,11 +12,11 @@ pacman -Syyu --noconfirm
|
||||
# main dependencies
|
||||
pacman -S --noconfirm devtools git npm pyalpm python-bcrypt python-filelock python-inflection python-pyelftools python-requests python-systemd sudo
|
||||
# make dependencies
|
||||
pacman -S --noconfirm --asdeps base-devel python-build python-hatchling python-installer python-tox python-wheel
|
||||
pacman -S --noconfirm --asdeps base-devel python-build python-flit python-installer python-tox python-wheel
|
||||
# optional dependencies
|
||||
if [[ -z $MINIMAL_INSTALL ]]; then
|
||||
# web server
|
||||
pacman -S --noconfirm python-aioauth-client python-aiohttp python-aiohttp-apispec-git python-aiohttp-cors python-aiohttp-jinja2 python-aiohttp-security python-aiohttp-session python-aiohttp-sse-git python-cryptography python-jinja
|
||||
pacman -S --noconfirm python-aioauth-client python-aiohttp python-aiohttp-apispec-git python-aiohttp-cors python-aiohttp-jinja2 python-aiohttp-security python-aiohttp-session python-cryptography python-jinja
|
||||
# additional features
|
||||
pacman -S --noconfirm gnupg ipython python-boto3 python-cerberus python-matplotlib rsync
|
||||
fi
|
||||
|
||||
+2
-5
@@ -103,8 +103,5 @@ docs/html/
|
||||
# Frontend
|
||||
node_modules/
|
||||
package-lock.json
|
||||
ahriman-web/package/share/ahriman/templates/static/index.js
|
||||
ahriman-web/package/share/ahriman/templates/static/index.css
|
||||
|
||||
# local configs
|
||||
/*.ini
|
||||
package/share/ahriman/templates/static/index.js
|
||||
package/share/ahriman/templates/static/index.css
|
||||
|
||||
@@ -2,6 +2,4 @@
|
||||
addopts = --cov=ahriman --cov-report=term-missing:skip-covered --no-cov-on-fail --cov-fail-under=100 --spec
|
||||
asyncio_default_fixture_loop_scope = function
|
||||
asyncio_mode = auto
|
||||
pythonpath = tests
|
||||
resource-path.directory-name-test-resources = ../../tests/testresources
|
||||
spec_test_format = {result} {docstring_summary}
|
||||
|
||||
+2
-2
@@ -1,9 +1,9 @@
|
||||
version: 2
|
||||
|
||||
build:
|
||||
os: ubuntu-lts-latest
|
||||
os: ubuntu-20.04
|
||||
tools:
|
||||
python: "3.13"
|
||||
python: "3.12"
|
||||
apt_packages:
|
||||
- graphviz
|
||||
|
||||
|
||||
+3
-6
@@ -125,7 +125,7 @@ Again, the most checks can be performed by `tox` command, though some additional
|
||||
def __hash__(self) -> int: ... # basically any magic (or look-alike) method
|
||||
```
|
||||
|
||||
Methods inside one group should be ordered alphabetically, the only exceptions are `__init__` (`__post_init__` for dataclasses), `__new__` and `__del__` methods which should be defined first. For test methods it is recommended to follow the order in which functions are defined. Same idea applies to frontend classes.
|
||||
Methods inside one group should be ordered alphabetically, the only exceptions are `__init__` (`__post_init__` for dataclasses), `__new__` and `__del__` methods which should be defined first. For test methods it is recommended to follow the order in which functions are defined.
|
||||
|
||||
Though, we would like to highlight abstract methods (i.e. ones which raise `NotImplementedError`), we still keep in global order at the moment.
|
||||
|
||||
@@ -172,9 +172,8 @@ Again, the most checks can be performed by `tox` command, though some additional
|
||||
)
|
||||
```
|
||||
|
||||
* Imports goes in alphabetical order, no relative imports allowed. Same rule applies to frontend classes.
|
||||
* One file should define only one class, exception is class satellites in case if file length remains less than 400 lines. Same rule applies to frontend classes.
|
||||
* It is possible to create file which contains some functions (e.g. `ahriman.core.utils`), but in this case you would need to define `__all__` attribute.
|
||||
* One file should define only one class, exception is class satellites in case if file length remains less than 400 lines.
|
||||
* It is possible to create file which contains some functions (e.g. `ahriman.core.util`), but in this case you would need to define `__all__` attribute.
|
||||
* The file size mentioned above must be applicable in general. In case of big classes consider splitting them into traits. Note, however, that `pylint` includes comments and docstrings into counter, thus you need to check file size by other tools.
|
||||
* No global variable is allowed outside of `ahriman` module. `ahriman.core.context` is also special case.
|
||||
* Single quotes are not allowed. The reason behind this restriction is the fact that docstrings must be written by using double quotes only, and we would like to make style consistent.
|
||||
@@ -227,8 +226,6 @@ Again, the most checks can be performed by `tox` command, though some additional
|
||||
|
||||
The projects also uses typing checks (provided by `mypy`) and some linter checks provided by `pylint` and `bandit`. Those checks must be passed successfully for any open pull requests.
|
||||
|
||||
Frontend checks normally are performed by `eslint` (e.g. `npx run eslint`).
|
||||
|
||||
## Developers how to
|
||||
|
||||
### Run automated checks
|
||||
|
||||
@@ -1,68 +0,0 @@
|
||||
[build-system]
|
||||
requires = ["hatchling"]
|
||||
build-backend = "hatchling.build"
|
||||
|
||||
[project]
|
||||
name = "ahriman-core"
|
||||
description = "ArcH linux ReposItory MANager, core package"
|
||||
readme = "../README.md"
|
||||
requires-python = ">=3.13"
|
||||
license = {file = "../COPYING"}
|
||||
authors = [
|
||||
{name = "ahriman team"},
|
||||
]
|
||||
dependencies = [
|
||||
"bcrypt",
|
||||
"filelock",
|
||||
"inflection",
|
||||
"pyelftools",
|
||||
"requests",
|
||||
]
|
||||
dynamic = ["version"]
|
||||
|
||||
[project.optional-dependencies]
|
||||
journald = [
|
||||
"systemd-python",
|
||||
]
|
||||
# FIXME technically this dependency is required, but in some cases we do not have access to
|
||||
# the libalpm which is required in order to install the package. Thus in case if we do not
|
||||
# really need to run the application we can move it to "optional" dependencies
|
||||
pacman = [
|
||||
"pyalpm",
|
||||
]
|
||||
reports = [
|
||||
"Jinja2",
|
||||
]
|
||||
s3 = [
|
||||
"boto3",
|
||||
]
|
||||
shell = [
|
||||
"IPython",
|
||||
]
|
||||
stats = [
|
||||
"matplotlib",
|
||||
]
|
||||
unixsocket = [
|
||||
"requests-unixsocket2",
|
||||
]
|
||||
validator = [
|
||||
"cerberus",
|
||||
]
|
||||
|
||||
[project.scripts]
|
||||
ahriman = "ahriman.application.ahriman:run"
|
||||
|
||||
[project.urls]
|
||||
Documentation = "https://ahriman.readthedocs.io/"
|
||||
Repository = "https://github.com/arcan1s/ahriman"
|
||||
Changelog = "https://github.com/arcan1s/ahriman/releases"
|
||||
|
||||
[tool.hatch.version]
|
||||
path = "src/ahriman/__init__.py"
|
||||
|
||||
[tool.hatch.build.targets.wheel]
|
||||
packages = ["src/ahriman"]
|
||||
|
||||
[tool.hatch.build.targets.wheel.shared-data]
|
||||
"package/lib" = "lib"
|
||||
"package/share" = "share"
|
||||
@@ -1,20 +0,0 @@
|
||||
#
|
||||
# Copyright (c) 2021-2026 ahriman team.
|
||||
#
|
||||
# This file is part of ahriman
|
||||
# (see https://github.com/arcan1s/ahriman).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
__version__ = "2.20.0"
|
||||
@@ -1,81 +0,0 @@
|
||||
#
|
||||
# Copyright (c) 2021-2026 ahriman team.
|
||||
#
|
||||
# This file is part of ahriman
|
||||
# (see https://github.com/arcan1s/ahriman).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
import argparse
|
||||
|
||||
from ahriman.application.application import Application
|
||||
from ahriman.application.handlers.handler import Handler, SubParserAction
|
||||
from ahriman.core.configuration import Configuration
|
||||
from ahriman.core.formatters import PackagePrinter
|
||||
from ahriman.models.action import Action
|
||||
from ahriman.models.build_status import BuildStatus, BuildStatusEnum
|
||||
from ahriman.models.repository_id import RepositoryId
|
||||
|
||||
|
||||
class Archives(Handler):
|
||||
"""
|
||||
package archives handler
|
||||
"""
|
||||
|
||||
ALLOW_MULTI_ARCHITECTURE_RUN = False # conflicting io
|
||||
|
||||
@classmethod
|
||||
def run(cls, args: argparse.Namespace, repository_id: RepositoryId, configuration: Configuration, *,
|
||||
report: bool) -> None:
|
||||
"""
|
||||
callback for command line
|
||||
|
||||
Args:
|
||||
args(argparse.Namespace): command line args
|
||||
repository_id(RepositoryId): repository unique identifier
|
||||
configuration(Configuration): configuration instance
|
||||
report(bool): force enable or disable reporting
|
||||
"""
|
||||
application = Application(repository_id, configuration, report=True)
|
||||
|
||||
match args.action:
|
||||
case Action.List:
|
||||
archives = application.repository.package_archives(args.package)
|
||||
for package in archives:
|
||||
PackagePrinter(package, BuildStatus(BuildStatusEnum.Success))(verbose=args.info)
|
||||
|
||||
Archives.check_status(args.exit_code, bool(archives))
|
||||
|
||||
@staticmethod
|
||||
def _set_package_archives_parser(root: SubParserAction) -> argparse.ArgumentParser:
|
||||
"""
|
||||
add parser for package archives subcommand
|
||||
|
||||
Args:
|
||||
root(SubParserAction): subparsers for the commands
|
||||
|
||||
Returns:
|
||||
argparse.ArgumentParser: created argument parser
|
||||
"""
|
||||
parser = root.add_parser("package-archives", help="list package archive versions",
|
||||
description="list available archive versions for the package")
|
||||
parser.add_argument("package", help="package base")
|
||||
parser.add_argument("-e", "--exit-code", help="return non-zero exit status if result is empty",
|
||||
action="store_true")
|
||||
parser.add_argument("--info", help="show additional package information",
|
||||
action=argparse.BooleanOptionalAction, default=False)
|
||||
parser.set_defaults(action=Action.List, lock=None, quiet=True, report=False, unsafe=True)
|
||||
return parser
|
||||
|
||||
arguments = [_set_package_archives_parser]
|
||||
@@ -1,93 +0,0 @@
|
||||
#
|
||||
# Copyright (c) 2021-2026 ahriman team.
|
||||
#
|
||||
# This file is part of ahriman
|
||||
# (see https://github.com/arcan1s/ahriman).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
import argparse
|
||||
|
||||
from ahriman.application.application import Application
|
||||
from ahriman.application.handlers.handler import Handler, SubParserAction
|
||||
from ahriman.core.configuration import Configuration
|
||||
from ahriman.models.action import Action
|
||||
from ahriman.models.repository_id import RepositoryId
|
||||
|
||||
|
||||
class Hold(Handler):
|
||||
"""
|
||||
package hold handler
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def run(cls, args: argparse.Namespace, repository_id: RepositoryId, configuration: Configuration, *,
|
||||
report: bool) -> None:
|
||||
"""
|
||||
callback for command line
|
||||
|
||||
Args:
|
||||
args(argparse.Namespace): command line args
|
||||
repository_id(RepositoryId): repository unique identifier
|
||||
configuration(Configuration): configuration instance
|
||||
report(bool): force enable or disable reporting
|
||||
"""
|
||||
client = Application(repository_id, configuration, report=True).reporter
|
||||
|
||||
match args.action:
|
||||
case Action.Remove:
|
||||
for package in args.package:
|
||||
client.package_hold_update(package, enabled=False)
|
||||
case Action.Update:
|
||||
for package in args.package:
|
||||
client.package_hold_update(package, enabled=True)
|
||||
|
||||
@staticmethod
|
||||
def _set_package_hold_parser(root: SubParserAction) -> argparse.ArgumentParser:
|
||||
"""
|
||||
add parser for hold package subcommand
|
||||
|
||||
Args:
|
||||
root(SubParserAction): subparsers for the commands
|
||||
|
||||
Returns:
|
||||
argparse.ArgumentParser: created argument parser
|
||||
"""
|
||||
parser = root.add_parser("package-hold", help="hold package",
|
||||
description="hold package from automatic updates")
|
||||
parser.add_argument("package", help="package base", nargs="+")
|
||||
parser.set_defaults(action=Action.Update, lock=None, quiet=True, report=False, unsafe=True)
|
||||
return parser
|
||||
|
||||
@staticmethod
|
||||
def _set_package_unhold_parser(root: SubParserAction) -> argparse.ArgumentParser:
|
||||
"""
|
||||
add parser for unhold package subcommand
|
||||
|
||||
Args:
|
||||
root(SubParserAction): subparsers for the commands
|
||||
|
||||
Returns:
|
||||
argparse.ArgumentParser: created argument parser
|
||||
"""
|
||||
parser = root.add_parser("package-unhold", help="unhold package",
|
||||
description="remove package hold, allowing automatic updates")
|
||||
parser.add_argument("package", help="package base", nargs="+")
|
||||
parser.set_defaults(action=Action.Remove, lock=None, quiet=True, report=False, unsafe=True)
|
||||
return parser
|
||||
|
||||
arguments = [
|
||||
_set_package_hold_parser,
|
||||
_set_package_unhold_parser,
|
||||
]
|
||||
@@ -1,100 +0,0 @@
|
||||
#
|
||||
# Copyright (c) 2021-2026 ahriman team.
|
||||
#
|
||||
# This file is part of ahriman
|
||||
# (see https://github.com/arcan1s/ahriman).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
import argparse
|
||||
|
||||
from dataclasses import replace
|
||||
|
||||
from ahriman.application.application import Application
|
||||
from ahriman.application.handlers.handler import Handler, SubParserAction
|
||||
from ahriman.core.configuration import Configuration
|
||||
from ahriman.core.formatters import PkgbuildPrinter
|
||||
from ahriman.models.action import Action
|
||||
from ahriman.models.repository_id import RepositoryId
|
||||
|
||||
|
||||
class Pkgbuild(Handler):
|
||||
"""
|
||||
package pkgbuild handler
|
||||
"""
|
||||
|
||||
ALLOW_MULTI_ARCHITECTURE_RUN = False # conflicting io
|
||||
|
||||
@classmethod
|
||||
def run(cls, args: argparse.Namespace, repository_id: RepositoryId, configuration: Configuration, *,
|
||||
report: bool) -> None:
|
||||
"""
|
||||
callback for command line
|
||||
|
||||
Args:
|
||||
args(argparse.Namespace): command line args
|
||||
repository_id(RepositoryId): repository unique identifier
|
||||
configuration(Configuration): configuration instance
|
||||
report(bool): force enable or disable reporting
|
||||
"""
|
||||
client = Application(repository_id, configuration, report=True).reporter
|
||||
|
||||
match args.action:
|
||||
case Action.List:
|
||||
changes = client.package_changes_get(args.package)
|
||||
PkgbuildPrinter(changes)(verbose=True, separator="")
|
||||
Pkgbuild.check_status(args.exit_code, changes.pkgbuild is not None)
|
||||
case Action.Remove:
|
||||
changes = client.package_changes_get(args.package)
|
||||
client.package_changes_update(args.package, replace(changes, pkgbuild=None))
|
||||
|
||||
@staticmethod
|
||||
def _set_package_pkgbuild_parser(root: SubParserAction) -> argparse.ArgumentParser:
|
||||
"""
|
||||
add parser for package pkgbuild subcommand
|
||||
|
||||
Args:
|
||||
root(SubParserAction): subparsers for the commands
|
||||
|
||||
Returns:
|
||||
argparse.ArgumentParser: created argument parser
|
||||
"""
|
||||
parser = root.add_parser("package-pkgbuild", help="get package pkgbuild",
|
||||
description="retrieve package PKGBUILD stored in database",
|
||||
epilog="This command requests package status from the web interface "
|
||||
"if it is available.")
|
||||
parser.add_argument("package", help="package base")
|
||||
parser.add_argument("-e", "--exit-code", help="return non-zero exit status if result is empty",
|
||||
action="store_true")
|
||||
parser.set_defaults(action=Action.List, lock=None, quiet=True, report=False, unsafe=True)
|
||||
return parser
|
||||
|
||||
@staticmethod
|
||||
def _set_package_pkgbuild_remove_parser(root: SubParserAction) -> argparse.ArgumentParser:
|
||||
"""
|
||||
add parser for package pkgbuild remove subcommand
|
||||
|
||||
Args:
|
||||
root(SubParserAction): subparsers for the commands
|
||||
|
||||
Returns:
|
||||
argparse.ArgumentParser: created argument parser
|
||||
"""
|
||||
parser = root.add_parser("package-pkgbuild-remove", help="remove package pkgbuild",
|
||||
description="remove the package PKGBUILD stored remotely")
|
||||
parser.add_argument("package", help="package base")
|
||||
parser.set_defaults(action=Action.Remove, exit_code=False, lock=None, quiet=True, report=False, unsafe=True)
|
||||
return parser
|
||||
|
||||
arguments = [_set_package_pkgbuild_parser, _set_package_pkgbuild_remove_parser]
|
||||
@@ -1,131 +0,0 @@
|
||||
#
|
||||
# Copyright (c) 2021-2026 ahriman team.
|
||||
#
|
||||
# This file is part of ahriman
|
||||
# (see https://github.com/arcan1s/ahriman).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
import argparse
|
||||
|
||||
from dataclasses import replace
|
||||
from pathlib import Path
|
||||
|
||||
from ahriman.application.application import Application
|
||||
from ahriman.application.handlers.add import Add
|
||||
from ahriman.application.handlers.handler import Handler, SubParserAction
|
||||
from ahriman.core.configuration import Configuration
|
||||
from ahriman.core.exceptions import UnknownPackageError
|
||||
from ahriman.core.utils import extract_user
|
||||
from ahriman.models.package import Package
|
||||
from ahriman.models.package_source import PackageSource
|
||||
from ahriman.models.repository_id import RepositoryId
|
||||
|
||||
|
||||
class Rollback(Handler):
|
||||
"""
|
||||
package rollback handler
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def run(cls, args: argparse.Namespace, repository_id: RepositoryId, configuration: Configuration, *,
|
||||
report: bool) -> None:
|
||||
"""
|
||||
callback for command line
|
||||
|
||||
Args:
|
||||
args(argparse.Namespace): command line args
|
||||
repository_id(RepositoryId): repository unique identifier
|
||||
configuration(Configuration): configuration instance
|
||||
report(bool): force enable or disable reporting
|
||||
"""
|
||||
application = Application(repository_id, configuration, report=report)
|
||||
application.on_start()
|
||||
|
||||
package = Rollback.package_load(application, args.package, args.version)
|
||||
artifacts = Rollback.package_artifacts(application, package)
|
||||
|
||||
args.package = [str(artifact) for artifact in artifacts]
|
||||
Add.perform_action(application, args)
|
||||
|
||||
if args.hold:
|
||||
application.reporter.package_hold_update(package.base, enabled=True)
|
||||
|
||||
@staticmethod
|
||||
def _set_package_rollback_parser(root: SubParserAction) -> argparse.ArgumentParser:
|
||||
"""
|
||||
add parser for package rollback subcommand
|
||||
|
||||
Args:
|
||||
root(SubParserAction): subparsers for the commands
|
||||
|
||||
Returns:
|
||||
argparse.ArgumentParser: created argument parser
|
||||
"""
|
||||
parser = root.add_parser("package-rollback", help="rollback package",
|
||||
description="rollback package to specified version from archives")
|
||||
parser.add_argument("package", help="package base")
|
||||
parser.add_argument("version", help="package version")
|
||||
parser.add_argument("--hold", help="hold package afterwards",
|
||||
action=argparse.BooleanOptionalAction, default=True)
|
||||
parser.add_argument("-u", "--username", help="build as user", default=extract_user())
|
||||
parser.set_defaults(aur=False, changes=False, check_files=False, dependencies=False, dry_run=False,
|
||||
exit_code=True, increment=False, now=True, local=False, manual=False, refresh=False,
|
||||
source=PackageSource.Archive, variable=None, vcs=False)
|
||||
return parser
|
||||
|
||||
@staticmethod
|
||||
def package_artifacts(application: Application, package: Package) -> list[Path]:
|
||||
"""
|
||||
look for requested package artifacts and return paths to them
|
||||
|
||||
Args:
|
||||
application(Application): application instance
|
||||
package(Package): package descriptor
|
||||
|
||||
Returns:
|
||||
list[Path]: paths to found artifacts
|
||||
|
||||
Raises:
|
||||
UnknownPackageError: if artifacts do not exist
|
||||
"""
|
||||
# lookup for built artifacts
|
||||
artifacts = application.repository.package_archives_lookup(package)
|
||||
if not artifacts:
|
||||
raise UnknownPackageError(package.base)
|
||||
return artifacts
|
||||
|
||||
@staticmethod
|
||||
def package_load(application: Application, package_base: str, version: str) -> Package:
|
||||
"""
|
||||
load package from repository, while setting requested version
|
||||
|
||||
Args:
|
||||
application(Application): application instance
|
||||
package_base(str): package base
|
||||
version(str): package version
|
||||
|
||||
Returns:
|
||||
Package: loaded package
|
||||
|
||||
Raises:
|
||||
UnknownPackageError: if package does not exist
|
||||
"""
|
||||
try:
|
||||
package, _ = next(iter(application.reporter.package_get(package_base)))
|
||||
return replace(package, version=version)
|
||||
except StopIteration:
|
||||
raise UnknownPackageError(package_base) from None
|
||||
|
||||
arguments = [_set_package_rollback_parser]
|
||||
@@ -1,81 +0,0 @@
|
||||
#
|
||||
# Copyright (c) 2021-2026 ahriman team.
|
||||
#
|
||||
# This file is part of ahriman
|
||||
# (see https://github.com/arcan1s/ahriman).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
from pathlib import Path
|
||||
from pyalpm import Handle, Package # type: ignore[import-not-found]
|
||||
from tempfile import TemporaryDirectory
|
||||
from typing import Any, ClassVar, Self
|
||||
|
||||
|
||||
class PacmanHandle:
|
||||
"""
|
||||
lightweight wrapper for pacman handle to be used for direct alpm operations (e.g. package load)
|
||||
|
||||
Attributes:
|
||||
handle(Handle): pyalpm handle instance
|
||||
"""
|
||||
|
||||
_ephemeral: ClassVar[Self | None] = None
|
||||
|
||||
def __init__(self, *args: Any, **kwargs: Any) -> None:
|
||||
"""
|
||||
Args:
|
||||
*args(Any): positional arguments for :class:`pyalpm.Handle`
|
||||
**kwargs(Any): keyword arguments for :class:`pyalpm.Handle`
|
||||
"""
|
||||
self.handle = Handle(*args, **kwargs)
|
||||
|
||||
@classmethod
|
||||
def ephemeral(cls) -> Self:
|
||||
"""
|
||||
create temporary instance with no access to real databases
|
||||
|
||||
Returns:
|
||||
Self: loaded class
|
||||
"""
|
||||
if cls._ephemeral is None:
|
||||
# handle creates alpm version file, but we don't use it
|
||||
# so it is ok to just remove it
|
||||
with TemporaryDirectory(ignore_cleanup_errors=True) as dir_name:
|
||||
cls._ephemeral = cls("/", dir_name)
|
||||
return cls._ephemeral
|
||||
|
||||
def package_load(self, path: Path) -> Package:
|
||||
"""
|
||||
load package from path to the archive
|
||||
|
||||
Args:
|
||||
path(Path): path to package archive
|
||||
|
||||
Returns:
|
||||
Package: package instance
|
||||
"""
|
||||
return self.handle.load_pkg(str(path))
|
||||
|
||||
def __getattr__(self, item: str) -> Any:
|
||||
"""
|
||||
proxy methods for :class:`pyalpm.Handle`, because it doesn't allow subclassing
|
||||
|
||||
Args:
|
||||
item(str): property name
|
||||
|
||||
Returns:
|
||||
Any: attribute by its name
|
||||
"""
|
||||
return self.handle.__getattribute__(item)
|
||||
@@ -1,25 +0,0 @@
|
||||
#
|
||||
# Copyright (c) 2021-2026 ahriman team.
|
||||
#
|
||||
# This file is part of ahriman
|
||||
# (see https://github.com/arcan1s/ahriman).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
__all__ = ["steps"]
|
||||
|
||||
|
||||
steps = [
|
||||
"""alter table package_changes add column pkgbuild text""",
|
||||
]
|
||||
@@ -1,25 +0,0 @@
|
||||
#
|
||||
# Copyright (c) 2021-2026 ahriman team.
|
||||
#
|
||||
# This file is part of ahriman
|
||||
# (see https://github.com/arcan1s/ahriman).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
__all__ = ["steps"]
|
||||
|
||||
|
||||
steps = [
|
||||
"""alter table package_statuses add column is_held integer not null default 0""",
|
||||
]
|
||||
@@ -1,62 +0,0 @@
|
||||
#
|
||||
# Copyright (c) 2021-2026 ahriman team.
|
||||
#
|
||||
# This file is part of ahriman
|
||||
# (see https://github.com/arcan1s/ahriman).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
from ahriman.core.formatters.printer import Printer
|
||||
from ahriman.models.changes import Changes
|
||||
from ahriman.models.property import Property
|
||||
|
||||
|
||||
class PkgbuildPrinter(Printer):
|
||||
"""
|
||||
print content of the pkgbuild stored in changes
|
||||
|
||||
Attributes:
|
||||
changes(Changes): package changes
|
||||
"""
|
||||
|
||||
def __init__(self, changes: Changes) -> None:
|
||||
"""
|
||||
Args:
|
||||
changes(Changes): package changes
|
||||
"""
|
||||
Printer.__init__(self)
|
||||
self.changes = changes
|
||||
|
||||
def properties(self) -> list[Property]:
|
||||
"""
|
||||
convert content into printable data
|
||||
|
||||
Returns:
|
||||
list[Property]: list of content properties
|
||||
"""
|
||||
if self.changes.pkgbuild is None:
|
||||
return []
|
||||
return [Property("", self.changes.pkgbuild, is_required=True, indent=0)]
|
||||
|
||||
# pylint: disable=redundant-returns-doc
|
||||
def title(self) -> str | None:
|
||||
"""
|
||||
generate entry title from content
|
||||
|
||||
Returns:
|
||||
str | None: content title if it can be generated and ``None`` otherwise
|
||||
"""
|
||||
if self.changes.pkgbuild is None:
|
||||
return None
|
||||
return self.changes.last_commit_sha
|
||||
@@ -1,108 +0,0 @@
|
||||
#
|
||||
# Copyright (c) 2021-2026 ahriman team.
|
||||
#
|
||||
# This file is part of ahriman
|
||||
# (see https://github.com/arcan1s/ahriman).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
import contextvars
|
||||
import logging
|
||||
|
||||
from typing import Any, ClassVar, TypeVar, cast
|
||||
|
||||
|
||||
T = TypeVar("T")
|
||||
|
||||
|
||||
class LogContext:
|
||||
"""
|
||||
logging context manager which provides context variables injection into log records
|
||||
"""
|
||||
|
||||
_context: ClassVar[dict[str, contextvars.ContextVar[Any]]] = {}
|
||||
|
||||
@classmethod
|
||||
def get(cls, name: str) -> T | None:
|
||||
"""
|
||||
get context variable if available
|
||||
|
||||
Args:
|
||||
name(str): name of the context variable
|
||||
|
||||
Returns:
|
||||
T | None: context variable if available and ``None`` otherwise
|
||||
"""
|
||||
if (variable := cls._context.get(name)) is not None:
|
||||
return cast(T | None, variable.get())
|
||||
return None
|
||||
|
||||
@classmethod
|
||||
def log_record_factory(cls, *args: Any, **kwargs: Any) -> logging.LogRecord:
|
||||
"""
|
||||
log record factory which injects all registered context variables into log records
|
||||
|
||||
Args:
|
||||
*args(Any): positional arguments for the log factory
|
||||
**kwargs(Any): keyword arguments for the log factory
|
||||
|
||||
Returns:
|
||||
logging.LogRecord: log record with context variables set as attributes
|
||||
"""
|
||||
record = logging.LogRecord(*args, **kwargs)
|
||||
|
||||
for name, variable in cls._context.items():
|
||||
if (value := variable.get()) is not None:
|
||||
setattr(record, name, value)
|
||||
|
||||
return record
|
||||
|
||||
@classmethod
|
||||
def register(cls, name: str) -> contextvars.ContextVar[T]:
|
||||
"""
|
||||
(re)create context variable for log records
|
||||
|
||||
Args:
|
||||
name(str): name of the context variable
|
||||
|
||||
Returns:
|
||||
contextvars.ContextVar[T]: created context variable
|
||||
"""
|
||||
variable = cls._context[name] = contextvars.ContextVar(name, default=None)
|
||||
return variable
|
||||
|
||||
@classmethod
|
||||
def reset(cls, name: str, token: contextvars.Token[T]) -> None:
|
||||
"""
|
||||
reset context variable to its previous value
|
||||
|
||||
Args:
|
||||
name(str): attribute name to reset on log records
|
||||
token(contextvars.Token[T]): previously registered token
|
||||
"""
|
||||
cls._context[name].reset(token)
|
||||
|
||||
@classmethod
|
||||
def set(cls, name: str, value: T) -> contextvars.Token[T]:
|
||||
"""
|
||||
set context variable for log records. This value will be automatically emitted with each log record
|
||||
|
||||
Args:
|
||||
name(str): attribute name to set on log records
|
||||
value(T): current value of the context variable
|
||||
|
||||
Returns:
|
||||
contextvars.Token[T]: token created with this value
|
||||
"""
|
||||
return cls._context[name].set(value)
|
||||
@@ -1,136 +0,0 @@
|
||||
#
|
||||
# Copyright (c) 2021-2026 ahriman team.
|
||||
#
|
||||
# This file is part of ahriman
|
||||
# (see https://github.com/arcan1s/ahriman).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
import uuid
|
||||
|
||||
from asyncio import Lock, Queue, QueueFull, QueueShutDown
|
||||
from dataclasses import dataclass
|
||||
from typing import Any
|
||||
|
||||
from ahriman.core.log import LazyLogging
|
||||
from ahriman.models.event import EventType
|
||||
|
||||
|
||||
SSEvent = tuple[str, dict[str, Any]]
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class _Subscription:
|
||||
"""
|
||||
internal event bus subscription record
|
||||
|
||||
Attributes:
|
||||
topics(list[EventType] | None): event type filter, ``None`` means all
|
||||
object_id(str | None): object identifier filter, ``None`` means all
|
||||
queue(Queue[SSEvent]): per-subscriber event queue
|
||||
"""
|
||||
|
||||
topics: list[EventType] | None
|
||||
object_id: str | None
|
||||
queue: Queue[SSEvent]
|
||||
|
||||
|
||||
class EventBus(LazyLogging):
|
||||
"""
|
||||
event bus implementation
|
||||
|
||||
Attributes:
|
||||
max_size(int): maximum size of queue
|
||||
"""
|
||||
|
||||
def __init__(self, max_size: int) -> None:
|
||||
"""
|
||||
Args:
|
||||
max_size(int): maximum size of queue
|
||||
"""
|
||||
self.max_size = max_size
|
||||
|
||||
self._lock = Lock()
|
||||
self._subscribers: dict[str, _Subscription] = {}
|
||||
|
||||
async def broadcast(self, event_type: EventType, object_id: str | None, **kwargs: Any) -> None:
|
||||
"""
|
||||
broadcast event to all subscribers
|
||||
|
||||
Args:
|
||||
event_type(EventType): event type
|
||||
object_id(str | None): object identifier (e.g. package base)
|
||||
**kwargs(Any): additional event data
|
||||
"""
|
||||
event: dict[str, Any] = {"object_id": object_id}
|
||||
event.update(kwargs)
|
||||
|
||||
async with self._lock:
|
||||
snapshot = list(self._subscribers.items())
|
||||
|
||||
for subscriber_id, subscription in snapshot:
|
||||
if subscription.topics is not None and event_type not in subscription.topics:
|
||||
continue
|
||||
if subscription.object_id is not None and object_id != subscription.object_id:
|
||||
continue
|
||||
|
||||
try:
|
||||
subscription.queue.put_nowait((event_type, event))
|
||||
except QueueFull:
|
||||
self.logger.warning("discard message to slow subscriber %s", subscriber_id)
|
||||
except QueueShutDown:
|
||||
pass
|
||||
|
||||
async def shutdown(self) -> None:
|
||||
"""
|
||||
gracefully shutdown all subscribers
|
||||
"""
|
||||
async with self._lock:
|
||||
for subscription in self._subscribers.values():
|
||||
subscription.queue.shutdown()
|
||||
self._subscribers.clear()
|
||||
|
||||
async def subscribe(self, topics: list[EventType] | None = None,
|
||||
object_id: str | None = None) -> tuple[str, Queue[SSEvent]]:
|
||||
"""
|
||||
register new subscriber
|
||||
|
||||
Args:
|
||||
topics(list[EventType] | None, optional): list of event types to filter by. If ``None`` is set,
|
||||
all events will be delivered (Default value = None)
|
||||
object_id(str | None, optional): object identifier to filter by. If ``None`` is set,
|
||||
events for all objects will be delivered (Default value = None)
|
||||
|
||||
Returns:
|
||||
tuple[str, Queue[SSEvent]]: subscriber identifier and associated queue
|
||||
"""
|
||||
subscriber_id = str(uuid.uuid4())
|
||||
queue: Queue[SSEvent] = Queue(self.max_size)
|
||||
|
||||
async with self._lock:
|
||||
self._subscribers[subscriber_id] = _Subscription(topics=topics, object_id=object_id, queue=queue)
|
||||
|
||||
return subscriber_id, queue
|
||||
|
||||
async def unsubscribe(self, subscriber_id: str) -> None:
|
||||
"""
|
||||
unsubscribe from events
|
||||
|
||||
Args:
|
||||
subscriber_id(str): subscriber unique identifier
|
||||
"""
|
||||
async with self._lock:
|
||||
subscription = self._subscribers.pop(subscriber_id, None)
|
||||
if subscription is not None:
|
||||
subscription.queue.shutdown()
|
||||
@@ -1,361 +0,0 @@
|
||||
#
|
||||
# Copyright (c) 2021-2026 ahriman team.
|
||||
#
|
||||
# This file is part of ahriman
|
||||
# (see https://github.com/arcan1s/ahriman).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# pylint: disable=too-many-public-methods
|
||||
from asyncio import Lock
|
||||
from dataclasses import replace
|
||||
from typing import Self
|
||||
|
||||
from ahriman.core.exceptions import UnknownPackageError
|
||||
from ahriman.core.log import LazyLogging
|
||||
from ahriman.core.repository.package_info import PackageInfo
|
||||
from ahriman.core.status import Client
|
||||
from ahriman.core.status.event_bus import EventBus
|
||||
from ahriman.models.build_status import BuildStatus, BuildStatusEnum
|
||||
from ahriman.models.changes import Changes
|
||||
from ahriman.models.dependencies import Dependencies
|
||||
from ahriman.models.event import Event, EventType
|
||||
from ahriman.models.log_record import LogRecord
|
||||
from ahriman.models.package import Package
|
||||
from ahriman.models.pkgbuild_patch import PkgbuildPatch
|
||||
|
||||
|
||||
class Watcher(LazyLogging):
|
||||
"""
|
||||
package status watcher
|
||||
|
||||
Attributes:
|
||||
client(Client): reporter instance
|
||||
event_bus(EventBus): event bus instance
|
||||
package_info(PackageInfo): package info instance
|
||||
status(BuildStatus): daemon status
|
||||
"""
|
||||
|
||||
def __init__(self, client: Client, package_info: PackageInfo, event_bus: EventBus) -> None:
|
||||
"""
|
||||
Args:
|
||||
client(Client): reporter instance
|
||||
package_info(PackageInfo): package info instance
|
||||
event_bus(EventBus): event bus instance
|
||||
"""
|
||||
self.client = client
|
||||
self.package_info = package_info
|
||||
self.event_bus = event_bus
|
||||
|
||||
self._lock = Lock()
|
||||
self._known: dict[str, tuple[Package, BuildStatus]] = {}
|
||||
self.status = BuildStatus()
|
||||
|
||||
async def event_add(self, event: Event) -> None:
|
||||
"""
|
||||
create new event
|
||||
|
||||
Args:
|
||||
event(Event): audit log event
|
||||
"""
|
||||
self.client.event_add(event)
|
||||
|
||||
async def event_get(self, event: str | EventType | None, object_id: str | None,
|
||||
from_date: int | float | None = None, to_date: int | float | None = None,
|
||||
limit: int = -1, offset: int = 0) -> list[Event]:
|
||||
"""
|
||||
retrieve list of events
|
||||
|
||||
Args:
|
||||
event(str | EventType | None): filter by event type
|
||||
object_id(str | None): filter by event object
|
||||
from_date(int | float | None, optional): minimal creation date, inclusive (Default value = None)
|
||||
to_date(int | float | None, optional): maximal creation date, exclusive (Default value = None)
|
||||
limit(int, optional): limit records to the specified count, -1 means unlimited (Default value = -1)
|
||||
offset(int, optional): records offset (Default value = 0)
|
||||
|
||||
Returns:
|
||||
list[Event]: list of audit log events
|
||||
"""
|
||||
return self.client.event_get(event, object_id, from_date, to_date, limit, offset)
|
||||
|
||||
async def load(self) -> None:
|
||||
"""
|
||||
load packages from local database
|
||||
"""
|
||||
async with self._lock:
|
||||
self._known = {
|
||||
package.base: (package, status)
|
||||
for package, status in self.client.package_get(None)
|
||||
}
|
||||
|
||||
async def logs_rotate(self, keep_last_records: int) -> None:
|
||||
"""
|
||||
remove older logs from storage
|
||||
|
||||
Args:
|
||||
keep_last_records(int): number of last records to keep
|
||||
"""
|
||||
self.client.logs_rotate(keep_last_records)
|
||||
|
||||
async def package_archives(self, package_base: str) -> list[Package]:
|
||||
"""
|
||||
get known package archives
|
||||
|
||||
Args:
|
||||
package_base(str): package base
|
||||
|
||||
Returns:
|
||||
list[Package]: list of built package for this package base
|
||||
"""
|
||||
return self.package_info.package_archives(package_base)
|
||||
|
||||
async def package_changes_get(self, package_base: str) -> Changes:
|
||||
"""
|
||||
get package changes
|
||||
|
||||
Args:
|
||||
package_base(str): package base to retrieve
|
||||
|
||||
Returns:
|
||||
Changes: package changes if available and empty object otherwise
|
||||
"""
|
||||
return self.client.package_changes_get(package_base)
|
||||
|
||||
async def package_changes_update(self, package_base: str, changes: Changes) -> None:
|
||||
"""
|
||||
update package changes
|
||||
|
||||
Args:
|
||||
package_base(str): package base to update
|
||||
changes(Changes): changes descriptor
|
||||
"""
|
||||
self.client.package_changes_update(package_base, changes)
|
||||
|
||||
async def package_dependencies_get(self, package_base: str) -> Dependencies:
|
||||
"""
|
||||
get package dependencies
|
||||
|
||||
Args:
|
||||
package_base(str): package base to retrieve
|
||||
|
||||
Returns:
|
||||
list[Dependencies]: package implicit dependencies if available
|
||||
"""
|
||||
return self.client.package_dependencies_get(package_base)
|
||||
|
||||
async def package_dependencies_update(self, package_base: str, dependencies: Dependencies) -> None:
|
||||
"""
|
||||
update package dependencies
|
||||
|
||||
Args:
|
||||
package_base(str): package base to update
|
||||
dependencies(Dependencies): dependencies descriptor
|
||||
"""
|
||||
self.client.package_dependencies_update(package_base, dependencies)
|
||||
|
||||
async def package_get(self, package_base: str) -> tuple[Package, BuildStatus]:
|
||||
"""
|
||||
get current package base build status
|
||||
|
||||
Args:
|
||||
package_base(str): package base
|
||||
|
||||
Returns:
|
||||
tuple[Package, BuildStatus]: package and its status
|
||||
|
||||
Raises:
|
||||
UnknownPackageError: if no package found
|
||||
"""
|
||||
try:
|
||||
async with self._lock:
|
||||
return self._known[package_base]
|
||||
except KeyError:
|
||||
raise UnknownPackageError(package_base) from None
|
||||
|
||||
async def package_hold_update(self, package_base: str, *, enabled: bool) -> None:
|
||||
"""
|
||||
update package hold status
|
||||
|
||||
Args:
|
||||
package_base(str): package base name
|
||||
enabled(bool): new hold status
|
||||
"""
|
||||
package, status = await self.package_get(package_base)
|
||||
async with self._lock:
|
||||
self._known[package_base] = (package, replace(status, is_held=enabled))
|
||||
self.client.package_hold_update(package_base, enabled=enabled)
|
||||
|
||||
await self.event_bus.broadcast(EventType.PackageHeld, package_base, is_held=enabled)
|
||||
|
||||
async def package_logs_add(self, log_record: LogRecord) -> None:
|
||||
"""
|
||||
post log record
|
||||
|
||||
Args:
|
||||
log_record(LogRecord): log record
|
||||
"""
|
||||
self.client.package_logs_add(log_record)
|
||||
|
||||
await self.event_bus.broadcast(EventType.BuildLog, log_record.log_record_id.package_base, **log_record.view())
|
||||
|
||||
async def package_logs_get(self, package_base: str, version: str | None = None, process_id: str | None = None,
|
||||
limit: int = -1, offset: int = 0) -> list[LogRecord]:
|
||||
"""
|
||||
get package logs
|
||||
|
||||
Args:
|
||||
package_base(str): package base
|
||||
version(str | None, optional): package version to search (Default value = None)
|
||||
process_id(str | None, optional): process identifier to search (Default value = None)
|
||||
limit(int, optional): limit records to the specified count, -1 means unlimited (Default value = -1)
|
||||
offset(int, optional): records offset (Default value = 0)
|
||||
|
||||
Returns:
|
||||
list[LogRecord]: package logs
|
||||
"""
|
||||
return self.client.package_logs_get(package_base, version, process_id, limit, offset)
|
||||
|
||||
async def package_logs_remove(self, package_base: str, version: str | None) -> None:
|
||||
"""
|
||||
remove package logs
|
||||
|
||||
Args:
|
||||
package_base(str): package base
|
||||
version(str | None): package version to remove logs. If ``None`` is set, all logs will be removed
|
||||
"""
|
||||
self.client.package_logs_remove(package_base, version)
|
||||
|
||||
async def package_patches_get(self, package_base: str, variable: str | None) -> list[PkgbuildPatch]:
|
||||
"""
|
||||
get package patches
|
||||
|
||||
Args:
|
||||
package_base(str): package base to retrieve
|
||||
variable(str | None): optional filter by patch variable
|
||||
|
||||
Returns:
|
||||
list[PkgbuildPatch]: list of patches for the specified package
|
||||
"""
|
||||
return self.client.package_patches_get(package_base, variable)
|
||||
|
||||
async def package_patches_remove(self, package_base: str, variable: str | None) -> None:
|
||||
"""
|
||||
remove package patch
|
||||
|
||||
Args:
|
||||
package_base(str): package base to update
|
||||
variable(str | None): patch name. If ``None`` is set, all patches will be removed
|
||||
"""
|
||||
self.client.package_patches_remove(package_base, variable)
|
||||
|
||||
async def package_patches_update(self, package_base: str, patch: PkgbuildPatch) -> None:
|
||||
"""
|
||||
create or update package patch
|
||||
|
||||
Args:
|
||||
package_base(str): package base to update
|
||||
patch(PkgbuildPatch): package patch
|
||||
"""
|
||||
self.client.package_patches_update(package_base, patch)
|
||||
|
||||
async def package_remove(self, package_base: str) -> None:
|
||||
"""
|
||||
remove package base from known list if any
|
||||
|
||||
Args:
|
||||
package_base(str): package base
|
||||
"""
|
||||
async with self._lock:
|
||||
self._known.pop(package_base, None)
|
||||
self.client.package_remove(package_base)
|
||||
|
||||
await self.event_bus.broadcast(EventType.PackageRemoved, package_base)
|
||||
|
||||
async def package_status_update(self, package_base: str, status: BuildStatusEnum) -> None:
|
||||
"""
|
||||
update package status
|
||||
|
||||
Args:
|
||||
package_base(str): package base to update
|
||||
status(BuildStatusEnum): new build status
|
||||
"""
|
||||
package, current_status = await self.package_get(package_base)
|
||||
async with self._lock:
|
||||
self._known[package_base] = (package, BuildStatus(status, is_held=current_status.is_held))
|
||||
self.client.package_status_update(package_base, status)
|
||||
|
||||
await self.event_bus.broadcast(EventType.PackageStatusChanged, package_base, status=status.value)
|
||||
|
||||
async def package_update(self, package: Package, status: BuildStatusEnum) -> None:
|
||||
"""
|
||||
update package
|
||||
|
||||
Args:
|
||||
package(Package): package description
|
||||
status(BuildStatusEnum): new build status
|
||||
"""
|
||||
async with self._lock:
|
||||
_, current_status = self._known.get(package.base, (package, BuildStatus()))
|
||||
self._known[package.base] = (package, BuildStatus(status, is_held=current_status.is_held))
|
||||
self.client.package_update(package, status)
|
||||
|
||||
await self.event_bus.broadcast(
|
||||
EventType.PackageUpdated, package.base, status=status.value, version=package.version,
|
||||
)
|
||||
|
||||
async def packages(self) -> list[tuple[Package, BuildStatus]]:
|
||||
"""
|
||||
get current known packages list
|
||||
|
||||
Returns:
|
||||
list[tuple[Package, BuildStatus]]: list of packages together with their statuses
|
||||
"""
|
||||
async with self._lock:
|
||||
return list(self._known.values())
|
||||
|
||||
async def shutdown(self) -> None:
|
||||
"""
|
||||
gracefully shutdown watcher
|
||||
"""
|
||||
await self.event_bus.shutdown()
|
||||
|
||||
async def status_update(self, status: BuildStatusEnum) -> None:
|
||||
"""
|
||||
update service status
|
||||
|
||||
Args:
|
||||
status(BuildStatusEnum): new service status
|
||||
"""
|
||||
self.status = BuildStatus(status)
|
||||
|
||||
await self.event_bus.broadcast(EventType.ServiceStatusChanged, None, status=status.value)
|
||||
|
||||
def __call__(self, package_base: str | None) -> Self:
|
||||
"""
|
||||
extract client for future calls
|
||||
|
||||
Args:
|
||||
package_base(str | None): package base to validate that package exists if applicable
|
||||
|
||||
Returns:
|
||||
Self: instance of self to pass calls to the client
|
||||
|
||||
Raises:
|
||||
UnknownPackageError: if no package found
|
||||
"""
|
||||
# keep check here instead of calling package_get to keep this method synchronized
|
||||
if package_base is not None and package_base not in self._known:
|
||||
raise UnknownPackageError(package_base)
|
||||
return self
|
||||
@@ -1,85 +0,0 @@
|
||||
import argparse
|
||||
import pytest
|
||||
|
||||
from pytest_mock import MockerFixture
|
||||
|
||||
from ahriman.application.application import Application
|
||||
from ahriman.application.handlers.add import Add
|
||||
from ahriman.core.configuration import Configuration
|
||||
from ahriman.core.repository import Repository
|
||||
from ahriman.models.package_source import PackageSource
|
||||
from ahriman.models.pkgbuild_patch import PkgbuildPatch
|
||||
|
||||
|
||||
def _default_args(args: argparse.Namespace) -> argparse.Namespace:
|
||||
"""
|
||||
default arguments for these test cases
|
||||
|
||||
Args:
|
||||
args(argparse.Namespace): command line arguments fixture
|
||||
|
||||
Returns:
|
||||
argparse.Namespace: generated arguments for these test cases
|
||||
"""
|
||||
args.package = ["ahriman"]
|
||||
args.now = False
|
||||
args.refresh = 0
|
||||
args.source = PackageSource.Auto
|
||||
args.username = "username"
|
||||
args.variable = None
|
||||
return args
|
||||
|
||||
|
||||
def test_run(args: argparse.Namespace, configuration: Configuration, repository: Repository,
|
||||
mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must run command
|
||||
"""
|
||||
args = _default_args(args)
|
||||
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
||||
on_start_mock = mocker.patch("ahriman.application.application.Application.on_start")
|
||||
perform_mock = mocker.patch("ahriman.application.handlers.add.Add.perform_action")
|
||||
|
||||
_, repository_id = configuration.check_loaded()
|
||||
Add.run(args, repository_id, configuration, report=False)
|
||||
on_start_mock.assert_called_once_with()
|
||||
perform_mock.assert_called_once_with(pytest.helpers.anyvar(int), args)
|
||||
|
||||
|
||||
def test_perform_action(args: argparse.Namespace, application: Application, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must perform add action
|
||||
"""
|
||||
args = _default_args(args)
|
||||
application_mock = mocker.patch("ahriman.application.application.Application.add")
|
||||
update_mock = mocker.patch("ahriman.application.handlers.update.Update.perform_action")
|
||||
|
||||
Add.perform_action(application, args)
|
||||
application_mock.assert_called_once_with(args.package, args.source, args.username)
|
||||
update_mock.assert_not_called()
|
||||
|
||||
|
||||
def test_perform_action_with_patches(args: argparse.Namespace, application: Application, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must perform add action and insert temporary patches
|
||||
"""
|
||||
args = _default_args(args)
|
||||
args.variable = ["KEY=VALUE"]
|
||||
mocker.patch("ahriman.application.application.Application.add")
|
||||
patches_mock = mocker.patch("ahriman.core.status.local_client.LocalClient.package_patches_update")
|
||||
|
||||
Add.perform_action(application, args)
|
||||
patches_mock.assert_called_once_with(args.package[0], PkgbuildPatch("KEY", "VALUE"))
|
||||
|
||||
|
||||
def test_perform_action_with_updates(args: argparse.Namespace, application: Application, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must perform add action with updates after
|
||||
"""
|
||||
args = _default_args(args)
|
||||
args.now = True
|
||||
mocker.patch("ahriman.application.application.Application.add")
|
||||
update_mock = mocker.patch("ahriman.application.handlers.update.Update.perform_action")
|
||||
|
||||
Add.perform_action(application, args)
|
||||
update_mock.assert_called_once_with(application, args)
|
||||
@@ -1,84 +0,0 @@
|
||||
import argparse
|
||||
import pytest
|
||||
|
||||
from pytest_mock import MockerFixture
|
||||
|
||||
from ahriman.application.handlers.archives import Archives
|
||||
from ahriman.core.configuration import Configuration
|
||||
from ahriman.core.database import SQLite
|
||||
from ahriman.core.repository import Repository
|
||||
from ahriman.models.action import Action
|
||||
from ahriman.models.package import Package
|
||||
|
||||
|
||||
def _default_args(args: argparse.Namespace) -> argparse.Namespace:
|
||||
"""
|
||||
default arguments for these test cases
|
||||
|
||||
Args:
|
||||
args(argparse.Namespace): command line arguments fixture
|
||||
|
||||
Returns:
|
||||
argparse.Namespace: generated arguments for these test cases
|
||||
"""
|
||||
args.action = Action.List
|
||||
args.exit_code = False
|
||||
args.info = False
|
||||
args.package = "package"
|
||||
return args
|
||||
|
||||
|
||||
def test_run(args: argparse.Namespace, configuration: Configuration, repository: Repository,
|
||||
package_ahriman: Package, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must run command
|
||||
"""
|
||||
args = _default_args(args)
|
||||
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
||||
application_mock = mocker.patch("ahriman.core.repository.package_info.PackageInfo.package_archives",
|
||||
return_value=[package_ahriman])
|
||||
check_mock = mocker.patch("ahriman.application.handlers.handler.Handler.check_status")
|
||||
print_mock = mocker.patch("ahriman.core.formatters.Printer.print")
|
||||
|
||||
_, repository_id = configuration.check_loaded()
|
||||
Archives.run(args, repository_id, configuration, report=False)
|
||||
application_mock.assert_called_once_with(args.package)
|
||||
check_mock.assert_called_once_with(False, True)
|
||||
print_mock.assert_called_once_with(verbose=False, log_fn=pytest.helpers.anyvar(int), separator=": ")
|
||||
|
||||
|
||||
def test_run_empty_exception(args: argparse.Namespace, configuration: Configuration, repository: Repository,
|
||||
mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must raise ExitCode exception on empty archives result
|
||||
"""
|
||||
args = _default_args(args)
|
||||
args.exit_code = True
|
||||
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
||||
mocker.patch("ahriman.core.repository.package_info.PackageInfo.package_archives", return_value=[])
|
||||
check_mock = mocker.patch("ahriman.application.handlers.handler.Handler.check_status")
|
||||
|
||||
_, repository_id = configuration.check_loaded()
|
||||
Archives.run(args, repository_id, configuration, report=False)
|
||||
check_mock.assert_called_once_with(True, False)
|
||||
|
||||
|
||||
def test_imply_with_report(args: argparse.Namespace, configuration: Configuration, database: SQLite,
|
||||
mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must create application object with native reporting
|
||||
"""
|
||||
args = _default_args(args)
|
||||
mocker.patch("ahriman.core.database.SQLite.load", return_value=database)
|
||||
load_mock = mocker.patch("ahriman.core.repository.Repository.load")
|
||||
|
||||
_, repository_id = configuration.check_loaded()
|
||||
Archives.run(args, repository_id, configuration, report=False)
|
||||
load_mock.assert_called_once_with(repository_id, configuration, database, report=True, refresh_pacman_database=0)
|
||||
|
||||
|
||||
def test_disallow_multi_architecture_run() -> None:
|
||||
"""
|
||||
must not allow multi architecture run
|
||||
"""
|
||||
assert not Archives.ALLOW_MULTI_ARCHITECTURE_RUN
|
||||
@@ -1,53 +0,0 @@
|
||||
import argparse
|
||||
import pytest
|
||||
|
||||
from pytest_mock import MockerFixture
|
||||
|
||||
from ahriman.application.handlers.hold import Hold
|
||||
from ahriman.core.configuration import Configuration
|
||||
from ahriman.core.repository import Repository
|
||||
from ahriman.models.action import Action
|
||||
|
||||
|
||||
def _default_args(args: argparse.Namespace) -> argparse.Namespace:
|
||||
"""
|
||||
default arguments for these test cases
|
||||
|
||||
Args:
|
||||
args(argparse.Namespace): command line arguments fixture
|
||||
|
||||
Returns:
|
||||
argparse.Namespace: generated arguments for these test cases
|
||||
"""
|
||||
args.package = ["ahriman"]
|
||||
return args
|
||||
|
||||
|
||||
def test_run(args: argparse.Namespace, configuration: Configuration, repository: Repository,
|
||||
mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must run command
|
||||
"""
|
||||
args = _default_args(args)
|
||||
args.action = Action.Update
|
||||
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
||||
hold_mock = mocker.patch("ahriman.core.status.local_client.LocalClient.package_hold_update")
|
||||
|
||||
_, repository_id = configuration.check_loaded()
|
||||
Hold.run(args, repository_id, configuration, report=False)
|
||||
hold_mock.assert_called_once_with("ahriman", enabled=True)
|
||||
|
||||
|
||||
def test_run_remove(args: argparse.Namespace, configuration: Configuration, repository: Repository,
|
||||
mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must remove held status
|
||||
"""
|
||||
args = _default_args(args)
|
||||
args.action = Action.Remove
|
||||
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
||||
hold_mock = mocker.patch("ahriman.core.status.local_client.LocalClient.package_hold_update")
|
||||
|
||||
_, repository_id = configuration.check_loaded()
|
||||
Hold.run(args, repository_id, configuration, report=False)
|
||||
hold_mock.assert_called_once_with("ahriman", enabled=False)
|
||||
@@ -1,100 +0,0 @@
|
||||
import argparse
|
||||
import pytest
|
||||
|
||||
from pytest_mock import MockerFixture
|
||||
|
||||
from ahriman.application.handlers.pkgbuild import Pkgbuild
|
||||
from ahriman.core.configuration import Configuration
|
||||
from ahriman.core.database import SQLite
|
||||
from ahriman.core.repository import Repository
|
||||
from ahriman.models.action import Action
|
||||
from ahriman.models.changes import Changes
|
||||
|
||||
|
||||
def _default_args(args: argparse.Namespace) -> argparse.Namespace:
|
||||
"""
|
||||
default arguments for these test cases
|
||||
|
||||
Args:
|
||||
args(argparse.Namespace): command line arguments fixture
|
||||
|
||||
Returns:
|
||||
argparse.Namespace: generated arguments for these test cases
|
||||
"""
|
||||
args.action = Action.List
|
||||
args.exit_code = False
|
||||
args.package = "package"
|
||||
return args
|
||||
|
||||
|
||||
def test_run(args: argparse.Namespace, configuration: Configuration, repository: Repository,
|
||||
mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must run command
|
||||
"""
|
||||
args = _default_args(args)
|
||||
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
||||
application_mock = mocker.patch("ahriman.core.status.local_client.LocalClient.package_changes_get",
|
||||
return_value=Changes("sha", "change", "pkgbuild content"))
|
||||
check_mock = mocker.patch("ahriman.application.handlers.handler.Handler.check_status")
|
||||
print_mock = mocker.patch("ahriman.core.formatters.Printer.print")
|
||||
|
||||
_, repository_id = configuration.check_loaded()
|
||||
Pkgbuild.run(args, repository_id, configuration, report=False)
|
||||
application_mock.assert_called_once_with(args.package)
|
||||
check_mock.assert_called_once_with(False, True)
|
||||
print_mock.assert_called_once_with(verbose=True, log_fn=pytest.helpers.anyvar(int), separator="")
|
||||
|
||||
|
||||
def test_run_empty_exception(args: argparse.Namespace, configuration: Configuration, repository: Repository,
|
||||
mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must raise ExitCode exception on empty pkgbuild result
|
||||
"""
|
||||
args = _default_args(args)
|
||||
args.exit_code = True
|
||||
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
||||
mocker.patch("ahriman.core.status.local_client.LocalClient.package_changes_get", return_value=Changes())
|
||||
check_mock = mocker.patch("ahriman.application.handlers.handler.Handler.check_status")
|
||||
|
||||
_, repository_id = configuration.check_loaded()
|
||||
Pkgbuild.run(args, repository_id, configuration, report=False)
|
||||
check_mock.assert_called_once_with(True, False)
|
||||
|
||||
|
||||
def test_run_remove(args: argparse.Namespace, configuration: Configuration, repository: Repository,
|
||||
mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must remove package pkgbuild
|
||||
"""
|
||||
args = _default_args(args)
|
||||
args.action = Action.Remove
|
||||
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
||||
changes = Changes("sha", "change", "pkgbuild content")
|
||||
mocker.patch("ahriman.core.status.local_client.LocalClient.package_changes_get", return_value=changes)
|
||||
update_mock = mocker.patch("ahriman.core.status.local_client.LocalClient.package_changes_update")
|
||||
|
||||
_, repository_id = configuration.check_loaded()
|
||||
Pkgbuild.run(args, repository_id, configuration, report=False)
|
||||
update_mock.assert_called_once_with(args.package, Changes("sha", "change", None))
|
||||
|
||||
|
||||
def test_imply_with_report(args: argparse.Namespace, configuration: Configuration, database: SQLite,
|
||||
mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must create application object with native reporting
|
||||
"""
|
||||
args = _default_args(args)
|
||||
mocker.patch("ahriman.core.database.SQLite.load", return_value=database)
|
||||
load_mock = mocker.patch("ahriman.core.repository.Repository.load")
|
||||
|
||||
_, repository_id = configuration.check_loaded()
|
||||
Pkgbuild.run(args, repository_id, configuration, report=False)
|
||||
load_mock.assert_called_once_with(repository_id, configuration, database, report=True, refresh_pacman_database=0)
|
||||
|
||||
|
||||
def test_disallow_multi_architecture_run() -> None:
|
||||
"""
|
||||
must not allow multi architecture run
|
||||
"""
|
||||
assert not Pkgbuild.ALLOW_MULTI_ARCHITECTURE_RUN
|
||||
@@ -1,113 +0,0 @@
|
||||
import argparse
|
||||
import pytest
|
||||
|
||||
from pytest_mock import MockerFixture
|
||||
|
||||
from ahriman.application.application import Application
|
||||
from ahriman.application.handlers.rollback import Rollback
|
||||
from ahriman.core.configuration import Configuration
|
||||
from ahriman.core.exceptions import UnknownPackageError
|
||||
from ahriman.core.repository import Repository
|
||||
from ahriman.models.package import Package
|
||||
|
||||
|
||||
def _default_args(args: argparse.Namespace) -> argparse.Namespace:
|
||||
"""
|
||||
default arguments for these test cases
|
||||
|
||||
Args:
|
||||
args(argparse.Namespace): command line arguments fixture
|
||||
|
||||
Returns:
|
||||
argparse.Namespace: generated arguments for these test cases
|
||||
"""
|
||||
args.package = "ahriman"
|
||||
args.version = "1.0.0-1"
|
||||
args.hold = False
|
||||
return args
|
||||
|
||||
|
||||
def test_run(args: argparse.Namespace, configuration: Configuration, repository: Repository, package_ahriman: Package,
|
||||
mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must run command
|
||||
"""
|
||||
args = _default_args(args)
|
||||
artifacts = [package.filepath for package in package_ahriman.packages.values()]
|
||||
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
||||
on_start_mock = mocker.patch("ahriman.application.application.Application.on_start")
|
||||
load_mock = mocker.patch("ahriman.application.handlers.rollback.Rollback.package_load",
|
||||
return_value=package_ahriman)
|
||||
artifacts_mock = mocker.patch("ahriman.application.handlers.rollback.Rollback.package_artifacts",
|
||||
return_value=artifacts)
|
||||
perform_mock = mocker.patch("ahriman.application.handlers.add.Add.perform_action")
|
||||
hold_mock = mocker.patch("ahriman.core.status.local_client.LocalClient.package_hold_update")
|
||||
|
||||
_, repository_id = configuration.check_loaded()
|
||||
Rollback.run(args, repository_id, configuration, report=False)
|
||||
on_start_mock.assert_called_once_with()
|
||||
load_mock.assert_called_once_with(pytest.helpers.anyvar(int), package_ahriman.base, args.version)
|
||||
artifacts_mock.assert_called_once_with(pytest.helpers.anyvar(int), package_ahriman)
|
||||
perform_mock.assert_called_once_with(pytest.helpers.anyvar(int), args)
|
||||
hold_mock.assert_not_called()
|
||||
|
||||
|
||||
def test_run_hold(args: argparse.Namespace, configuration: Configuration, repository: Repository,
|
||||
package_ahriman: Package, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must hold package after rollback
|
||||
"""
|
||||
args = _default_args(args)
|
||||
args.hold = True
|
||||
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
||||
mocker.patch("ahriman.application.application.Application.on_start")
|
||||
mocker.patch("ahriman.application.handlers.rollback.Rollback.package_load", return_value=package_ahriman)
|
||||
mocker.patch("ahriman.application.handlers.rollback.Rollback.package_artifacts", return_value=[])
|
||||
mocker.patch("ahriman.application.handlers.add.Add.perform_action")
|
||||
hold_mock = mocker.patch("ahriman.core.status.local_client.LocalClient.package_hold_update")
|
||||
|
||||
_, repository_id = configuration.check_loaded()
|
||||
Rollback.run(args, repository_id, configuration, report=False)
|
||||
hold_mock.assert_called_once_with(package_ahriman.base, enabled=True)
|
||||
|
||||
|
||||
def test_package_artifacts(application: Application, package_ahriman: Package, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must return package artifacts
|
||||
"""
|
||||
artifacts = [package.filepath for package in package_ahriman.packages.values()]
|
||||
lookup_mock = mocker.patch("ahriman.core.repository.Repository.package_archives_lookup", return_value=artifacts)
|
||||
|
||||
assert Rollback.package_artifacts(application, package_ahriman) == artifacts
|
||||
lookup_mock.assert_called_once_with(package_ahriman)
|
||||
|
||||
|
||||
def test_package_artifacts_empty(application: Application, package_ahriman: Package,
|
||||
mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must raise UnknownPackageError if no artifacts found
|
||||
"""
|
||||
mocker.patch("ahriman.core.repository.Repository.package_archives_lookup", return_value=[])
|
||||
with pytest.raises(UnknownPackageError):
|
||||
Rollback.package_artifacts(application, package_ahriman)
|
||||
|
||||
|
||||
def test_package_load(application: Application, package_ahriman: Package, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must load package from reporter
|
||||
"""
|
||||
package_mock = mocker.patch("ahriman.core.status.local_client.LocalClient.package_get",
|
||||
return_value=[(package_ahriman, None)])
|
||||
|
||||
result = Rollback.package_load(application, package_ahriman.base, "2.0.0-1")
|
||||
assert result.version == "2.0.0-1"
|
||||
package_mock.assert_called_once_with(package_ahriman.base)
|
||||
|
||||
|
||||
def test_package_load_unknown(application: Application, package_ahriman: Package, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must raise UnknownPackageError if package not found
|
||||
"""
|
||||
mocker.patch("ahriman.core.status.local_client.LocalClient.package_get", return_value=[])
|
||||
with pytest.raises(UnknownPackageError):
|
||||
Rollback.package_load(application, package_ahriman.base, package_ahriman.version)
|
||||
@@ -1,37 +0,0 @@
|
||||
import pytest
|
||||
|
||||
from pathlib import Path
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
from ahriman.core.alpm.pacman_handle import PacmanHandle
|
||||
|
||||
|
||||
def test_package_load() -> None:
|
||||
"""
|
||||
must load package from archive path
|
||||
"""
|
||||
local = Path("local")
|
||||
instance = PacmanHandle.ephemeral()
|
||||
handle_mock = instance.handle = MagicMock()
|
||||
|
||||
instance.package_load(local)
|
||||
handle_mock.load_pkg.assert_called_once_with(str(local))
|
||||
|
||||
PacmanHandle._ephemeral = None
|
||||
|
||||
|
||||
def test_getattr() -> None:
|
||||
"""
|
||||
must proxy attribute access to underlying handle
|
||||
"""
|
||||
instance = PacmanHandle.ephemeral()
|
||||
assert instance.dbpath
|
||||
|
||||
|
||||
def test_getattr_not_found() -> None:
|
||||
"""
|
||||
must raise AttributeError for missing handle attributes
|
||||
"""
|
||||
instance = PacmanHandle.ephemeral()
|
||||
with pytest.raises(AttributeError):
|
||||
assert instance.random_attribute
|
||||
@@ -1,8 +0,0 @@
|
||||
from ahriman.core.database.migrations.m017_pkgbuild import steps
|
||||
|
||||
|
||||
def test_migration_pkgbuild() -> None:
|
||||
"""
|
||||
migration must not be empty
|
||||
"""
|
||||
assert steps
|
||||
@@ -1,8 +0,0 @@
|
||||
from ahriman.core.database.migrations.m018_package_hold import steps
|
||||
|
||||
|
||||
def test_migration_package_hold() -> None:
|
||||
"""
|
||||
migration must not be empty
|
||||
"""
|
||||
assert steps
|
||||
@@ -1,32 +0,0 @@
|
||||
from ahriman.core.formatters import PkgbuildPrinter
|
||||
from ahriman.models.changes import Changes
|
||||
|
||||
|
||||
def test_properties(pkgbuild_printer: PkgbuildPrinter) -> None:
|
||||
"""
|
||||
must return non-empty properties list
|
||||
"""
|
||||
assert pkgbuild_printer.properties()
|
||||
|
||||
|
||||
def test_properties_empty() -> None:
|
||||
"""
|
||||
must return empty properties list if pkgbuild is empty
|
||||
"""
|
||||
assert not PkgbuildPrinter(Changes()).properties()
|
||||
assert not PkgbuildPrinter(Changes("sha", "changes")).properties()
|
||||
|
||||
|
||||
def test_title(pkgbuild_printer: PkgbuildPrinter) -> None:
|
||||
"""
|
||||
must return non-empty title
|
||||
"""
|
||||
assert pkgbuild_printer.title()
|
||||
|
||||
|
||||
def test_title_empty() -> None:
|
||||
"""
|
||||
must return empty title if change is empty
|
||||
"""
|
||||
assert not PkgbuildPrinter(Changes()).title()
|
||||
assert not PkgbuildPrinter(Changes("sha")).title()
|
||||
@@ -1,73 +0,0 @@
|
||||
import logging
|
||||
import pytest
|
||||
|
||||
from ahriman.core.alpm.repo import Repo
|
||||
from ahriman.core.build_tools.task import Task
|
||||
from ahriman.core.database import SQLite
|
||||
from ahriman.models.log_record_id import LogRecordId
|
||||
from ahriman.models.package import Package
|
||||
|
||||
|
||||
def test_logger(database: SQLite, repo: Repo) -> None:
|
||||
"""
|
||||
must set logger attribute
|
||||
"""
|
||||
assert database.logger
|
||||
assert database.logger.name == "sql"
|
||||
|
||||
assert repo.logger
|
||||
assert repo.logger.name == "ahriman.core.alpm.repo.Repo"
|
||||
|
||||
|
||||
def test_logger_name(database: SQLite, repo: Repo, task_ahriman: Task) -> None:
|
||||
"""
|
||||
must correctly generate logger name
|
||||
"""
|
||||
assert database.logger_name == "sql"
|
||||
assert repo.logger_name == "ahriman.core.alpm.repo.Repo"
|
||||
assert task_ahriman.logger_name == "ahriman.core.build_tools.task.Task"
|
||||
|
||||
|
||||
def test_in_context(database: SQLite) -> None:
|
||||
"""
|
||||
must set and reset generic log context
|
||||
"""
|
||||
with database.in_context("package_id", "42"):
|
||||
record = logging.makeLogRecord({})
|
||||
assert record.package_id == "42"
|
||||
|
||||
record = logging.makeLogRecord({})
|
||||
assert not hasattr(record, "package_id")
|
||||
|
||||
|
||||
def test_in_context_failed(database: SQLite) -> None:
|
||||
"""
|
||||
must reset context even if exception occurs
|
||||
"""
|
||||
with pytest.raises(ValueError):
|
||||
with database.in_context("package_id", "42"):
|
||||
raise ValueError()
|
||||
|
||||
record = logging.makeLogRecord({})
|
||||
assert not hasattr(record, "package_id")
|
||||
|
||||
|
||||
def test_in_package_context(database: SQLite, package_ahriman: Package) -> None:
|
||||
"""
|
||||
must set package log context
|
||||
"""
|
||||
with database.in_package_context(package_ahriman.base, package_ahriman.version):
|
||||
record = logging.makeLogRecord({})
|
||||
assert record.package_id == LogRecordId(package_ahriman.base, package_ahriman.version)
|
||||
|
||||
record = logging.makeLogRecord({})
|
||||
assert not hasattr(record, "package_id")
|
||||
|
||||
|
||||
def test_in_package_context_empty_version(database: SQLite, package_ahriman: Package) -> None:
|
||||
"""
|
||||
must set package log context with empty version
|
||||
"""
|
||||
with database.in_package_context(package_ahriman.base, None):
|
||||
record = logging.makeLogRecord({})
|
||||
assert record.package_id == LogRecordId(package_ahriman.base, "<unknown>")
|
||||
@@ -1,75 +0,0 @@
|
||||
import logging
|
||||
|
||||
from ahriman.core.log.log_context import LogContext
|
||||
|
||||
|
||||
def test_get() -> None:
|
||||
"""
|
||||
must get context variable value
|
||||
"""
|
||||
token = LogContext.set("package_id", "value")
|
||||
assert LogContext.get("package_id") == "value"
|
||||
LogContext.reset("package_id", token)
|
||||
|
||||
|
||||
def test_get_empty() -> None:
|
||||
"""
|
||||
must return None when context variable is unknown or not set
|
||||
"""
|
||||
assert LogContext.get("package_id") is None
|
||||
assert LogContext.get("random") is None
|
||||
|
||||
|
||||
def test_log_record_factory() -> None:
|
||||
"""
|
||||
must inject all registered context variables into log records
|
||||
"""
|
||||
package_token = LogContext.set("package_id", "package")
|
||||
|
||||
record = logging.makeLogRecord({})
|
||||
assert record.package_id == "package"
|
||||
|
||||
LogContext.reset("package_id", package_token)
|
||||
|
||||
|
||||
def test_log_record_factory_empty() -> None:
|
||||
"""
|
||||
must not inject context variable when value is None
|
||||
"""
|
||||
record = logging.makeLogRecord({})
|
||||
assert not hasattr(record, "package_id")
|
||||
|
||||
|
||||
def test_register() -> None:
|
||||
"""
|
||||
must register a context variable
|
||||
"""
|
||||
variable = LogContext.register("random")
|
||||
|
||||
assert "random" in LogContext._context
|
||||
assert LogContext._context["random"] is variable
|
||||
|
||||
del LogContext._context["random"]
|
||||
|
||||
|
||||
def test_reset() -> None:
|
||||
"""
|
||||
must reset context variable so it is no longer injected
|
||||
"""
|
||||
token = LogContext.set("package_id", "value")
|
||||
LogContext.reset("package_id", token)
|
||||
|
||||
record = logging.makeLogRecord({})
|
||||
assert not hasattr(record, "package_id")
|
||||
|
||||
|
||||
def test_set() -> None:
|
||||
"""
|
||||
must set context variable and inject it into log records
|
||||
"""
|
||||
token = LogContext.set("package_id", "value")
|
||||
|
||||
record = logging.makeLogRecord({})
|
||||
assert record.package_id == "value"
|
||||
|
||||
LogContext.reset("package_id", token)
|
||||
@@ -1,268 +0,0 @@
|
||||
import pytest
|
||||
|
||||
from dataclasses import replace
|
||||
from pathlib import Path
|
||||
from pytest_mock import MockerFixture
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
from ahriman.core.repository import Repository
|
||||
from ahriman.models.changes import Changes
|
||||
from ahriman.models.package import Package
|
||||
|
||||
|
||||
def test_full_depends(repository: Repository, package_ahriman: Package, package_python_schedule: Package,
|
||||
pyalpm_package_ahriman: MagicMock) -> None:
|
||||
"""
|
||||
must extract all dependencies from the package
|
||||
"""
|
||||
package_python_schedule.packages[package_python_schedule.base].provides = ["python3-schedule"]
|
||||
|
||||
database_mock = MagicMock()
|
||||
database_mock.pkgcache = [pyalpm_package_ahriman]
|
||||
repository.pacman = MagicMock()
|
||||
repository.pacman.handle.get_syncdbs.return_value = [database_mock]
|
||||
|
||||
assert repository.full_depends(package_ahriman, [package_python_schedule]) == package_ahriman.depends
|
||||
|
||||
package_python_schedule.packages[package_python_schedule.base].depends = [package_ahriman.base]
|
||||
expected = sorted(set(package_python_schedule.depends + package_ahriman.depends))
|
||||
assert repository.full_depends(package_python_schedule, [package_python_schedule]) == expected
|
||||
|
||||
|
||||
def test_load_archives(repository: Repository, package_ahriman: Package, package_python_schedule: Package,
|
||||
mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must return all packages grouped by package base
|
||||
"""
|
||||
single_packages = [
|
||||
Package(base=package_python_schedule.base,
|
||||
version=package_python_schedule.version,
|
||||
remote=package_python_schedule.remote,
|
||||
packages={package: props})
|
||||
for package, props in package_python_schedule.packages.items()
|
||||
] + [package_ahriman]
|
||||
mocker.patch("ahriman.models.package.Package.from_archive", side_effect=single_packages)
|
||||
mocker.patch("ahriman.core.status.local_client.LocalClient.package_get", return_value=[
|
||||
(package_ahriman, None),
|
||||
])
|
||||
|
||||
packages = repository.load_archives([Path("a.pkg.tar.xz"), Path("b.pkg.tar.xz"), Path("c.pkg.tar.xz")])
|
||||
assert len(packages) == 2
|
||||
assert {package.base for package in packages} == {package_ahriman.base, package_python_schedule.base}
|
||||
|
||||
archives = sum((list(package.packages.keys()) for package in packages), start=[])
|
||||
assert len(archives) == 3
|
||||
expected = set(package_ahriman.packages.keys())
|
||||
expected.update(package_python_schedule.packages.keys())
|
||||
assert set(archives) == expected
|
||||
|
||||
|
||||
def test_load_archives_failed(repository: Repository, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must skip packages which cannot be loaded
|
||||
"""
|
||||
mocker.patch("ahriman.models.package.Package.from_archive", side_effect=Exception)
|
||||
assert not repository.load_archives([Path("a.pkg.tar.xz")])
|
||||
|
||||
|
||||
def test_load_archives_not_package(repository: Repository) -> None:
|
||||
"""
|
||||
must skip not packages from iteration
|
||||
"""
|
||||
assert not repository.load_archives([Path("a.tar.xz")])
|
||||
|
||||
|
||||
def test_load_archives_different_version(repository: Repository, package_python_schedule: Package,
|
||||
mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must load packages with different versions choosing maximal
|
||||
"""
|
||||
single_packages = [
|
||||
Package(base=package_python_schedule.base,
|
||||
version=package_python_schedule.version,
|
||||
remote=package_python_schedule.remote,
|
||||
packages={package: props})
|
||||
for package, props in package_python_schedule.packages.items()
|
||||
]
|
||||
single_packages[0].version = "0.0.1-1"
|
||||
mocker.patch("ahriman.models.package.Package.from_archive", side_effect=single_packages)
|
||||
|
||||
packages = repository.load_archives([Path("a.pkg.tar.xz"), Path("b.pkg.tar.xz")])
|
||||
assert len(packages) == 1
|
||||
assert packages[0].version == package_python_schedule.version
|
||||
|
||||
|
||||
def test_load_archives_all_versions(repository: Repository, package_ahriman: Package,
|
||||
mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must load packages with different versions keeping all when latest_only is False
|
||||
"""
|
||||
mocker.patch("ahriman.models.package.Package.from_archive",
|
||||
side_effect=[package_ahriman, replace(package_ahriman, version="0.0.1-1")])
|
||||
mocker.patch("ahriman.core.status.local_client.LocalClient.package_get", return_value=[])
|
||||
|
||||
packages = repository.load_archives([Path("a.pkg.tar.xz"), Path("b.pkg.tar.xz")], latest_only=False)
|
||||
assert len(packages) == 2
|
||||
|
||||
|
||||
def test_package_archives(repository: Repository, package_ahriman: Package, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must load package archives sorted by version
|
||||
"""
|
||||
mocker.patch("pathlib.Path.is_dir", return_value=True)
|
||||
mocker.patch("pathlib.Path.iterdir")
|
||||
load_mock = mocker.patch("ahriman.core.repository.package_info.PackageInfo.load_archives",
|
||||
return_value=[replace(package_ahriman, version=str(i)) for i in range(5)])
|
||||
|
||||
result = repository.package_archives(package_ahriman.base)
|
||||
assert len(result) == 5
|
||||
assert [p.version for p in result] == [str(i) for i in range(5)]
|
||||
load_mock.assert_called_once_with(pytest.helpers.anyvar(int), latest_only=False)
|
||||
|
||||
|
||||
def test_package_archives_no_directory(repository: Repository, package_ahriman: Package,
|
||||
mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must return empty list if archive directory does not exist
|
||||
"""
|
||||
mocker.patch("pathlib.Path.is_dir", return_value=False)
|
||||
assert repository.package_archives(package_ahriman.base) == []
|
||||
|
||||
|
||||
def test_package_archives_architecture_mismatch(repository: Repository, package_ahriman: Package,
|
||||
mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must skip packages with mismatched architecture
|
||||
"""
|
||||
package_ahriman.packages[package_ahriman.base].architecture = "i686"
|
||||
|
||||
mocker.patch("pathlib.Path.is_dir", return_value=True)
|
||||
mocker.patch("pathlib.Path.iterdir")
|
||||
mocker.patch("ahriman.core.repository.package_info.PackageInfo.load_archives",
|
||||
return_value=[package_ahriman])
|
||||
|
||||
result = repository.package_archives(package_ahriman.base)
|
||||
assert len(result) == 0
|
||||
|
||||
|
||||
def test_package_archives_lookup(repository: Repository, package_ahriman: Package, package_python_schedule: Package,
|
||||
mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must existing packages which match the version
|
||||
"""
|
||||
archives_mock = mocker.patch("ahriman.core.repository.package_info.PackageInfo.package_archives", return_value=[
|
||||
package_ahriman,
|
||||
package_python_schedule,
|
||||
replace(package_ahriman, version="1"),
|
||||
])
|
||||
glob_mock = mocker.patch("pathlib.Path.glob", return_value=[Path("1.pkg.tar.xz")])
|
||||
|
||||
assert repository.package_archives_lookup(package_ahriman) == [Path("1.pkg.tar.xz")]
|
||||
archives_mock.assert_called_once_with(package_ahriman.base)
|
||||
glob_mock.assert_called_once_with(f"{package_ahriman.packages[package_ahriman.base].filename}*")
|
||||
|
||||
|
||||
def test_package_archives_lookup_version_mismatch(repository: Repository, package_ahriman: Package,
|
||||
mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must return nothing if no packages found with the same version
|
||||
"""
|
||||
mocker.patch("ahriman.core.repository.package_info.PackageInfo.package_archives",
|
||||
return_value=[replace(package_ahriman, version="1")])
|
||||
assert repository.package_archives_lookup(package_ahriman) == []
|
||||
|
||||
|
||||
def test_package_archives_lookup_architecture_mismatch(repository: Repository, package_ahriman: Package,
|
||||
mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must return nothing if architecture doesn't match
|
||||
"""
|
||||
mocker.patch("ahriman.core.repository.package_info.PackageInfo.package_archives", return_value=[])
|
||||
assert repository.package_archives_lookup(package_ahriman) == []
|
||||
|
||||
|
||||
def test_package_archives_lookup_no_archive_directory(repository: Repository, package_ahriman: Package,
|
||||
mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must return nothing if no archive directory found
|
||||
"""
|
||||
mocker.patch("ahriman.core.repository.package_info.PackageInfo.package_archives", return_value=[])
|
||||
assert repository.package_archives_lookup(package_ahriman) == []
|
||||
|
||||
|
||||
def test_package_changes(repository: Repository, package_ahriman: Package, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must load package changes
|
||||
"""
|
||||
changes = Changes("sha", "change")
|
||||
load_mock = mocker.patch("ahriman.core.build_tools.sources.Sources.load", return_value="sha2")
|
||||
changes_mock = mocker.patch("ahriman.core.build_tools.sources.Sources.changes", return_value=changes)
|
||||
|
||||
assert repository.package_changes(package_ahriman, changes.last_commit_sha) == changes
|
||||
load_mock.assert_called_once_with(
|
||||
pytest.helpers.anyvar(int), package_ahriman, [], repository.configuration.repository_paths)
|
||||
changes_mock.assert_called_once_with(pytest.helpers.anyvar(int), changes.last_commit_sha)
|
||||
|
||||
|
||||
def test_package_changes_skip(repository: Repository, package_ahriman: Package, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must skip loading package changes if no new commits
|
||||
"""
|
||||
mocker.patch("ahriman.core.build_tools.sources.Sources.load", return_value="sha")
|
||||
changes_mock = mocker.patch("ahriman.core.build_tools.sources.Sources.changes")
|
||||
|
||||
assert repository.package_changes(package_ahriman, "sha") is None
|
||||
changes_mock.assert_not_called()
|
||||
|
||||
|
||||
def test_packages(repository: Repository, package_ahriman: Package, package_python_schedule: Package,
|
||||
mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must return repository packages
|
||||
"""
|
||||
mocker.patch("pathlib.Path.iterdir")
|
||||
load_mock = mocker.patch("ahriman.core.repository.package_info.PackageInfo.load_archives",
|
||||
return_value=[package_ahriman, package_python_schedule])
|
||||
assert repository.packages() == [package_ahriman, package_python_schedule]
|
||||
# it uses filter object, so we cannot verify argument list =/
|
||||
load_mock.assert_called_once_with(pytest.helpers.anyvar(int))
|
||||
|
||||
|
||||
def test_packages_filter(repository: Repository, package_ahriman: Package, package_python_schedule: Package,
|
||||
mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must filter result by bases
|
||||
"""
|
||||
mocker.patch("pathlib.Path.iterdir")
|
||||
mocker.patch("ahriman.core.repository.package_info.PackageInfo.load_archives",
|
||||
return_value=[package_ahriman, package_python_schedule])
|
||||
assert repository.packages([package_ahriman.base]) == [package_ahriman]
|
||||
|
||||
|
||||
def test_packages_built(repository: Repository, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must return build packages
|
||||
"""
|
||||
mocker.patch("pathlib.Path.iterdir", return_value=[Path("a.tar.xz"), Path("b.pkg.tar.xz")])
|
||||
assert repository.packages_built() == [Path("b.pkg.tar.xz")]
|
||||
|
||||
|
||||
def test_packages_depend_on(repository: Repository, package_ahriman: Package, package_python_schedule: Package,
|
||||
mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must filter packages by depends list
|
||||
"""
|
||||
mocker.patch("ahriman.core.repository.repository.Repository.packages",
|
||||
return_value=[package_ahriman, package_python_schedule])
|
||||
assert repository.packages_depend_on([package_ahriman], {"python-srcinfo"}) == [package_ahriman]
|
||||
|
||||
|
||||
def test_packages_depend_on_empty(repository: Repository, package_ahriman: Package, package_python_schedule: Package,
|
||||
mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must return all packages in case if no filter is provided
|
||||
"""
|
||||
mocker.patch("ahriman.core.repository.repository.Repository.packages",
|
||||
return_value=[package_ahriman, package_python_schedule])
|
||||
assert repository.packages_depend_on([package_ahriman, package_python_schedule], None) == \
|
||||
[package_ahriman, package_python_schedule]
|
||||
@@ -1,145 +0,0 @@
|
||||
import pytest
|
||||
|
||||
from asyncio import QueueShutDown
|
||||
|
||||
from ahriman.core.status.event_bus import EventBus
|
||||
from ahriman.models.event import EventType
|
||||
from ahriman.models.package import Package
|
||||
|
||||
|
||||
async def test_broadcast(event_bus: EventBus, package_ahriman: Package) -> None:
|
||||
"""
|
||||
must broadcast event to all subscribers
|
||||
"""
|
||||
_, queue = await event_bus.subscribe()
|
||||
await event_bus.broadcast(EventType.PackageUpdated, package_ahriman.base, version=package_ahriman.version)
|
||||
|
||||
message = queue.get_nowait()
|
||||
assert message == (
|
||||
EventType.PackageUpdated,
|
||||
{"object_id": package_ahriman.base, "version": package_ahriman.version},
|
||||
)
|
||||
|
||||
|
||||
async def test_broadcast_with_topics(event_bus: EventBus, package_ahriman: Package) -> None:
|
||||
"""
|
||||
must broadcast event to subscribers with matching topics
|
||||
"""
|
||||
_, queue = await event_bus.subscribe([EventType.PackageUpdated])
|
||||
await event_bus.broadcast(EventType.PackageUpdated, package_ahriman.base)
|
||||
assert not queue.empty()
|
||||
|
||||
|
||||
async def test_broadcast_topic_isolation(event_bus: EventBus, package_ahriman: Package) -> None:
|
||||
"""
|
||||
must not broadcast event to subscribers with non-matching topics
|
||||
"""
|
||||
_, queue = await event_bus.subscribe([EventType.BuildLog])
|
||||
await event_bus.broadcast(EventType.PackageUpdated, package_ahriman.base)
|
||||
assert queue.empty()
|
||||
|
||||
|
||||
async def test_broadcast_queue_full(event_bus: EventBus, package_ahriman: Package) -> None:
|
||||
"""
|
||||
must discard message to slow subscriber
|
||||
"""
|
||||
event_bus.max_size = 1
|
||||
_, queue = await event_bus.subscribe()
|
||||
|
||||
await event_bus.broadcast(EventType.PackageUpdated, package_ahriman.base)
|
||||
await event_bus.broadcast(EventType.PackageRemoved, package_ahriman.base)
|
||||
assert queue.qsize() == 1
|
||||
|
||||
|
||||
async def test_broadcast_queue_shutdown(event_bus: EventBus, package_ahriman: Package) -> None:
|
||||
"""
|
||||
must skip subscriber whose queue was shutdown concurrently
|
||||
"""
|
||||
_, queue = await event_bus.subscribe()
|
||||
queue.shutdown()
|
||||
|
||||
await event_bus.broadcast(EventType.PackageUpdated, package_ahriman.base)
|
||||
|
||||
|
||||
async def test_shutdown(event_bus: EventBus) -> None:
|
||||
"""
|
||||
must shutdown all subscriber queues on shutdown
|
||||
"""
|
||||
subscriber_id, queue = await event_bus.subscribe()
|
||||
|
||||
await event_bus.shutdown()
|
||||
assert subscriber_id not in event_bus._subscribers
|
||||
with pytest.raises(QueueShutDown):
|
||||
queue.get_nowait()
|
||||
|
||||
|
||||
async def test_shutdown_queue_full(event_bus: EventBus, package_ahriman: Package) -> None:
|
||||
"""
|
||||
must handle shutdown when queue is full
|
||||
"""
|
||||
event_bus.max_size = 1
|
||||
_, queue = await event_bus.subscribe()
|
||||
|
||||
await event_bus.broadcast(EventType.PackageUpdated, package_ahriman.base)
|
||||
await event_bus.shutdown()
|
||||
|
||||
|
||||
async def test_subscribe(event_bus: EventBus) -> None:
|
||||
"""
|
||||
must register new subscriber
|
||||
"""
|
||||
subscriber_id, queue = await event_bus.subscribe()
|
||||
|
||||
assert subscriber_id
|
||||
assert queue.empty()
|
||||
assert subscriber_id in event_bus._subscribers
|
||||
|
||||
|
||||
async def test_broadcast_with_object_id(event_bus: EventBus, package_ahriman: Package) -> None:
|
||||
"""
|
||||
must broadcast event to subscribers with matching object_id
|
||||
"""
|
||||
_, queue = await event_bus.subscribe(object_id=package_ahriman.base)
|
||||
await event_bus.broadcast(EventType.PackageUpdated, package_ahriman.base)
|
||||
assert not queue.empty()
|
||||
|
||||
|
||||
async def test_broadcast_object_id_isolation(event_bus: EventBus, package_ahriman: Package) -> None:
|
||||
"""
|
||||
must not broadcast event to subscribers with non-matching object_id
|
||||
"""
|
||||
_, queue = await event_bus.subscribe(object_id="other-package")
|
||||
await event_bus.broadcast(EventType.PackageUpdated, package_ahriman.base)
|
||||
assert queue.empty()
|
||||
|
||||
|
||||
async def test_subscribe_with_topics(event_bus: EventBus) -> None:
|
||||
"""
|
||||
must register subscriber with topic filter
|
||||
"""
|
||||
subscriber_id, _ = await event_bus.subscribe([EventType.BuildLog])
|
||||
assert event_bus._subscribers[subscriber_id].topics == [EventType.BuildLog]
|
||||
|
||||
|
||||
async def test_subscribe_with_object_id(event_bus: EventBus, package_ahriman: Package) -> None:
|
||||
"""
|
||||
must register subscriber with object_id filter
|
||||
"""
|
||||
subscriber_id, _ = await event_bus.subscribe(object_id=package_ahriman.base)
|
||||
assert event_bus._subscribers[subscriber_id].object_id == package_ahriman.base
|
||||
|
||||
|
||||
async def test_unsubscribe(event_bus: EventBus) -> None:
|
||||
"""
|
||||
must remove subscriber
|
||||
"""
|
||||
subscriber_id, _ = await event_bus.subscribe()
|
||||
await event_bus.unsubscribe(subscriber_id)
|
||||
assert subscriber_id not in event_bus._subscribers
|
||||
|
||||
|
||||
async def test_unsubscribe_unknown(event_bus: EventBus) -> None:
|
||||
"""
|
||||
must not fail on unknown subscriber removal
|
||||
"""
|
||||
await event_bus.unsubscribe("unknown")
|
||||
@@ -1,385 +0,0 @@
|
||||
import pytest
|
||||
|
||||
from pytest_mock import MockerFixture
|
||||
|
||||
from ahriman.core.exceptions import UnknownPackageError
|
||||
from ahriman.core.status.watcher import Watcher
|
||||
from ahriman.models.build_status import BuildStatus, BuildStatusEnum
|
||||
from ahriman.models.changes import Changes
|
||||
from ahriman.models.dependencies import Dependencies
|
||||
from ahriman.models.event import Event, EventType
|
||||
from ahriman.models.log_record import LogRecord
|
||||
from ahriman.models.log_record_id import LogRecordId
|
||||
from ahriman.models.package import Package
|
||||
from ahriman.models.pkgbuild_patch import PkgbuildPatch
|
||||
|
||||
|
||||
async def test_event_add(watcher: Watcher, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must create new event
|
||||
"""
|
||||
event = Event("event", "object")
|
||||
cache_mock = mocker.patch("ahriman.core.status.local_client.LocalClient.event_add")
|
||||
|
||||
await watcher.event_add(event)
|
||||
cache_mock.assert_called_once_with(event)
|
||||
|
||||
|
||||
async def test_event_get(watcher: Watcher, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must retrieve events
|
||||
"""
|
||||
event = Event("event", "object")
|
||||
cache_mock = mocker.patch("ahriman.core.status.local_client.LocalClient.event_get", return_value=[event])
|
||||
|
||||
result = await watcher.event_get(None, None)
|
||||
assert result == [event]
|
||||
cache_mock.assert_called_once_with(None, None, None, None, -1, 0)
|
||||
|
||||
|
||||
async def test_load(watcher: Watcher, package_ahriman: Package, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must correctly load packages
|
||||
"""
|
||||
cache_mock = mocker.patch("ahriman.core.status.local_client.LocalClient.package_get",
|
||||
return_value=[(package_ahriman, BuildStatus())])
|
||||
|
||||
await watcher.load()
|
||||
cache_mock.assert_called_once_with(None)
|
||||
package, status = watcher._known[package_ahriman.base]
|
||||
assert package == package_ahriman
|
||||
assert status.status == BuildStatusEnum.Unknown
|
||||
|
||||
|
||||
async def test_load_known(watcher: Watcher, package_ahriman: Package, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must correctly load packages with known statuses
|
||||
"""
|
||||
status = BuildStatus(BuildStatusEnum.Success)
|
||||
mocker.patch("ahriman.core.status.local_client.LocalClient.package_get", return_value=[(package_ahriman, status)])
|
||||
watcher._known = {package_ahriman.base: (package_ahriman, status)}
|
||||
|
||||
await watcher.load()
|
||||
_, status = watcher._known[package_ahriman.base]
|
||||
assert status.status == BuildStatusEnum.Success
|
||||
|
||||
|
||||
async def test_logs_rotate(watcher: Watcher, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must rotate logs
|
||||
"""
|
||||
cache_mock = mocker.patch("ahriman.core.status.local_client.LocalClient.logs_rotate")
|
||||
await watcher.logs_rotate(42)
|
||||
cache_mock.assert_called_once_with(42)
|
||||
|
||||
|
||||
async def test_package_archives(watcher: Watcher, package_ahriman: Package, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must return package archives from package info
|
||||
"""
|
||||
archives_mock = mocker.patch("ahriman.core.repository.package_info.PackageInfo.package_archives",
|
||||
return_value=[package_ahriman])
|
||||
|
||||
result = await watcher.package_archives(package_ahriman.base)
|
||||
assert result == [package_ahriman]
|
||||
archives_mock.assert_called_once_with(package_ahriman.base)
|
||||
|
||||
|
||||
async def test_package_get(watcher: Watcher, package_ahriman: Package) -> None:
|
||||
"""
|
||||
must return package status
|
||||
"""
|
||||
watcher._known = {package_ahriman.base: (package_ahriman, BuildStatus())}
|
||||
package, status = await watcher.package_get(package_ahriman.base)
|
||||
assert package == package_ahriman
|
||||
assert status.status == BuildStatusEnum.Unknown
|
||||
|
||||
|
||||
async def test_package_get_failed(watcher: Watcher, package_ahriman: Package) -> None:
|
||||
"""
|
||||
must fail on unknown package
|
||||
"""
|
||||
with pytest.raises(UnknownPackageError):
|
||||
await watcher.package_get(package_ahriman.base)
|
||||
|
||||
|
||||
async def test_package_changes_get(watcher: Watcher, package_ahriman: Package, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must return package changes
|
||||
"""
|
||||
changes = Changes("sha")
|
||||
cache_mock = mocker.patch("ahriman.core.status.local_client.LocalClient.package_changes_get",
|
||||
return_value=changes)
|
||||
|
||||
assert await watcher.package_changes_get(package_ahriman.base) == changes
|
||||
cache_mock.assert_called_once_with(package_ahriman.base)
|
||||
|
||||
|
||||
async def test_package_changes_update(watcher: Watcher, package_ahriman: Package, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must update package changes
|
||||
"""
|
||||
changes = Changes("sha")
|
||||
cache_mock = mocker.patch("ahriman.core.status.local_client.LocalClient.package_changes_update")
|
||||
|
||||
await watcher.package_changes_update(package_ahriman.base, changes)
|
||||
cache_mock.assert_called_once_with(package_ahriman.base, changes)
|
||||
|
||||
|
||||
async def test_package_dependencies_get(watcher: Watcher, package_ahriman: Package, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must return package dependencies
|
||||
"""
|
||||
dependencies = Dependencies({"path": [package_ahriman.base]})
|
||||
cache_mock = mocker.patch("ahriman.core.status.local_client.LocalClient.package_dependencies_get",
|
||||
return_value=dependencies)
|
||||
|
||||
assert await watcher.package_dependencies_get(package_ahriman.base) == dependencies
|
||||
cache_mock.assert_called_once_with(package_ahriman.base)
|
||||
|
||||
|
||||
async def test_package_dependencies_update(watcher: Watcher, package_ahriman: Package, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must update package dependencies
|
||||
"""
|
||||
dependencies = Dependencies({"path": [package_ahriman.base]})
|
||||
cache_mock = mocker.patch("ahriman.core.status.local_client.LocalClient.package_dependencies_update")
|
||||
|
||||
await watcher.package_dependencies_update(package_ahriman.base, dependencies)
|
||||
cache_mock.assert_called_once_with(package_ahriman.base, dependencies)
|
||||
|
||||
|
||||
async def test_package_hold_update(watcher: Watcher, package_ahriman: Package, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must update package hold status
|
||||
"""
|
||||
cache_mock = mocker.patch("ahriman.core.status.local_client.LocalClient.package_hold_update")
|
||||
broadcast_mock = mocker.patch("ahriman.core.status.event_bus.EventBus.broadcast")
|
||||
watcher._known = {package_ahriman.base: (package_ahriman, BuildStatus())}
|
||||
|
||||
await watcher.package_hold_update(package_ahriman.base, enabled=True)
|
||||
cache_mock.assert_called_once_with(package_ahriman.base, enabled=True)
|
||||
_, status = watcher._known[package_ahriman.base]
|
||||
assert status.is_held is True
|
||||
broadcast_mock.assert_called_once_with(EventType.PackageHeld, package_ahriman.base, is_held=True)
|
||||
|
||||
|
||||
async def test_package_hold_update_unknown(watcher: Watcher, package_ahriman: Package) -> None:
|
||||
"""
|
||||
must fail on unknown package hold update
|
||||
"""
|
||||
with pytest.raises(UnknownPackageError):
|
||||
await watcher.package_hold_update(package_ahriman.base, enabled=True)
|
||||
|
||||
|
||||
async def test_package_logs_add(watcher: Watcher, package_ahriman: Package, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must post log record
|
||||
"""
|
||||
log_record = LogRecord(LogRecordId(package_ahriman.base, "1.0.0"), 42.0, "message")
|
||||
cache_mock = mocker.patch("ahriman.core.status.local_client.LocalClient.package_logs_add")
|
||||
broadcast_mock = mocker.patch("ahriman.core.status.event_bus.EventBus.broadcast")
|
||||
|
||||
await watcher.package_logs_add(log_record)
|
||||
cache_mock.assert_called_once_with(log_record)
|
||||
broadcast_mock.assert_called_once_with(EventType.BuildLog, package_ahriman.base, **log_record.view())
|
||||
|
||||
|
||||
async def test_package_logs_get(watcher: Watcher, package_ahriman: Package, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must return package logs
|
||||
"""
|
||||
log_record = LogRecord(LogRecordId(package_ahriman.base, "1.0.0"), 42.0, "message")
|
||||
cache_mock = mocker.patch("ahriman.core.status.local_client.LocalClient.package_logs_get",
|
||||
return_value=[log_record])
|
||||
|
||||
assert await watcher.package_logs_get(package_ahriman.base) == [log_record]
|
||||
cache_mock.assert_called_once_with(package_ahriman.base, None, None, -1, 0)
|
||||
|
||||
|
||||
async def test_package_logs_remove(watcher: Watcher, package_ahriman: Package, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must remove package logs
|
||||
"""
|
||||
cache_mock = mocker.patch("ahriman.core.status.local_client.LocalClient.package_logs_remove")
|
||||
await watcher.package_logs_remove(package_ahriman.base, None)
|
||||
cache_mock.assert_called_once_with(package_ahriman.base, None)
|
||||
|
||||
|
||||
async def test_package_patches_get(watcher: Watcher, package_ahriman: Package, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must return package patches
|
||||
"""
|
||||
patch = PkgbuildPatch("key", "value")
|
||||
cache_mock = mocker.patch("ahriman.core.status.local_client.LocalClient.package_patches_get", return_value=[patch])
|
||||
|
||||
assert await watcher.package_patches_get(package_ahriman.base, None) == [patch]
|
||||
cache_mock.assert_called_once_with(package_ahriman.base, None)
|
||||
|
||||
|
||||
async def test_package_patches_remove(watcher: Watcher, package_ahriman: Package, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must remove package patches
|
||||
"""
|
||||
cache_mock = mocker.patch("ahriman.core.status.local_client.LocalClient.package_patches_remove")
|
||||
await watcher.package_patches_remove(package_ahriman.base, None)
|
||||
cache_mock.assert_called_once_with(package_ahriman.base, None)
|
||||
|
||||
|
||||
async def test_package_patches_update(watcher: Watcher, package_ahriman: Package, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must update package patches
|
||||
"""
|
||||
patch = PkgbuildPatch("key", "value")
|
||||
cache_mock = mocker.patch("ahriman.core.status.local_client.LocalClient.package_patches_update")
|
||||
|
||||
await watcher.package_patches_update(package_ahriman.base, patch)
|
||||
cache_mock.assert_called_once_with(package_ahriman.base, patch)
|
||||
|
||||
|
||||
async def test_package_remove(watcher: Watcher, package_ahriman: Package, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must remove package base
|
||||
"""
|
||||
cache_mock = mocker.patch("ahriman.core.status.local_client.LocalClient.package_remove")
|
||||
broadcast_mock = mocker.patch("ahriman.core.status.event_bus.EventBus.broadcast")
|
||||
watcher._known = {package_ahriman.base: (package_ahriman, BuildStatus())}
|
||||
|
||||
await watcher.package_remove(package_ahriman.base)
|
||||
assert not watcher._known
|
||||
cache_mock.assert_called_once_with(package_ahriman.base)
|
||||
broadcast_mock.assert_called_once_with(EventType.PackageRemoved, package_ahriman.base)
|
||||
|
||||
|
||||
async def test_package_remove_unknown(watcher: Watcher, package_ahriman: Package, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must not fail on unknown base removal
|
||||
"""
|
||||
cache_mock = mocker.patch("ahriman.core.status.local_client.LocalClient.package_remove")
|
||||
broadcast_mock = mocker.patch("ahriman.core.status.event_bus.EventBus.broadcast")
|
||||
|
||||
await watcher.package_remove(package_ahriman.base)
|
||||
cache_mock.assert_called_once_with(package_ahriman.base)
|
||||
broadcast_mock.assert_called_once_with(EventType.PackageRemoved, package_ahriman.base)
|
||||
|
||||
|
||||
async def test_package_status_update(watcher: Watcher, package_ahriman: Package, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must update package status only for known package
|
||||
"""
|
||||
cache_mock = mocker.patch("ahriman.core.status.local_client.LocalClient.package_status_update")
|
||||
broadcast_mock = mocker.patch("ahriman.core.status.event_bus.EventBus.broadcast")
|
||||
watcher._known = {package_ahriman.base: (package_ahriman, BuildStatus())}
|
||||
|
||||
await watcher.package_status_update(package_ahriman.base, BuildStatusEnum.Success)
|
||||
cache_mock.assert_called_once_with(package_ahriman.base, pytest.helpers.anyvar(int))
|
||||
package, status = watcher._known[package_ahriman.base]
|
||||
assert package == package_ahriman
|
||||
assert status.status == BuildStatusEnum.Success
|
||||
broadcast_mock.assert_called_once_with(
|
||||
EventType.PackageStatusChanged, package_ahriman.base, status=BuildStatusEnum.Success.value,
|
||||
)
|
||||
|
||||
|
||||
async def test_package_status_update_preserves_hold(watcher: Watcher, package_ahriman: Package,
|
||||
mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must preserve hold status on package status update
|
||||
"""
|
||||
mocker.patch("ahriman.core.status.local_client.LocalClient.package_status_update")
|
||||
mocker.patch("ahriman.core.status.event_bus.EventBus.broadcast")
|
||||
watcher._known = {package_ahriman.base: (package_ahriman, BuildStatus(is_held=True))}
|
||||
|
||||
await watcher.package_status_update(package_ahriman.base, BuildStatusEnum.Success)
|
||||
_, status = watcher._known[package_ahriman.base]
|
||||
assert status.is_held is True
|
||||
|
||||
|
||||
async def test_package_status_update_unknown(watcher: Watcher, package_ahriman: Package) -> None:
|
||||
"""
|
||||
must fail on unknown package status update only
|
||||
"""
|
||||
with pytest.raises(UnknownPackageError):
|
||||
await watcher.package_status_update(package_ahriman.base, BuildStatusEnum.Unknown)
|
||||
|
||||
|
||||
async def test_package_update(watcher: Watcher, package_ahriman: Package, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must add package to cache
|
||||
"""
|
||||
cache_mock = mocker.patch("ahriman.core.status.local_client.LocalClient.package_update")
|
||||
broadcast_mock = mocker.patch("ahriman.core.status.event_bus.EventBus.broadcast")
|
||||
|
||||
await watcher.package_update(package_ahriman, BuildStatusEnum.Unknown)
|
||||
assert await watcher.packages()
|
||||
cache_mock.assert_called_once_with(package_ahriman, pytest.helpers.anyvar(int))
|
||||
broadcast_mock.assert_called_once_with(
|
||||
EventType.PackageUpdated, package_ahriman.base,
|
||||
status=BuildStatusEnum.Unknown.value, version=package_ahriman.version,
|
||||
)
|
||||
|
||||
|
||||
async def test_package_update_preserves_hold(watcher: Watcher, package_ahriman: Package,
|
||||
mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must preserve hold status on package update
|
||||
"""
|
||||
mocker.patch("ahriman.core.status.local_client.LocalClient.package_update")
|
||||
watcher._known = {package_ahriman.base: (package_ahriman, BuildStatus(is_held=True))}
|
||||
|
||||
await watcher.package_update(package_ahriman, BuildStatusEnum.Success)
|
||||
_, status = watcher._known[package_ahriman.base]
|
||||
assert status.is_held is True
|
||||
|
||||
|
||||
async def test_packages(watcher: Watcher, package_ahriman: Package) -> None:
|
||||
"""
|
||||
must return list of available packages
|
||||
"""
|
||||
assert not await watcher.packages()
|
||||
|
||||
watcher._known = {package_ahriman.base: (package_ahriman, BuildStatus())}
|
||||
assert await watcher.packages()
|
||||
|
||||
|
||||
async def test_shutdown(watcher: Watcher, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must gracefully shutdown watcher
|
||||
"""
|
||||
shutdown_mock = mocker.patch("ahriman.core.status.event_bus.EventBus.shutdown")
|
||||
await watcher.shutdown()
|
||||
shutdown_mock.assert_called_once_with()
|
||||
|
||||
|
||||
async def test_status_update(watcher: Watcher, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must update service status
|
||||
"""
|
||||
broadcast_mock = mocker.patch("ahriman.core.status.event_bus.EventBus.broadcast")
|
||||
|
||||
await watcher.status_update(BuildStatusEnum.Success)
|
||||
assert watcher.status.status == BuildStatusEnum.Success
|
||||
broadcast_mock.assert_called_once_with(EventType.ServiceStatusChanged, None, status=BuildStatusEnum.Success.value)
|
||||
|
||||
|
||||
def test_call(watcher: Watcher, package_ahriman: Package) -> None:
|
||||
"""
|
||||
must return self instance if package exists
|
||||
"""
|
||||
watcher._known = {package_ahriman.base: (package_ahriman, BuildStatus())}
|
||||
assert watcher(package_ahriman.base)
|
||||
|
||||
|
||||
def test_call_skip(watcher: Watcher) -> None:
|
||||
"""
|
||||
must return self instance if no package base set
|
||||
"""
|
||||
assert watcher(None)
|
||||
|
||||
|
||||
def test_call_failed(watcher: Watcher, package_ahriman: Package) -> None:
|
||||
"""
|
||||
must raise UnknownPackage
|
||||
"""
|
||||
with pytest.raises(UnknownPackageError):
|
||||
assert watcher(package_ahriman.base)
|
||||
@@ -1,162 +0,0 @@
|
||||
import datetime
|
||||
import pytest
|
||||
|
||||
from unittest.mock import MagicMock, PropertyMock
|
||||
|
||||
from ahriman.core.alpm.pacman import Pacman
|
||||
from ahriman.core.alpm.remote import AUR
|
||||
from ahriman.core.configuration import Configuration
|
||||
from ahriman.models.aur_package import AURPackage
|
||||
from ahriman.models.package import Package
|
||||
from ahriman.models.package_description import PackageDescription
|
||||
from ahriman.models.package_source import PackageSource
|
||||
from ahriman.models.pacman_synchronization import PacmanSynchronization
|
||||
from ahriman.models.remote_source import RemoteSource
|
||||
from ahriman.models.scan_paths import ScanPaths
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def aur_package_akonadi() -> AURPackage:
|
||||
"""
|
||||
fixture for AUR package
|
||||
|
||||
Returns:
|
||||
AURPackage: AUR package test instance
|
||||
"""
|
||||
return AURPackage(
|
||||
id=0,
|
||||
name="akonadi",
|
||||
package_base_id=0,
|
||||
package_base="akonadi",
|
||||
version="21.12.3-2",
|
||||
description="PIM layer, which provides an asynchronous API to access all kind of PIM data",
|
||||
num_votes=0,
|
||||
popularity=0.0,
|
||||
first_submitted=datetime.datetime.fromtimestamp(0, datetime.UTC),
|
||||
last_modified=datetime.datetime.fromtimestamp(1646555990.610, datetime.UTC),
|
||||
url_path="",
|
||||
url="https://kontact.kde.org",
|
||||
out_of_date=None,
|
||||
maintainer="felixonmars",
|
||||
repository="extra",
|
||||
depends=[
|
||||
"libakonadi",
|
||||
"mariadb",
|
||||
],
|
||||
make_depends=[
|
||||
"boost",
|
||||
"doxygen",
|
||||
"extra-cmake-modules",
|
||||
"kaccounts-integration",
|
||||
"kitemmodels",
|
||||
"postgresql",
|
||||
"qt5-tools",
|
||||
],
|
||||
opt_depends=[
|
||||
"postgresql: PostgreSQL backend",
|
||||
],
|
||||
conflicts=[],
|
||||
provides=[],
|
||||
license=["LGPL"],
|
||||
keywords=[],
|
||||
groups=[],
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def package_tpacpi_bat_git() -> Package:
|
||||
"""
|
||||
git package fixture
|
||||
|
||||
Returns:
|
||||
Package: git package test instance
|
||||
"""
|
||||
return Package(
|
||||
base="tpacpi-bat-git",
|
||||
version="3.1.r12.g4959b52-1",
|
||||
remote=RemoteSource(
|
||||
source=PackageSource.AUR,
|
||||
git_url=AUR.remote_git_url("tpacpi-bat-git", "aur"),
|
||||
web_url=AUR.remote_web_url("tpacpi-bat-git"),
|
||||
path=".",
|
||||
branch="master",
|
||||
),
|
||||
packages={"tpacpi-bat-git": PackageDescription()})
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def pacman(configuration: Configuration) -> Pacman:
|
||||
"""
|
||||
fixture for pacman wrapper
|
||||
|
||||
Args:
|
||||
configuration(Configuration): configuration fixture
|
||||
|
||||
Returns:
|
||||
Pacman: pacman wrapper test instance
|
||||
"""
|
||||
_, repository_id = configuration.check_loaded()
|
||||
return Pacman(repository_id, configuration, refresh_database=PacmanSynchronization.Disabled)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def passwd() -> MagicMock:
|
||||
"""
|
||||
get passwd structure for the user
|
||||
|
||||
Returns:
|
||||
MagicMock: passwd structure test instance
|
||||
"""
|
||||
passwd = MagicMock()
|
||||
passwd.pw_dir = "home"
|
||||
passwd.pw_name = "ahriman"
|
||||
return passwd
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def pyalpm_package_ahriman(aur_package_ahriman: AURPackage) -> MagicMock:
|
||||
"""
|
||||
mock object for pyalpm package
|
||||
|
||||
Args:
|
||||
aur_package_ahriman(AURPackage): package fixture
|
||||
|
||||
Returns:
|
||||
MagicMock: pyalpm package mock
|
||||
"""
|
||||
mock = MagicMock()
|
||||
db = type(mock).db = MagicMock()
|
||||
|
||||
type(mock).base = PropertyMock(return_value=aur_package_ahriman.package_base)
|
||||
type(mock).builddate = PropertyMock(
|
||||
return_value=aur_package_ahriman.last_modified.replace(tzinfo=datetime.timezone.utc).timestamp())
|
||||
type(mock).conflicts = PropertyMock(return_value=aur_package_ahriman.conflicts)
|
||||
type(db).name = PropertyMock(return_value="aur")
|
||||
type(mock).depends = PropertyMock(return_value=aur_package_ahriman.depends)
|
||||
type(mock).desc = PropertyMock(return_value=aur_package_ahriman.description)
|
||||
type(mock).licenses = PropertyMock(return_value=aur_package_ahriman.license)
|
||||
type(mock).makedepends = PropertyMock(return_value=aur_package_ahriman.make_depends)
|
||||
type(mock).name = PropertyMock(return_value=aur_package_ahriman.name)
|
||||
type(mock).optdepends = PropertyMock(return_value=aur_package_ahriman.opt_depends)
|
||||
type(mock).checkdepends = PropertyMock(return_value=aur_package_ahriman.check_depends)
|
||||
type(mock).packager = PropertyMock(return_value="packager")
|
||||
type(mock).provides = PropertyMock(return_value=aur_package_ahriman.provides)
|
||||
type(mock).version = PropertyMock(return_value=aur_package_ahriman.version)
|
||||
type(mock).url = PropertyMock(return_value=aur_package_ahriman.url)
|
||||
type(mock).groups = PropertyMock(return_value=aur_package_ahriman.groups)
|
||||
|
||||
return mock
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def scan_paths(configuration: Configuration) -> ScanPaths:
|
||||
"""
|
||||
scan paths fixture
|
||||
|
||||
Args:
|
||||
configuration(Configuration): configuration test instance
|
||||
|
||||
Returns:
|
||||
ScanPaths: scan paths test instance
|
||||
"""
|
||||
return ScanPaths(configuration.getlist("build", "scan_paths", fallback=[]))
|
||||
@@ -1,32 +0,0 @@
|
||||
[build-system]
|
||||
requires = ["hatchling"]
|
||||
build-backend = "hatchling.build"
|
||||
|
||||
[project]
|
||||
name = "ahriman-triggers"
|
||||
description = "ArcH linux ReposItory MANager, additional extensions"
|
||||
readme = "../README.md"
|
||||
requires-python = ">=3.13"
|
||||
license = {file = "../COPYING"}
|
||||
authors = [
|
||||
{name = "ahriman team"},
|
||||
]
|
||||
dependencies = [
|
||||
"ahriman-core",
|
||||
]
|
||||
dynamic = ["version"]
|
||||
|
||||
[project.urls]
|
||||
Documentation = "https://ahriman.readthedocs.io/"
|
||||
Repository = "https://github.com/arcan1s/ahriman"
|
||||
Changelog = "https://github.com/arcan1s/ahriman/releases"
|
||||
|
||||
[tool.hatch.version]
|
||||
path = "../ahriman-core/src/ahriman/__init__.py"
|
||||
|
||||
[tool.hatch.build.targets.wheel]
|
||||
only-include = ["src/ahriman"]
|
||||
sources = ["src"]
|
||||
|
||||
[tool.hatch.build.targets.wheel.shared-data]
|
||||
"package/share" = "share"
|
||||
@@ -1,55 +0,0 @@
|
||||
[build-system]
|
||||
requires = ["hatchling"]
|
||||
build-backend = "hatchling.build"
|
||||
|
||||
[project]
|
||||
name = "ahriman-web"
|
||||
description = "ArcH linux ReposItory MANager, web server"
|
||||
readme = "../README.md"
|
||||
requires-python = ">=3.13"
|
||||
license = {file = "../COPYING"}
|
||||
authors = [
|
||||
{name = "ahriman team"},
|
||||
]
|
||||
dependencies = [
|
||||
"ahriman-core",
|
||||
"aiohttp",
|
||||
"aiohttp_cors",
|
||||
"aiohttp_jinja2",
|
||||
"aiohttp_sse",
|
||||
]
|
||||
dynamic = ["version"]
|
||||
|
||||
[project.optional-dependencies]
|
||||
auth = [
|
||||
"aiohttp_session",
|
||||
"aiohttp_security",
|
||||
"cryptography",
|
||||
]
|
||||
docs = [
|
||||
"aiohttp-apispec",
|
||||
"setuptools",
|
||||
]
|
||||
metrics = [
|
||||
"aiohttp-openmetrics",
|
||||
]
|
||||
oauth2 = [
|
||||
"ahriman-web[auth]",
|
||||
"aioauth-client",
|
||||
]
|
||||
|
||||
[project.urls]
|
||||
Documentation = "https://ahriman.readthedocs.io/"
|
||||
Repository = "https://github.com/arcan1s/ahriman"
|
||||
Changelog = "https://github.com/arcan1s/ahriman/releases"
|
||||
|
||||
[tool.hatch.version]
|
||||
path = "../ahriman-core/src/ahriman/__init__.py"
|
||||
|
||||
[tool.hatch.build.targets.wheel]
|
||||
only-include = ["src/ahriman"]
|
||||
sources = ["src"]
|
||||
|
||||
[tool.hatch.build.targets.wheel.shared-data]
|
||||
"package/lib" = "lib"
|
||||
"package/share" = "share"
|
||||
@@ -1,61 +0,0 @@
|
||||
#
|
||||
# Copyright (c) 2021-2026 ahriman team.
|
||||
#
|
||||
# This file is part of ahriman
|
||||
# (see https://github.com/arcan1s/ahriman).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
import hashlib
|
||||
|
||||
from aiohttp import ETag
|
||||
from aiohttp.typedefs import Middleware
|
||||
from aiohttp.web import HTTPNotModified, Request, Response, StreamResponse, middleware
|
||||
|
||||
from ahriman.web.middlewares import HandlerType
|
||||
|
||||
|
||||
__all__ = ["etag_handler"]
|
||||
|
||||
|
||||
def etag_handler() -> Middleware:
|
||||
"""
|
||||
middleware to handle ETag header for conditional requests. It computes ETag from the response body
|
||||
and returns 304 Not Modified if the client sends a matching ``If-None-Match`` header
|
||||
|
||||
Returns:
|
||||
Middleware: built middleware
|
||||
|
||||
Raises:
|
||||
HTTPNotModified: if content matches ``If-None-Match`` header sent
|
||||
"""
|
||||
@middleware
|
||||
async def handle(request: Request, handler: HandlerType) -> StreamResponse:
|
||||
response = await handler(request)
|
||||
|
||||
if not isinstance(response, Response) or not isinstance(response.body, bytes):
|
||||
return response
|
||||
|
||||
if request.method not in ("GET", "HEAD"):
|
||||
return response
|
||||
|
||||
etag = ETag(value=hashlib.md5(response.body, usedforsecurity=False).hexdigest())
|
||||
response.etag = etag
|
||||
|
||||
if request.if_none_match is not None and etag in request.if_none_match:
|
||||
raise HTTPNotModified(headers={"ETag": response.headers["ETag"]})
|
||||
|
||||
return response
|
||||
|
||||
return handle
|
||||
@@ -1,51 +0,0 @@
|
||||
#
|
||||
# Copyright (c) 2021-2026 ahriman team.
|
||||
#
|
||||
# This file is part of ahriman
|
||||
# (see https://github.com/arcan1s/ahriman).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
import uuid
|
||||
|
||||
from aiohttp.typedefs import Middleware
|
||||
from aiohttp.web import Request, StreamResponse, middleware
|
||||
|
||||
from ahriman.core.log.log_context import LogContext
|
||||
from ahriman.web.middlewares import HandlerType
|
||||
|
||||
|
||||
__all__ = ["request_id_handler"]
|
||||
|
||||
|
||||
def request_id_handler() -> Middleware:
|
||||
"""
|
||||
middleware to trace request id header
|
||||
|
||||
Returns:
|
||||
Middleware: request id processing middleware
|
||||
"""
|
||||
@middleware
|
||||
async def handle(request: Request, handler: HandlerType) -> StreamResponse:
|
||||
request_id = request.headers.getone("X-Request-ID", str(uuid.uuid4()))
|
||||
|
||||
token = LogContext.set("request_id", request_id)
|
||||
try:
|
||||
response = await handler(request)
|
||||
response.headers["X-Request-ID"] = request_id
|
||||
return response
|
||||
finally:
|
||||
LogContext.reset("request_id", token)
|
||||
|
||||
return handle
|
||||
@@ -1,37 +0,0 @@
|
||||
#
|
||||
# Copyright (c) 2021-2026 ahriman team.
|
||||
#
|
||||
# This file is part of ahriman
|
||||
# (see https://github.com/arcan1s/ahriman).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
from ahriman.models.event import EventType
|
||||
from ahriman.web.apispec import fields
|
||||
from ahriman.web.schemas.repository_id_schema import RepositoryIdSchema
|
||||
|
||||
|
||||
class EventBusFilterSchema(RepositoryIdSchema):
|
||||
"""
|
||||
request event bus filter schema
|
||||
"""
|
||||
|
||||
event = fields.List(fields.String(), metadata={
|
||||
"description": "Event type filter",
|
||||
"example": [EventType.PackageUpdated],
|
||||
})
|
||||
object_id = fields.String(metadata={
|
||||
"description": "Object identifier filter",
|
||||
"example": "ahriman",
|
||||
})
|
||||
@@ -1,30 +0,0 @@
|
||||
#
|
||||
# Copyright (c) 2021-2026 ahriman team.
|
||||
#
|
||||
# This file is part of ahriman
|
||||
# (see https://github.com/arcan1s/ahriman).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
from ahriman.web.apispec import Schema, fields
|
||||
|
||||
|
||||
class HoldSchema(Schema):
|
||||
"""
|
||||
request hold schema
|
||||
"""
|
||||
|
||||
is_held = fields.Boolean(required=True, metadata={
|
||||
"description": "Package hold status",
|
||||
})
|
||||
@@ -1,30 +0,0 @@
|
||||
#
|
||||
# Copyright (c) 2021-2026 ahriman team.
|
||||
#
|
||||
# This file is part of ahriman
|
||||
# (see https://github.com/arcan1s/ahriman).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
from ahriman.web.apispec import Schema, fields
|
||||
|
||||
|
||||
class PackagerSchema(Schema):
|
||||
"""
|
||||
request packager schema
|
||||
"""
|
||||
|
||||
packager = fields.String(metadata={
|
||||
"description": "Packager identity if applicable",
|
||||
})
|
||||
@@ -1,40 +0,0 @@
|
||||
#
|
||||
# Copyright (c) 2021-2026 ahriman team.
|
||||
#
|
||||
# This file is part of ahriman
|
||||
# (see https://github.com/arcan1s/ahriman).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
from ahriman import __version__
|
||||
from ahriman.web.apispec import fields
|
||||
from ahriman.web.schemas.packager_schema import PackagerSchema
|
||||
|
||||
|
||||
class RollbackSchema(PackagerSchema):
|
||||
"""
|
||||
request schema for package rollback
|
||||
"""
|
||||
|
||||
hold = fields.Boolean(dump_default=True, metadata={
|
||||
"description": "Hold package after rollback",
|
||||
})
|
||||
package = fields.String(required=True, metadata={
|
||||
"description": "Package name",
|
||||
"example": "ahriman",
|
||||
})
|
||||
version = fields.String(required=True, metadata={
|
||||
"description": "Package version",
|
||||
"example": __version__,
|
||||
})
|
||||
@@ -1,35 +0,0 @@
|
||||
#
|
||||
# Copyright (c) 2021-2026 ahriman team.
|
||||
#
|
||||
# This file is part of ahriman
|
||||
# (see https://github.com/arcan1s/ahriman).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
from ahriman.models.event import EventType
|
||||
from ahriman.web.apispec import Schema, fields
|
||||
|
||||
|
||||
class SSESchema(Schema):
|
||||
"""
|
||||
response SSE schema
|
||||
"""
|
||||
|
||||
event = fields.String(required=True, metadata={
|
||||
"description": "Event type",
|
||||
"example": EventType.PackageUpdated,
|
||||
})
|
||||
data = fields.Dict(keys=fields.String(), values=fields.Raw(), metadata={
|
||||
"description": "Event data",
|
||||
})
|
||||
@@ -1,164 +0,0 @@
|
||||
#
|
||||
# Copyright (c) 2021-2026 ahriman team.
|
||||
#
|
||||
# This file is part of ahriman
|
||||
# (see https://github.com/arcan1s/ahriman).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
import json
|
||||
|
||||
from aiohttp.web import HTTPBadRequest, Request, Response, StreamResponse
|
||||
from aiohttp_sse import EventSourceResponse, sse_response
|
||||
from asyncio import Queue, QueueShutDown, wait_for
|
||||
from typing import ClassVar
|
||||
|
||||
from ahriman.core.status.event_bus import SSEvent
|
||||
from ahriman.models.event import EventType
|
||||
from ahriman.models.user_access import UserAccess
|
||||
from ahriman.web.apispec.decorators import apidocs
|
||||
from ahriman.web.schemas import EventBusFilterSchema, SSESchema
|
||||
from ahriman.web.views.base import BaseView
|
||||
|
||||
|
||||
class EventBusView(BaseView):
|
||||
"""
|
||||
event bus SSE view
|
||||
|
||||
Attributes:
|
||||
READ_EVENTS(set[EventType]): (class attribute) events which are allowed for read-only users
|
||||
"""
|
||||
|
||||
READ_EVENTS: ClassVar[set[EventType]] = {
|
||||
EventType.PackageHeld,
|
||||
EventType.PackageOutdated,
|
||||
EventType.PackageRemoved,
|
||||
EventType.PackageStatusChanged,
|
||||
EventType.PackageUpdateFailed,
|
||||
EventType.PackageUpdated,
|
||||
EventType.ServiceStatusChanged,
|
||||
}
|
||||
ROUTES = ["/api/v1/events/stream"]
|
||||
|
||||
@classmethod
|
||||
async def get_permission(cls, request: Request) -> UserAccess:
|
||||
"""
|
||||
retrieve user permission from the request
|
||||
|
||||
Args:
|
||||
request(Request): request object
|
||||
|
||||
Returns:
|
||||
UserAccess: extracted permission
|
||||
"""
|
||||
if request.method.upper() not in ("GET", "HEAD"):
|
||||
return await BaseView.get_permission(request)
|
||||
|
||||
permission = UserAccess.Full
|
||||
try:
|
||||
topics = cls(request)._topics()
|
||||
except HTTPBadRequest:
|
||||
topics = None
|
||||
|
||||
if topics is not None and set(topics).issubset(cls.READ_EVENTS):
|
||||
permission = UserAccess.Read
|
||||
|
||||
return permission
|
||||
|
||||
@staticmethod
|
||||
async def _run(response: EventSourceResponse, queue: Queue[SSEvent]) -> None:
|
||||
"""
|
||||
read events from queue and send them to the client
|
||||
|
||||
Args:
|
||||
response(EventSourceResponse): SSE response instance
|
||||
queue(Queue[SSEvent]): subscriber queue
|
||||
"""
|
||||
while response.is_connected():
|
||||
try:
|
||||
event_type, data = await wait_for(queue.get(), timeout=response.ping_interval)
|
||||
except TimeoutError:
|
||||
continue
|
||||
except QueueShutDown:
|
||||
break
|
||||
|
||||
await response.send(json.dumps(data), event=event_type)
|
||||
|
||||
def _topics(self) -> list[EventType] | None:
|
||||
"""
|
||||
parse event filter from request query
|
||||
|
||||
Returns:
|
||||
list[EventType] | None: event filter if any
|
||||
|
||||
Raises:
|
||||
HTTPBadRequest: if invalid event type is supplied
|
||||
"""
|
||||
if self.request.query is None:
|
||||
return None
|
||||
|
||||
try:
|
||||
return [EventType(event) for event in self.request.query.getall("event", [])] or None
|
||||
except ValueError as ex:
|
||||
raise HTTPBadRequest(reason=str(ex))
|
||||
|
||||
@apidocs(
|
||||
tags=["Audit log"],
|
||||
summary="Live updates",
|
||||
description="Stream live updates via SSE. Read-only users may subscribe only when all requested event filters "
|
||||
"belong to read-safe package and service status events; build log or unfiltered streams require "
|
||||
"full access. Streams are live-only and do not replay missed events after reconnect.",
|
||||
permission=UserAccess.Full,
|
||||
error_400_enabled=True,
|
||||
error_404_description="Repository is unknown",
|
||||
schema=SSESchema(many=True),
|
||||
query_schema=EventBusFilterSchema,
|
||||
)
|
||||
async def get(self) -> StreamResponse:
|
||||
"""
|
||||
subscribe on updates
|
||||
|
||||
Returns:
|
||||
StreamResponse: 200 with streaming updates
|
||||
"""
|
||||
topics = self._topics()
|
||||
object_id = self.request.query.get("object_id")
|
||||
event_bus = self.service().event_bus
|
||||
|
||||
async with sse_response(self.request) as response:
|
||||
subscription_id, queue = await event_bus.subscribe(topics, object_id=object_id)
|
||||
|
||||
try:
|
||||
await self._run(response, queue)
|
||||
except (ConnectionResetError, QueueShutDown):
|
||||
pass
|
||||
finally:
|
||||
await event_bus.unsubscribe(subscription_id)
|
||||
|
||||
return response
|
||||
|
||||
async def head(self) -> StreamResponse:
|
||||
"""
|
||||
HEAD method implementation based on the result of GET method
|
||||
|
||||
Returns:
|
||||
StreamResponse: generated response for the request
|
||||
"""
|
||||
self._topics()
|
||||
self.service()
|
||||
|
||||
return Response(headers={
|
||||
"Cache-Control": "no-cache",
|
||||
"Content-Type": "text/event-stream",
|
||||
})
|
||||
@@ -1,65 +0,0 @@
|
||||
#
|
||||
# Copyright (c) 2021-2026 ahriman team.
|
||||
#
|
||||
# This file is part of ahriman
|
||||
# (see https://github.com/arcan1s/ahriman).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
from aiohttp.web import Response
|
||||
from typing import ClassVar
|
||||
|
||||
from ahriman.models.user_access import UserAccess
|
||||
from ahriman.web.apispec.decorators import apidocs
|
||||
from ahriman.web.schemas import PackageNameSchema, PackageSchema, RepositoryIdSchema
|
||||
from ahriman.web.views.base import BaseView
|
||||
from ahriman.web.views.status_view_guard import StatusViewGuard
|
||||
|
||||
|
||||
class Archives(StatusViewGuard, BaseView):
|
||||
"""
|
||||
package archives web view
|
||||
|
||||
Attributes:
|
||||
GET_PERMISSION(UserAccess): (class attribute) get permissions of self
|
||||
"""
|
||||
|
||||
GET_PERMISSION: ClassVar[UserAccess] = UserAccess.Reporter
|
||||
ROUTES = ["/api/v1/packages/{package}/archives"]
|
||||
|
||||
@apidocs(
|
||||
tags=["Packages"],
|
||||
summary="Get package archives",
|
||||
description="Retrieve built package archives for the base",
|
||||
permission=GET_PERMISSION,
|
||||
error_404_description="Package base and/or repository are unknown",
|
||||
schema=PackageSchema(many=True),
|
||||
match_schema=PackageNameSchema,
|
||||
query_schema=RepositoryIdSchema,
|
||||
)
|
||||
async def get(self) -> Response:
|
||||
"""
|
||||
get package archives
|
||||
|
||||
Returns:
|
||||
Response: 200 with package archives on success
|
||||
|
||||
Raises:
|
||||
HTTPNotFound: if no package was found
|
||||
"""
|
||||
package_base = self.request.match_info["package"]
|
||||
|
||||
archives = await self.service(package_base=package_base).package_archives(package_base)
|
||||
|
||||
return self.json_response([archive.view() for archive in archives])
|
||||
@@ -1,75 +0,0 @@
|
||||
#
|
||||
# Copyright (c) 2021-2026 ahriman team.
|
||||
#
|
||||
# This file is part of ahriman
|
||||
# (see https://github.com/arcan1s/ahriman).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
from aiohttp.web import HTTPBadRequest, HTTPNoContent, HTTPNotFound
|
||||
from typing import ClassVar
|
||||
|
||||
from ahriman.core.exceptions import UnknownPackageError
|
||||
from ahriman.models.user_access import UserAccess
|
||||
from ahriman.web.apispec.decorators import apidocs
|
||||
from ahriman.web.schemas import HoldSchema, PackageNameSchema, RepositoryIdSchema
|
||||
from ahriman.web.views.base import BaseView
|
||||
from ahriman.web.views.status_view_guard import StatusViewGuard
|
||||
|
||||
|
||||
class HoldView(StatusViewGuard, BaseView):
|
||||
"""
|
||||
package hold web view
|
||||
|
||||
Attributes:
|
||||
POST_PERMISSION(UserAccess): (class attribute) post permissions of self
|
||||
"""
|
||||
|
||||
POST_PERMISSION: ClassVar[UserAccess] = UserAccess.Full
|
||||
ROUTES = ["/api/v1/packages/{package}/hold"]
|
||||
|
||||
@apidocs(
|
||||
tags=["Packages"],
|
||||
summary="Update package hold status",
|
||||
description="Set package hold status",
|
||||
permission=POST_PERMISSION,
|
||||
error_400_enabled=True,
|
||||
error_404_description="Package base and/or repository are unknown",
|
||||
match_schema=PackageNameSchema,
|
||||
query_schema=RepositoryIdSchema,
|
||||
body_schema=HoldSchema,
|
||||
)
|
||||
async def post(self) -> None:
|
||||
"""
|
||||
update package hold status
|
||||
|
||||
Raises:
|
||||
HTTPBadRequest: if bad data is supplied
|
||||
HTTPNoContent: in case of success response
|
||||
HTTPNotFound: if no package was found
|
||||
"""
|
||||
package_base = self.request.match_info["package"]
|
||||
|
||||
try:
|
||||
data = await self.request.json()
|
||||
is_held = data["is_held"]
|
||||
except Exception as ex:
|
||||
raise HTTPBadRequest(reason=str(ex))
|
||||
|
||||
try:
|
||||
await self.service().package_hold_update(package_base, enabled=is_held)
|
||||
except UnknownPackageError:
|
||||
raise HTTPNotFound(reason=f"Package {package_base} is unknown")
|
||||
|
||||
raise HTTPNoContent
|
||||
@@ -1,77 +0,0 @@
|
||||
#
|
||||
# Copyright (c) 2021-2026 ahriman team.
|
||||
#
|
||||
# This file is part of ahriman
|
||||
# (see https://github.com/arcan1s/ahriman).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
from aiohttp.web import HTTPBadRequest, Response
|
||||
from typing import ClassVar
|
||||
|
||||
from ahriman.models.user_access import UserAccess
|
||||
from ahriman.web.apispec.decorators import apidocs
|
||||
from ahriman.web.schemas import ProcessIdSchema, RepositoryIdSchema, RollbackSchema
|
||||
from ahriman.web.views.base import BaseView
|
||||
|
||||
|
||||
class RollbackView(BaseView):
|
||||
"""
|
||||
package rollback web view
|
||||
|
||||
Attributes:
|
||||
POST_PERMISSION(UserAccess): (class attribute) post permissions of self
|
||||
"""
|
||||
|
||||
POST_PERMISSION: ClassVar[UserAccess] = UserAccess.Full
|
||||
ROUTES = ["/api/v1/service/rollback"]
|
||||
|
||||
@apidocs(
|
||||
tags=["Actions"],
|
||||
summary="Rollback package",
|
||||
description="Rollback package to specified version",
|
||||
permission=POST_PERMISSION,
|
||||
error_400_enabled=True,
|
||||
schema=ProcessIdSchema,
|
||||
query_schema=RepositoryIdSchema,
|
||||
body_schema=RollbackSchema,
|
||||
)
|
||||
async def post(self) -> Response:
|
||||
"""
|
||||
run package rollback
|
||||
|
||||
Returns:
|
||||
Response: 200 with spawned process id
|
||||
|
||||
Raises:
|
||||
HTTPBadRequest: if bad data is supplied
|
||||
"""
|
||||
try:
|
||||
data = await self.request.json()
|
||||
package = self.get_non_empty(lambda key: data[key], "package")
|
||||
version = self.get_non_empty(lambda key: data[key], "version")
|
||||
except Exception as ex:
|
||||
raise HTTPBadRequest(reason=str(ex))
|
||||
|
||||
repository_id = self.repository_id()
|
||||
username = await self.username()
|
||||
process_id = self.spawner.packages_rollback(
|
||||
repository_id,
|
||||
package,
|
||||
version,
|
||||
username,
|
||||
hold=data.get("hold", True),
|
||||
)
|
||||
|
||||
return self.json_response({"process_id": process_id})
|
||||
@@ -1,19 +0,0 @@
|
||||
#
|
||||
# Copyright (c) 2021-2026 ahriman team.
|
||||
#
|
||||
# This file is part of ahriman
|
||||
# (see https://github.com/arcan1s/ahriman).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
@@ -1,85 +0,0 @@
|
||||
import hashlib
|
||||
import pytest
|
||||
|
||||
from aiohttp import ETag
|
||||
from aiohttp.web import HTTPNotModified, Response, StreamResponse
|
||||
from unittest.mock import AsyncMock
|
||||
|
||||
from ahriman.web.middlewares.etag_handler import etag_handler
|
||||
|
||||
|
||||
async def test_etag_handler() -> None:
|
||||
"""
|
||||
must set ETag header on GET responses
|
||||
"""
|
||||
request = pytest.helpers.request("", "", "GET")
|
||||
request.if_none_match = None
|
||||
request_handler = AsyncMock(return_value=Response(body=b"hello"))
|
||||
|
||||
handler = etag_handler()
|
||||
result = await handler(request, request_handler)
|
||||
assert result.etag is not None
|
||||
|
||||
|
||||
async def test_etag_handler_not_modified() -> None:
|
||||
"""
|
||||
must raise NotModified when ETag matches If-None-Match
|
||||
"""
|
||||
body = b"hello"
|
||||
request = pytest.helpers.request("", "", "GET")
|
||||
request.if_none_match = (ETag(value=hashlib.md5(body, usedforsecurity=False).hexdigest()),)
|
||||
request_handler = AsyncMock(return_value=Response(body=body))
|
||||
|
||||
handler = etag_handler()
|
||||
with pytest.raises(HTTPNotModified):
|
||||
await handler(request, request_handler)
|
||||
|
||||
|
||||
async def test_etag_handler_no_match() -> None:
|
||||
"""
|
||||
must return full response when ETag does not match If-None-Match
|
||||
"""
|
||||
request = pytest.helpers.request("", "", "GET")
|
||||
request.if_none_match = (ETag(value="outdated"),)
|
||||
request_handler = AsyncMock(return_value=Response(body=b"hello"))
|
||||
|
||||
handler = etag_handler()
|
||||
result = await handler(request, request_handler)
|
||||
assert result.status == 200
|
||||
assert result.etag is not None
|
||||
|
||||
|
||||
async def test_etag_handler_skip_post() -> None:
|
||||
"""
|
||||
must skip ETag for non-GET/HEAD methods
|
||||
"""
|
||||
request = pytest.helpers.request("", "", "POST")
|
||||
request_handler = AsyncMock(return_value=Response(body=b"hello"))
|
||||
|
||||
handler = etag_handler()
|
||||
result = await handler(request, request_handler)
|
||||
assert result.etag is None
|
||||
|
||||
|
||||
async def test_etag_handler_skip_no_body() -> None:
|
||||
"""
|
||||
must skip ETag for responses without body
|
||||
"""
|
||||
request = pytest.helpers.request("", "", "GET")
|
||||
request_handler = AsyncMock(return_value=Response())
|
||||
|
||||
handler = etag_handler()
|
||||
result = await handler(request, request_handler)
|
||||
assert result.etag is None
|
||||
|
||||
|
||||
async def test_etag_handler_skip_stream() -> None:
|
||||
"""
|
||||
must skip ETag for streaming responses
|
||||
"""
|
||||
request = pytest.helpers.request("", "", "GET")
|
||||
request_handler = AsyncMock(return_value=StreamResponse())
|
||||
|
||||
handler = etag_handler()
|
||||
result = await handler(request, request_handler)
|
||||
assert "ETag" not in result.headers
|
||||
@@ -1,43 +0,0 @@
|
||||
import logging
|
||||
import pytest
|
||||
|
||||
from unittest.mock import AsyncMock, MagicMock
|
||||
from typing import Any
|
||||
|
||||
from ahriman.web.middlewares.request_id_handler import request_id_handler
|
||||
|
||||
|
||||
async def test_request_id_handler() -> None:
|
||||
"""
|
||||
must use request id from request if available
|
||||
"""
|
||||
request = pytest.helpers.request("", "", "")
|
||||
request.headers = MagicMock()
|
||||
request.headers.getone.return_value = "request_id"
|
||||
|
||||
response = MagicMock()
|
||||
response.headers = {}
|
||||
|
||||
async def check_handler(_: Any) -> MagicMock:
|
||||
record = logging.makeLogRecord({})
|
||||
assert record.request_id == "request_id"
|
||||
return response
|
||||
|
||||
handler = request_id_handler()
|
||||
await handler(request, check_handler)
|
||||
assert response.headers["X-Request-ID"] == "request_id"
|
||||
|
||||
|
||||
async def test_request_id_handler_generate() -> None:
|
||||
"""
|
||||
must generate request id and set it in response header
|
||||
"""
|
||||
request = pytest.helpers.request("", "", "")
|
||||
|
||||
response = MagicMock()
|
||||
response.headers = {}
|
||||
request_handler = AsyncMock(return_value=response)
|
||||
|
||||
handler = request_id_handler()
|
||||
await handler(request, request_handler)
|
||||
assert "X-Request-ID" in response.headers
|
||||
@@ -1 +0,0 @@
|
||||
# schema testing goes in view class tests
|
||||
@@ -1 +0,0 @@
|
||||
# schema testing goes in view class tests
|
||||
@@ -1 +0,0 @@
|
||||
# schema testing goes in view class tests
|
||||
@@ -1 +0,0 @@
|
||||
# schema testing goes in view class tests
|
||||
@@ -1 +0,0 @@
|
||||
# schema testing goes in view class tests
|
||||
@@ -1,55 +0,0 @@
|
||||
import aiohttp_cors
|
||||
import pytest
|
||||
|
||||
from aiohttp.web import Application
|
||||
from pytest_mock import MockerFixture
|
||||
|
||||
from ahriman.web.cors import setup_cors
|
||||
from ahriman.web.keys import ConfigurationKey
|
||||
|
||||
|
||||
def test_setup_cors(application: Application) -> None:
|
||||
"""
|
||||
must setup CORS
|
||||
"""
|
||||
cors = application[aiohttp_cors.APP_CONFIG_KEY]
|
||||
# let's test here that it is enabled for all requests
|
||||
for route in application.router.routes():
|
||||
# we don't want to deal with match info here though
|
||||
try:
|
||||
url = route.url_for()
|
||||
except (KeyError, TypeError):
|
||||
continue
|
||||
request = pytest.helpers.request(application, url, route.method, resource=route.resource)
|
||||
assert cors._cors_impl._router_adapter.is_cors_enabled_on_request(request)
|
||||
|
||||
|
||||
def test_setup_cors_custom_origins(application: Application, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must setup CORS with custom origins
|
||||
"""
|
||||
configuration = application[ConfigurationKey]
|
||||
configuration.set_option("web", "cors_allow_origins", "https://example.com https://httpbin.com")
|
||||
|
||||
setup_mock = mocker.patch("ahriman.web.cors.aiohttp_cors.setup", return_value=mocker.MagicMock())
|
||||
setup_cors(application, configuration)
|
||||
|
||||
defaults = setup_mock.call_args.kwargs["defaults"]
|
||||
assert "https://example.com" in defaults
|
||||
assert "https://httpbin.com" in defaults
|
||||
assert "*" not in defaults
|
||||
|
||||
|
||||
def test_setup_cors_custom_methods(application: Application, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must setup CORS with custom methods
|
||||
"""
|
||||
configuration = application[ConfigurationKey]
|
||||
configuration.set_option("web", "cors_allow_methods", "GET POST")
|
||||
|
||||
setup_mock = mocker.patch("ahriman.web.cors.aiohttp_cors.setup", return_value=mocker.MagicMock())
|
||||
setup_cors(application, configuration)
|
||||
|
||||
defaults = setup_mock.call_args.kwargs["defaults"]
|
||||
resource_options = next(iter(defaults.values()))
|
||||
assert resource_options.allow_methods == {"GET", "POST"}
|
||||
@@ -1,254 +0,0 @@
|
||||
import asyncio
|
||||
import pytest
|
||||
|
||||
from aiohttp.test_utils import TestClient
|
||||
from aiohttp.web import HTTPBadRequest
|
||||
from asyncio import Queue
|
||||
from multidict import MultiDict
|
||||
from pytest_mock import MockerFixture
|
||||
from unittest.mock import AsyncMock
|
||||
|
||||
from ahriman.core.status.watcher import Watcher
|
||||
from ahriman.models.event import EventType
|
||||
from ahriman.models.package import Package
|
||||
from ahriman.models.user_access import UserAccess
|
||||
from ahriman.web.keys import WatcherKey
|
||||
from ahriman.web.views.base import BaseView
|
||||
from ahriman.web.views.v1.auditlog.event_bus import EventBusView
|
||||
|
||||
|
||||
async def _producer(watcher: Watcher, package_ahriman: Package) -> None:
|
||||
"""
|
||||
create producer
|
||||
|
||||
Args:
|
||||
watcher(Watcher): watcher test instance
|
||||
package_ahriman(Package): package test instance
|
||||
"""
|
||||
await asyncio.sleep(0.1)
|
||||
await watcher.event_bus.broadcast(EventType.PackageRemoved, package_ahriman.base)
|
||||
await watcher.event_bus.broadcast(EventType.PackageUpdated, package_ahriman.base, status="success")
|
||||
await asyncio.sleep(0.1)
|
||||
await watcher.event_bus.shutdown()
|
||||
|
||||
|
||||
async def test_get_permission() -> None:
|
||||
"""
|
||||
must return correct permission for the request
|
||||
"""
|
||||
for method in ("GET",):
|
||||
request = pytest.helpers.request("", "", method)
|
||||
assert await EventBusView.get_permission(request) == UserAccess.Full
|
||||
|
||||
|
||||
async def test_get_permission_build_log() -> None:
|
||||
"""
|
||||
must return full permission for build log stream
|
||||
"""
|
||||
request = pytest.helpers.request("", "", "GET", params=MultiDict(event=EventType.BuildLog))
|
||||
assert await EventBusView.get_permission(request) == UserAccess.Full
|
||||
|
||||
|
||||
async def test_get_permission_build_log_with_read_events() -> None:
|
||||
"""
|
||||
must return full permission for mixed build log and read event stream
|
||||
"""
|
||||
request = pytest.helpers.request("", "", "GET", params=MultiDict([
|
||||
("event", EventType.BuildLog),
|
||||
("event", EventType.PackageUpdated),
|
||||
]))
|
||||
assert await EventBusView.get_permission(request) == UserAccess.Full
|
||||
|
||||
|
||||
async def test_get_permission_invalid_event() -> None:
|
||||
"""
|
||||
must return full permission for invalid event type
|
||||
"""
|
||||
request = pytest.helpers.request("", "", "GET", params=MultiDict(event="invalid"))
|
||||
assert await EventBusView.get_permission(request) == UserAccess.Full
|
||||
|
||||
|
||||
async def test_get_permission_post() -> None:
|
||||
"""
|
||||
must use default permission for non-get requests
|
||||
"""
|
||||
request = pytest.helpers.request("", "", "POST", params=MultiDict(event=EventType.PackageUpdated))
|
||||
assert await EventBusView.get_permission(request) == await BaseView.get_permission(request)
|
||||
|
||||
|
||||
async def test_get_permission_read_events() -> None:
|
||||
"""
|
||||
must return read permission for package and status streams
|
||||
"""
|
||||
request = pytest.helpers.request("", "", "GET", params=MultiDict(
|
||||
("event", event_type) for event_type in EventBusView.READ_EVENTS
|
||||
))
|
||||
assert await EventBusView.get_permission(request) == UserAccess.Read
|
||||
|
||||
|
||||
def test_routes() -> None:
|
||||
"""
|
||||
must return correct routes
|
||||
"""
|
||||
assert EventBusView.ROUTES == ["/api/v1/events/stream"]
|
||||
|
||||
|
||||
async def test_run_timeout() -> None:
|
||||
"""
|
||||
must handle timeout and continue loop
|
||||
"""
|
||||
queue = Queue()
|
||||
|
||||
async def _shutdown() -> None:
|
||||
await asyncio.sleep(0.05)
|
||||
queue.shutdown()
|
||||
|
||||
response = AsyncMock()
|
||||
response.is_connected = lambda: True
|
||||
response.ping_interval = 0.01
|
||||
|
||||
asyncio.create_task(_shutdown())
|
||||
await EventBusView._run(response, queue)
|
||||
|
||||
|
||||
def test_topics() -> None:
|
||||
"""
|
||||
must parse event filters
|
||||
"""
|
||||
request = pytest.helpers.request("", "", "GET", params=MultiDict([
|
||||
("event", EventType.PackageUpdated),
|
||||
("event", EventType.PackageRemoved),
|
||||
]))
|
||||
|
||||
assert EventBusView(request)._topics() == [EventType.PackageUpdated, EventType.PackageRemoved]
|
||||
|
||||
|
||||
def test_topics_empty() -> None:
|
||||
"""
|
||||
must return None for missing event filters
|
||||
"""
|
||||
request = pytest.helpers.request("", "", "GET", params=MultiDict())
|
||||
|
||||
assert EventBusView(request)._topics() is None
|
||||
|
||||
|
||||
def test_topics_invalid() -> None:
|
||||
"""
|
||||
must raise bad request for invalid event filters
|
||||
"""
|
||||
request = pytest.helpers.request("", "", "GET", params=MultiDict(event="invalid"))
|
||||
|
||||
with pytest.raises(HTTPBadRequest):
|
||||
EventBusView(request)._topics()
|
||||
|
||||
|
||||
async def test_get(client: TestClient, package_ahriman: Package) -> None:
|
||||
"""
|
||||
must stream events via SSE
|
||||
"""
|
||||
watcher = next(iter(client.app[WatcherKey].values()))
|
||||
asyncio.create_task(_producer(watcher, package_ahriman))
|
||||
request_schema = pytest.helpers.schema_request(EventBusView.get, location="querystring")
|
||||
# no content validation here because it is a streaming response
|
||||
|
||||
assert not request_schema.validate({})
|
||||
response = await client.get("/api/v1/events/stream")
|
||||
assert response.status == 200
|
||||
|
||||
body = await response.text()
|
||||
assert EventType.PackageUpdated in body
|
||||
assert "ahriman" in body
|
||||
|
||||
|
||||
async def test_get_with_topic_filter(client: TestClient, package_ahriman: Package) -> None:
|
||||
"""
|
||||
must filter events by topic
|
||||
"""
|
||||
watcher = next(iter(client.app[WatcherKey].values()))
|
||||
asyncio.create_task(_producer(watcher, package_ahriman))
|
||||
request_schema = pytest.helpers.schema_request(EventBusView.get, location="querystring")
|
||||
|
||||
payload = {"event": [EventType.PackageUpdated]}
|
||||
assert not request_schema.validate(payload)
|
||||
response = await client.get("/api/v1/events/stream", params=payload)
|
||||
assert response.status == 200
|
||||
|
||||
body = await response.text()
|
||||
assert EventType.PackageUpdated in body
|
||||
assert EventType.PackageRemoved not in body
|
||||
|
||||
|
||||
async def test_get_with_object_id_filter(client: TestClient, package_ahriman: Package) -> None:
|
||||
"""
|
||||
must filter events by object_id
|
||||
"""
|
||||
watcher = next(iter(client.app[WatcherKey].values()))
|
||||
asyncio.create_task(_producer(watcher, package_ahriman))
|
||||
request_schema = pytest.helpers.schema_request(EventBusView.get, location="querystring")
|
||||
|
||||
payload = {"object_id": "non-existent-package"}
|
||||
assert not request_schema.validate(payload)
|
||||
response = await client.get("/api/v1/events/stream", params=payload)
|
||||
assert response.status == 200
|
||||
|
||||
body = await response.text()
|
||||
assert "ahriman" not in body
|
||||
|
||||
|
||||
async def test_get_bad_request(client: TestClient) -> None:
|
||||
"""
|
||||
must return bad request for invalid event type
|
||||
"""
|
||||
response_schema = pytest.helpers.schema_response(EventBusView.get, code=400)
|
||||
|
||||
response = await client.get("/api/v1/events/stream", params={"event": "invalid"})
|
||||
assert response.status == 400
|
||||
assert not response_schema.validate(await response.json())
|
||||
|
||||
|
||||
async def test_get_not_found(client: TestClient) -> None:
|
||||
"""
|
||||
must return not found for unknown repository
|
||||
"""
|
||||
response_schema = pytest.helpers.schema_response(EventBusView.get, code=404)
|
||||
|
||||
response = await client.get("/api/v1/events/stream", params={"architecture": "unknown", "repository": "unknown"})
|
||||
assert response.status == 404
|
||||
assert not response_schema.validate(await response.json())
|
||||
|
||||
|
||||
async def test_get_connection_reset(client: TestClient, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must handle connection reset
|
||||
"""
|
||||
mocker.patch.object(EventBusView, "_run", side_effect=ConnectionResetError)
|
||||
response = await client.get("/api/v1/events/stream")
|
||||
assert response.status == 200
|
||||
|
||||
|
||||
async def test_head(client: TestClient) -> None:
|
||||
"""
|
||||
must check stream availability without opening SSE stream
|
||||
"""
|
||||
response = await client.head("/api/v1/events/stream", params={"event": EventType.PackageUpdated})
|
||||
assert response.status == 200
|
||||
assert response.headers["Content-Type"] == "text/event-stream"
|
||||
assert not await response.text()
|
||||
|
||||
|
||||
async def test_head_bad_request(client: TestClient) -> None:
|
||||
"""
|
||||
must return bad request for invalid event type
|
||||
"""
|
||||
response = await client.head("/api/v1/events/stream", params={"event": "invalid"})
|
||||
assert response.status == 400
|
||||
assert not await response.text()
|
||||
|
||||
|
||||
async def test_head_not_found(client: TestClient) -> None:
|
||||
"""
|
||||
must return not found for unknown repository
|
||||
"""
|
||||
response = await client.head("/api/v1/events/stream", params={"architecture": "unknown", "repository": "unknown"})
|
||||
assert response.status == 404
|
||||
assert not await response.text()
|
||||
@@ -1,52 +0,0 @@
|
||||
import pytest
|
||||
|
||||
from aiohttp.test_utils import TestClient
|
||||
from pytest_mock import MockerFixture
|
||||
|
||||
from ahriman.models.build_status import BuildStatusEnum
|
||||
from ahriman.models.package import Package
|
||||
from ahriman.models.user_access import UserAccess
|
||||
from ahriman.web.views.v1.packages.archives import Archives
|
||||
|
||||
|
||||
async def test_get_permission() -> None:
|
||||
"""
|
||||
must return correct permission for the request
|
||||
"""
|
||||
for method in ("GET",):
|
||||
request = pytest.helpers.request("", "", method)
|
||||
assert await Archives.get_permission(request) == UserAccess.Reporter
|
||||
|
||||
|
||||
def test_routes() -> None:
|
||||
"""
|
||||
must return correct routes
|
||||
"""
|
||||
assert Archives.ROUTES == ["/api/v1/packages/{package}/archives"]
|
||||
|
||||
|
||||
async def test_get(client: TestClient, package_ahriman: Package, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must get archives for package
|
||||
"""
|
||||
await client.post(f"/api/v1/packages/{package_ahriman.base}",
|
||||
json={"status": BuildStatusEnum.Success.value, "package": package_ahriman.view()})
|
||||
mocker.patch("ahriman.core.status.watcher.Watcher.package_archives", return_value=[package_ahriman])
|
||||
response_schema = pytest.helpers.schema_response(Archives.get)
|
||||
|
||||
response = await client.get(f"/api/v1/packages/{package_ahriman.base}/archives")
|
||||
assert response.status == 200
|
||||
|
||||
archives = await response.json()
|
||||
assert not response_schema.validate(archives)
|
||||
|
||||
|
||||
async def test_get_not_found(client: TestClient, package_ahriman: Package) -> None:
|
||||
"""
|
||||
must return not found for missing package
|
||||
"""
|
||||
response_schema = pytest.helpers.schema_response(Archives.get, code=404)
|
||||
|
||||
response = await client.get(f"/api/v1/packages/{package_ahriman.base}/archives")
|
||||
assert response.status == 404
|
||||
assert not response_schema.validate(await response.json())
|
||||
@@ -1,60 +0,0 @@
|
||||
import pytest
|
||||
|
||||
from aiohttp.test_utils import TestClient
|
||||
|
||||
from ahriman.models.build_status import BuildStatusEnum
|
||||
from ahriman.models.package import Package
|
||||
from ahriman.models.user_access import UserAccess
|
||||
from ahriman.web.views.v1.packages.hold import HoldView
|
||||
|
||||
|
||||
async def test_get_permission() -> None:
|
||||
"""
|
||||
must return correct permission for the request
|
||||
"""
|
||||
for method in ("POST",):
|
||||
request = pytest.helpers.request("", "", method)
|
||||
assert await HoldView.get_permission(request) == UserAccess.Full
|
||||
|
||||
|
||||
def test_routes() -> None:
|
||||
"""
|
||||
must return correct routes
|
||||
"""
|
||||
assert HoldView.ROUTES == ["/api/v1/packages/{package}/hold"]
|
||||
|
||||
|
||||
async def test_post(client: TestClient, package_ahriman: Package) -> None:
|
||||
"""
|
||||
must update package hold status
|
||||
"""
|
||||
await client.post(f"/api/v1/packages/{package_ahriman.base}",
|
||||
json={"status": BuildStatusEnum.Success.value, "package": package_ahriman.view()})
|
||||
request_schema = pytest.helpers.schema_request(HoldView.post)
|
||||
|
||||
payload = {"is_held": True}
|
||||
assert not request_schema.validate(payload)
|
||||
response = await client.post(f"/api/v1/packages/{package_ahriman.base}/hold", json=payload)
|
||||
assert response.status == 204
|
||||
|
||||
|
||||
async def test_post_not_found(client: TestClient, package_ahriman: Package) -> None:
|
||||
"""
|
||||
must return Not Found for unknown package
|
||||
"""
|
||||
response_schema = pytest.helpers.schema_response(HoldView.post, code=404)
|
||||
|
||||
response = await client.post(f"/api/v1/packages/{package_ahriman.base}/hold", json={"is_held": False})
|
||||
assert response.status == 404
|
||||
assert not response_schema.validate(await response.json())
|
||||
|
||||
|
||||
async def test_post_exception(client: TestClient, package_ahriman: Package) -> None:
|
||||
"""
|
||||
must raise exception on invalid payload
|
||||
"""
|
||||
response_schema = pytest.helpers.schema_response(HoldView.post, code=400)
|
||||
|
||||
response = await client.post(f"/api/v1/packages/{package_ahriman.base}/hold", json=[])
|
||||
assert response.status == 400
|
||||
assert not response_schema.validate(await response.json())
|
||||
@@ -1,70 +0,0 @@
|
||||
import pytest
|
||||
|
||||
from aiohttp.test_utils import TestClient
|
||||
from pytest_mock import MockerFixture
|
||||
from unittest.mock import AsyncMock
|
||||
|
||||
from ahriman.models.repository_id import RepositoryId
|
||||
from ahriman.models.user_access import UserAccess
|
||||
from ahriman.web.views.v1.service.rollback import RollbackView
|
||||
|
||||
|
||||
async def test_get_permission() -> None:
|
||||
"""
|
||||
must return correct permission for the request
|
||||
"""
|
||||
for method in ("POST",):
|
||||
request = pytest.helpers.request("", "", method)
|
||||
assert await RollbackView.get_permission(request) == UserAccess.Full
|
||||
|
||||
|
||||
def test_routes() -> None:
|
||||
"""
|
||||
must return correct routes
|
||||
"""
|
||||
assert RollbackView.ROUTES == ["/api/v1/service/rollback"]
|
||||
|
||||
|
||||
async def test_post(client: TestClient, repository_id: RepositoryId, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must call post request correctly
|
||||
"""
|
||||
rollback_mock = mocker.patch("ahriman.core.spawn.Spawn.packages_rollback", return_value="abc")
|
||||
user_mock = AsyncMock()
|
||||
user_mock.return_value = "username"
|
||||
mocker.patch("ahriman.web.views.base.BaseView.username", side_effect=user_mock)
|
||||
request_schema = pytest.helpers.schema_request(RollbackView.post)
|
||||
response_schema = pytest.helpers.schema_response(RollbackView.post)
|
||||
|
||||
payload = {"package": "ahriman", "version": "version"}
|
||||
assert not request_schema.validate(payload)
|
||||
response = await client.post("/api/v1/service/rollback", json=payload)
|
||||
assert response.ok
|
||||
rollback_mock.assert_called_once_with(repository_id, "ahriman", "version", "username", hold=True)
|
||||
|
||||
json = await response.json()
|
||||
assert json["process_id"] == "abc"
|
||||
assert not response_schema.validate(json)
|
||||
|
||||
|
||||
async def test_post_empty(client: TestClient, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must call raise 400 on empty request
|
||||
"""
|
||||
rollback_mock = mocker.patch("ahriman.core.spawn.Spawn.packages_rollback")
|
||||
response_schema = pytest.helpers.schema_response(RollbackView.post, code=400)
|
||||
|
||||
response = await client.post("/api/v1/service/rollback", json={"package": "", "version": "version"})
|
||||
assert response.status == 400
|
||||
assert not response_schema.validate(await response.json())
|
||||
rollback_mock.assert_not_called()
|
||||
|
||||
response = await client.post("/api/v1/service/rollback", json={"package": "ahriman", "version": ""})
|
||||
assert response.status == 400
|
||||
assert not response_schema.validate(await response.json())
|
||||
rollback_mock.assert_not_called()
|
||||
|
||||
response = await client.post("/api/v1/service/rollback", json={})
|
||||
assert response.status == 400
|
||||
assert not response_schema.validate(await response.json())
|
||||
rollback_mock.assert_not_called()
|
||||
@@ -1,18 +0,0 @@
|
||||
import pytest
|
||||
|
||||
from ahriman.core.auth import Auth
|
||||
from ahriman.core.configuration import Configuration
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def auth(configuration: Configuration) -> Auth:
|
||||
"""
|
||||
auth provider fixture
|
||||
|
||||
Args:
|
||||
configuration(Configuration): configuration fixture
|
||||
|
||||
Returns:
|
||||
Auth: auth service instance
|
||||
"""
|
||||
return Auth(configuration)
|
||||
+13
-14
@@ -1,15 +1,13 @@
|
||||
# build image
|
||||
FROM archlinux:base AS build
|
||||
|
||||
ARG BUILD_DATE
|
||||
|
||||
# install environment
|
||||
## create build user
|
||||
RUN useradd -m -d "/home/build" -s "/usr/bin/nologin" build
|
||||
|
||||
## extract container creation date and set mirror for this timestamp, set PKGEXT and refresh database next
|
||||
RUN echo "Server = https://archive.archlinux.org/repos/${BUILD_DATE//-/\/}/\$repo/os/\$arch" > "/etc/pacman.d/mirrorlist" && \
|
||||
pacman -Syyuu --noconfirm
|
||||
RUN echo "Server = https://archive.archlinux.org/repos/$(stat -c "%y" "/var/lib/pacman" | cut -d " " -f 1 | sed "s,-,/,g")/\$repo/os/\$arch" > "/etc/pacman.d/mirrorlist" && \
|
||||
pacman -Sy
|
||||
## setup package cache
|
||||
RUN runuser -u build -- mkdir "/tmp/pkg" && \
|
||||
echo "PKGDEST=/tmp/pkg" >> "/etc/makepkg.conf" && \
|
||||
@@ -31,16 +29,17 @@ RUN pacman -S --noconfirm --asdeps \
|
||||
python-filelock \
|
||||
python-inflection \
|
||||
python-pyelftools \
|
||||
python-requests
|
||||
RUN pacman -S --noconfirm --asdeps \
|
||||
python-requests \
|
||||
&& \
|
||||
pacman -S --noconfirm --asdeps \
|
||||
base-devel \
|
||||
python-build \
|
||||
python-hatchling \
|
||||
python-flit \
|
||||
python-installer \
|
||||
python-setuptools \
|
||||
python-tox \
|
||||
python-wheel
|
||||
RUN pacman -S --noconfirm --asdeps \
|
||||
python-wheel \
|
||||
&& \
|
||||
pacman -S --noconfirm --asdeps \
|
||||
git \
|
||||
python-aiohttp \
|
||||
python-aiohttp-openmetrics \
|
||||
@@ -49,8 +48,9 @@ RUN pacman -S --noconfirm --asdeps \
|
||||
python-cryptography \
|
||||
python-jinja \
|
||||
python-systemd \
|
||||
rsync
|
||||
RUN runuser -u build -- install-aur-package \
|
||||
rsync \
|
||||
&& \
|
||||
runuser -u build -- install-aur-package \
|
||||
python-aioauth-client \
|
||||
python-sphinx-typlog-theme \
|
||||
python-webargs \
|
||||
@@ -59,7 +59,6 @@ RUN runuser -u build -- install-aur-package \
|
||||
python-aiohttp-jinja2 \
|
||||
python-aiohttp-session \
|
||||
python-aiohttp-security \
|
||||
python-aiohttp-sse-git \
|
||||
python-requests-unixsocket2
|
||||
|
||||
# install ahriman
|
||||
@@ -110,7 +109,7 @@ RUN cp "/etc/pacman.d/mirrorlist" "/etc/pacman.d/mirrorlist.orig" && \
|
||||
echo "Server = file:///var/cache/pacman/pkg" > "/etc/pacman.d/mirrorlist" && \
|
||||
cp "/etc/pacman.conf" "/etc/pacman.conf.orig" && \
|
||||
sed -i "s/SigLevel *=.*/SigLevel = Optional/g" "/etc/pacman.conf" && \
|
||||
pacman -Syyuu --noconfirm
|
||||
pacman -Sy
|
||||
## install package and its optional dependencies
|
||||
RUN pacman -S --noconfirm ahriman
|
||||
RUN pacman -S --noconfirm --asdeps \
|
||||
|
||||
@@ -7,10 +7,8 @@ for PACKAGE in "$@"; do
|
||||
# clone the remote source
|
||||
git clone https://aur.archlinux.org/"$PACKAGE".git "$BUILD_DIR"
|
||||
cd "$BUILD_DIR"
|
||||
# FIXME monkey patch PKGBUILD for python
|
||||
sed -i 's/python -m build/python -m build --skip-dependency-check/g' "PKGBUILD"
|
||||
# checkout to the image date
|
||||
git checkout "$(git rev-list -1 --before="$BUILD_DATE" master)"
|
||||
git checkout "$(git rev-list -1 --before="$(stat -c "%y" "/var/lib/pacman" | cut -d " " -f 1)" master)"
|
||||
# build and install the package
|
||||
makepkg --nocheck --noconfirm --install --rmdeps --syncdeps
|
||||
cd /
|
||||
|
||||
Vendored
+41
-79
@@ -138,12 +138,11 @@ digraph G {
|
||||
ahriman_core_http [fillcolor="blue",fontcolor="white",label="ahriman\.\ncore\.\nhttp",shape="box"];
|
||||
ahriman_core_http_sync_ahriman_client [fillcolor="blue",fontcolor="white",label="ahriman\.\ncore\.\nhttp\.\nsync_ahriman_client",shape="box"];
|
||||
ahriman_core_http_sync_http_client [fillcolor="#933f24",fontcolor="#ffffff",label="ahriman\.\ncore\.\nhttp\.\nsync_http_client"];
|
||||
ahriman_core_log [fillcolor="blue",fontcolor="white",label="ahriman\.\ncore\.\nlog",shape="box"];
|
||||
ahriman_core_log [fillcolor="#e53b05",fontcolor="#ffffff",label="ahriman\.\ncore\.\nlog"];
|
||||
ahriman_core_log_http_log_handler [fillcolor="#914730",fontcolor="#ffffff",label="ahriman\.\ncore\.\nlog\.\nhttp_log_handler"];
|
||||
ahriman_core_log_journal_handler [fillcolor="#ac6149",fontcolor="#ffffff",label="ahriman\.\ncore\.\nlog\.\njournal_handler"];
|
||||
ahriman_core_log_lazy_logging [fillcolor="blue",fontcolor="white",label="ahriman\.\ncore\.\nlog\.\nlazy_logging",shape="box"];
|
||||
ahriman_core_log_log_context [fillcolor="#db582f",fontcolor="#ffffff",label="ahriman\.\ncore\.\nlog\.\nlog_context"];
|
||||
ahriman_core_log_log_loader [fillcolor="#7a3c28",fontcolor="#ffffff",label="ahriman\.\ncore\.\nlog\.\nlog_loader"];
|
||||
ahriman_core_log_lazy_logging [fillcolor="#b85a3d",fontcolor="#ffffff",label="ahriman\.\ncore\.\nlog\.\nlazy_logging"];
|
||||
ahriman_core_log_log_loader [fillcolor="#82402b",fontcolor="#ffffff",label="ahriman\.\ncore\.\nlog\.\nlog_loader"];
|
||||
ahriman_core_module_loader [fillcolor="#ce5e3b",fontcolor="#ffffff",label="ahriman\.\ncore\.\nmodule_loader"];
|
||||
ahriman_core_report [fillcolor="blue",fontcolor="white",label="ahriman\.\ncore\.\nreport",shape="box"];
|
||||
ahriman_core_report_console [fillcolor="blue",fontcolor="white",label="ahriman\.\ncore\.\nreport\.\nconsole",shape="box"];
|
||||
@@ -243,18 +242,15 @@ digraph G {
|
||||
ahriman_web_apispec_info [fillcolor="#a14f35",fontcolor="#ffffff",label="ahriman\.\nweb\.\napispec\.\ninfo"];
|
||||
ahriman_web_cors [fillcolor="#b0573a",fontcolor="#ffffff",label="ahriman\.\nweb\.\ncors"];
|
||||
ahriman_web_keys [fillcolor="#823017",fontcolor="#ffffff",label="ahriman\.\nweb\.\nkeys"];
|
||||
ahriman_web_middlewares [fillcolor="#ef3e06",fontcolor="#ffffff",label="ahriman\.\nweb\.\nmiddlewares"];
|
||||
ahriman_web_middlewares [fillcolor="#e9410c",fontcolor="#ffffff",label="ahriman\.\nweb\.\nmiddlewares"];
|
||||
ahriman_web_middlewares_auth_handler [fillcolor="#733826",fontcolor="#ffffff",label="ahriman\.\nweb\.\nmiddlewares\.\nauth_handler"];
|
||||
ahriman_web_middlewares_exception_handler [fillcolor="#994b33",fontcolor="#ffffff",label="ahriman\.\nweb\.\nmiddlewares\.\nexception_handler"];
|
||||
ahriman_web_middlewares_metrics_handler [fillcolor="#a34628",fontcolor="#ffffff",label="ahriman\.\nweb\.\nmiddlewares\.\nmetrics_handler"];
|
||||
ahriman_web_middlewares_request_id_handler [fillcolor="#8a442e",fontcolor="#ffffff",label="ahriman\.\nweb\.\nmiddlewares\.\nrequest_id_handler"];
|
||||
ahriman_web_routes [fillcolor="#8a442e",fontcolor="#ffffff",label="ahriman\.\nweb\.\nroutes"];
|
||||
ahriman_web_schemas [fillcolor="blue",fontcolor="white",label="ahriman\.\nweb\.\nschemas",shape="box"];
|
||||
ahriman_web_schemas_any_schema [fillcolor="#b85a3d",fontcolor="#ffffff",label="ahriman\.\nweb\.\nschemas\.\nany_schema"];
|
||||
ahriman_web_schemas_aur_package_schema [fillcolor="#b85a3d",fontcolor="#ffffff",label="ahriman\.\nweb\.\nschemas\.\naur_package_schema"];
|
||||
ahriman_web_schemas_auth_info_schema [fillcolor="#c45431",fontcolor="#ffffff",label="ahriman\.\nweb\.\nschemas\.\nauth_info_schema"];
|
||||
ahriman_web_schemas_auth_schema [fillcolor="#b85a3d",fontcolor="#ffffff",label="ahriman\.\nweb\.\nschemas\.\nauth_schema"];
|
||||
ahriman_web_schemas_auto_refresh_interval_schema [fillcolor="#c45431",fontcolor="#ffffff",label="ahriman\.\nweb\.\nschemas\.\nauto_refresh_interval_schema"];
|
||||
ahriman_web_schemas_build_options_schema [fillcolor="#d04e24",fontcolor="#ffffff",label="ahriman\.\nweb\.\nschemas\.\nbuild_options_schema"];
|
||||
ahriman_web_schemas_changes_schema [fillcolor="#b85a3d",fontcolor="#ffffff",label="ahriman\.\nweb\.\nschemas\.\nchanges_schema"];
|
||||
ahriman_web_schemas_configuration_schema [fillcolor="#b85a3d",fontcolor="#ffffff",label="ahriman\.\nweb\.\nschemas\.\nconfiguration_schema"];
|
||||
@@ -265,7 +261,6 @@ digraph G {
|
||||
ahriman_web_schemas_event_search_schema [fillcolor="blue",fontcolor="white",label="ahriman\.\nweb\.\nschemas\.\nevent_search_schema",shape="box"];
|
||||
ahriman_web_schemas_file_schema [fillcolor="#b85a3d",fontcolor="#ffffff",label="ahriman\.\nweb\.\nschemas\.\nfile_schema"];
|
||||
ahriman_web_schemas_info_schema [fillcolor="blue",fontcolor="white",label="ahriman\.\nweb\.\nschemas\.\ninfo_schema",shape="box"];
|
||||
ahriman_web_schemas_info_v2_schema [fillcolor="blue",fontcolor="white",label="ahriman\.\nweb\.\nschemas\.\ninfo_v2_schema",shape="box"];
|
||||
ahriman_web_schemas_internal_status_schema [fillcolor="blue",fontcolor="white",label="ahriman\.\nweb\.\nschemas\.\ninternal_status_schema",shape="box"];
|
||||
ahriman_web_schemas_log_schema [fillcolor="#b85a3d",fontcolor="#ffffff",label="ahriman\.\nweb\.\nschemas\.\nlog_schema"];
|
||||
ahriman_web_schemas_login_schema [fillcolor="#b85a3d",fontcolor="#ffffff",label="ahriman\.\nweb\.\nschemas\.\nlogin_schema"];
|
||||
@@ -294,12 +289,11 @@ digraph G {
|
||||
ahriman_web_schemas_status_schema [fillcolor="#ca4116",fontcolor="#ffffff",label="ahriman\.\nweb\.\nschemas\.\nstatus_schema"];
|
||||
ahriman_web_schemas_update_flags_schema [fillcolor="blue",fontcolor="white",label="ahriman\.\nweb\.\nschemas\.\nupdate_flags_schema",shape="box"];
|
||||
ahriman_web_schemas_worker_schema [fillcolor="#b85a3d",fontcolor="#ffffff",label="ahriman\.\nweb\.\nschemas\.\nworker_schema"];
|
||||
ahriman_web_server_info [fillcolor="#93371a",fontcolor="#ffffff",label="ahriman\.\nweb\.\nserver_info"];
|
||||
ahriman_web_views [fillcolor="#f94810",fontcolor="#ffffff",label="ahriman\.\nweb\.\nviews"];
|
||||
ahriman_web_views_api_docs [fillcolor="#794434",fontcolor="#ffffff",label="ahriman\.\nweb\.\nviews\.\napi\.\ndocs"];
|
||||
ahriman_web_views_api_swagger [fillcolor="#6b3c2e",fontcolor="#ffffff",label="ahriman\.\nweb\.\nviews\.\napi\.\nswagger"];
|
||||
ahriman_web_views_base [fillcolor="#952603",fontcolor="#ffffff",label="ahriman\.\nweb\.\nviews\.\nbase"];
|
||||
ahriman_web_views_index [fillcolor="#794434",fontcolor="#ffffff",label="ahriman\.\nweb\.\nviews\.\nindex"];
|
||||
ahriman_web_views_index [fillcolor="#6b3c2e",fontcolor="#ffffff",label="ahriman\.\nweb\.\nviews\.\nindex"];
|
||||
ahriman_web_views_static [fillcolor="#884d3a",fontcolor="#ffffff",label="ahriman\.\nweb\.\nviews\.\nstatic"];
|
||||
ahriman_web_views_status_view_guard [fillcolor="#ef3e06",fontcolor="#ffffff",label="ahriman\.\nweb\.\nviews\.\nstatus_view_guard"];
|
||||
ahriman_web_views_v1_auditlog_events [fillcolor="#6b3c2e",fontcolor="#ffffff",label="ahriman\.\nweb\.\nviews\.\nv1\.\nauditlog\.\nevents"];
|
||||
@@ -322,14 +316,13 @@ digraph G {
|
||||
ahriman_web_views_v1_service_search [fillcolor="#6b3c2e",fontcolor="#ffffff",label="ahriman\.\nweb\.\nviews\.\nv1\.\nservice\.\nsearch"];
|
||||
ahriman_web_views_v1_service_update [fillcolor="#724031",fontcolor="#ffffff",label="ahriman\.\nweb\.\nviews\.\nv1\.\nservice\.\nupdate"];
|
||||
ahriman_web_views_v1_service_upload [fillcolor="#6b3c2e",fontcolor="#ffffff",label="ahriman\.\nweb\.\nviews\.\nv1\.\nservice\.\nupload"];
|
||||
ahriman_web_views_v1_status_info [fillcolor="#6b3c2e",fontcolor="#ffffff",label="ahriman\.\nweb\.\nviews\.\nv1\.\nstatus\.\ninfo"];
|
||||
ahriman_web_views_v1_status_info [fillcolor="#724031",fontcolor="#ffffff",label="ahriman\.\nweb\.\nviews\.\nv1\.\nstatus\.\ninfo"];
|
||||
ahriman_web_views_v1_status_metrics [fillcolor="#6b3c2e",fontcolor="#ffffff",label="ahriman\.\nweb\.\nviews\.\nv1\.\nstatus\.\nmetrics"];
|
||||
ahriman_web_views_v1_status_repositories [fillcolor="#724031",fontcolor="#ffffff",label="ahriman\.\nweb\.\nviews\.\nv1\.\nstatus\.\nrepositories"];
|
||||
ahriman_web_views_v1_status_status [fillcolor="#6b3c2e",fontcolor="#ffffff",label="ahriman\.\nweb\.\nviews\.\nv1\.\nstatus\.\nstatus"];
|
||||
ahriman_web_views_v1_user_login [fillcolor="#6b3c2e",fontcolor="#ffffff",label="ahriman\.\nweb\.\nviews\.\nv1\.\nuser\.\nlogin"];
|
||||
ahriman_web_views_v1_user_logout [fillcolor="#6b3c2e",fontcolor="#ffffff",label="ahriman\.\nweb\.\nviews\.\nv1\.\nuser\.\nlogout"];
|
||||
ahriman_web_views_v2_packages_logs [fillcolor="#6b3c2e",fontcolor="#ffffff",label="ahriman\.\nweb\.\nviews\.\nv2\.\npackages\.\nlogs"];
|
||||
ahriman_web_views_v2_status_info [fillcolor="#6b3c2e",fontcolor="#ffffff",label="ahriman\.\nweb\.\nviews\.\nv2\.\nstatus\.\ninfo"];
|
||||
ahriman_web_web [fillcolor="#733826",fontcolor="#ffffff",label="ahriman\.\nweb\.\nweb"];
|
||||
aioauth_client [fillcolor="#c07d40",shape="folder"];
|
||||
aiohttp [fillcolor="#f9b506",shape="folder"];
|
||||
@@ -495,12 +488,11 @@ digraph G {
|
||||
ahriman_core -> ahriman_models_worker [fillcolor="#ef3e06",minlen="2"];
|
||||
ahriman_core -> ahriman_web_keys [fillcolor="#ef3e06",minlen="2"];
|
||||
ahriman_core -> ahriman_web_middlewares_auth_handler [fillcolor="#ef3e06",minlen="3"];
|
||||
ahriman_core -> ahriman_web_middlewares_request_id_handler [fillcolor="#ef3e06",minlen="3"];
|
||||
ahriman_core -> ahriman_web_routes [fillcolor="#ef3e06",minlen="2"];
|
||||
ahriman_core -> ahriman_web_server_info [fillcolor="#ef3e06",minlen="2"];
|
||||
ahriman_core -> ahriman_web_views_api_docs [fillcolor="#ef3e06",minlen="3"];
|
||||
ahriman_core -> ahriman_web_views_api_swagger [fillcolor="#ef3e06",minlen="3"];
|
||||
ahriman_core -> ahriman_web_views_base [fillcolor="#ef3e06",minlen="3"];
|
||||
ahriman_core -> ahriman_web_views_index [fillcolor="#ef3e06",minlen="3"];
|
||||
ahriman_core -> ahriman_web_views_status_view_guard [fillcolor="#ef3e06",minlen="3"];
|
||||
ahriman_core -> ahriman_web_views_v1_distributed_workers [fillcolor="#ef3e06",minlen="3"];
|
||||
ahriman_core -> ahriman_web_views_v1_packages_logs [fillcolor="#ef3e06",minlen="3"];
|
||||
@@ -550,13 +542,13 @@ digraph G {
|
||||
ahriman_core_archive_archive_trigger -> ahriman_core_archive [fillcolor="blue",weight="3"];
|
||||
ahriman_core_auth -> ahriman_web_keys [fillcolor="blue",minlen="2"];
|
||||
ahriman_core_auth -> ahriman_web_middlewares_auth_handler [fillcolor="blue",minlen="3"];
|
||||
ahriman_core_auth -> ahriman_web_server_info [fillcolor="blue",minlen="2"];
|
||||
ahriman_core_auth -> ahriman_web_views_base [fillcolor="blue",minlen="3"];
|
||||
ahriman_core_auth -> ahriman_web_views_index [fillcolor="blue",minlen="3"];
|
||||
ahriman_core_auth -> ahriman_web_views_v1_user_login [fillcolor="blue",minlen="3"];
|
||||
ahriman_core_auth -> ahriman_web_views_v1_user_logout [fillcolor="blue",minlen="3"];
|
||||
ahriman_core_auth -> ahriman_web_web [fillcolor="blue",minlen="2"];
|
||||
ahriman_core_auth_auth -> ahriman_core_auth [fillcolor="blue",weight="3"];
|
||||
ahriman_core_auth_helpers -> ahriman_web_server_info [fillcolor="#d04e24",minlen="3"];
|
||||
ahriman_core_auth_helpers -> ahriman_web_views_index [fillcolor="#d04e24",minlen="3"];
|
||||
ahriman_core_auth_helpers -> ahriman_web_views_v1_user_login [fillcolor="#d04e24",minlen="3"];
|
||||
ahriman_core_auth_helpers -> ahriman_web_views_v1_user_logout [fillcolor="#d04e24",minlen="3"];
|
||||
ahriman_core_auth_mapping -> ahriman_core_auth_auth [fillcolor="blue",weight="3"];
|
||||
@@ -851,39 +843,35 @@ digraph G {
|
||||
ahriman_core_http_sync_ahriman_client -> ahriman_core_http [fillcolor="blue",weight="3"];
|
||||
ahriman_core_http_sync_http_client -> ahriman_core_http [fillcolor="#933f24",weight="3"];
|
||||
ahriman_core_http_sync_http_client -> ahriman_core_http_sync_ahriman_client [fillcolor="#933f24",weight="3"];
|
||||
ahriman_core_log -> ahriman_application_application_application_properties [fillcolor="blue",minlen="3"];
|
||||
ahriman_core_log -> ahriman_application_application_workers_updater [fillcolor="blue",minlen="3"];
|
||||
ahriman_core_log -> ahriman_application_handlers_handler [fillcolor="blue",minlen="3"];
|
||||
ahriman_core_log -> ahriman_application_lock [fillcolor="blue",minlen="2"];
|
||||
ahriman_core_log -> ahriman_core_alpm_pacman [fillcolor="blue",minlen="2",weight="2"];
|
||||
ahriman_core_log -> ahriman_core_alpm_repo [fillcolor="blue",minlen="2",weight="2"];
|
||||
ahriman_core_log -> ahriman_core_archive_archive_tree [fillcolor="blue",minlen="2",weight="2"];
|
||||
ahriman_core_log -> ahriman_core_auth_auth [fillcolor="blue",minlen="2",weight="2"];
|
||||
ahriman_core_log -> ahriman_core_build_tools_package_version [fillcolor="blue",minlen="2",weight="2"];
|
||||
ahriman_core_log -> ahriman_core_build_tools_sources [fillcolor="blue",minlen="2",weight="2"];
|
||||
ahriman_core_log -> ahriman_core_build_tools_task [fillcolor="blue",minlen="2",weight="2"];
|
||||
ahriman_core_log -> ahriman_core_database_migrations [fillcolor="blue",minlen="2",weight="2"];
|
||||
ahriman_core_log -> ahriman_core_database_operations_operations [fillcolor="blue",minlen="2",weight="2"];
|
||||
ahriman_core_log -> ahriman_core_distributed_workers_cache [fillcolor="blue",minlen="2",weight="2"];
|
||||
ahriman_core_log -> ahriman_core_gitremote_remote_pull [fillcolor="blue",minlen="2",weight="2"];
|
||||
ahriman_core_log -> ahriman_core_gitremote_remote_push [fillcolor="blue",minlen="2",weight="2"];
|
||||
ahriman_core_log -> ahriman_core_http_sync_http_client [fillcolor="blue",minlen="2",weight="2"];
|
||||
ahriman_core_log -> ahriman_core_report_report [fillcolor="blue",minlen="2",weight="2"];
|
||||
ahriman_core_log -> ahriman_core_repository_repository_properties [fillcolor="blue",minlen="2",weight="2"];
|
||||
ahriman_core_log -> ahriman_core_spawn [fillcolor="blue",weight="2"];
|
||||
ahriman_core_log -> ahriman_core_status_watcher [fillcolor="blue",minlen="2",weight="2"];
|
||||
ahriman_core_log -> ahriman_core_triggers_trigger [fillcolor="blue",minlen="2",weight="2"];
|
||||
ahriman_core_log -> ahriman_core_triggers_trigger_loader [fillcolor="blue",minlen="2",weight="2"];
|
||||
ahriman_core_log -> ahriman_core_upload_upload [fillcolor="blue",minlen="2",weight="2"];
|
||||
ahriman_core_log -> ahriman_models_package [fillcolor="blue",minlen="2"];
|
||||
ahriman_core_log -> ahriman_models_repository_paths [fillcolor="blue",minlen="2"];
|
||||
ahriman_core_log -> ahriman_web_middlewares_request_id_handler [fillcolor="blue",minlen="3"];
|
||||
ahriman_core_log -> ahriman_application_application_application_properties [fillcolor="#e53b05",minlen="3"];
|
||||
ahriman_core_log -> ahriman_application_application_workers_updater [fillcolor="#e53b05",minlen="3"];
|
||||
ahriman_core_log -> ahriman_application_handlers_handler [fillcolor="#e53b05",minlen="3"];
|
||||
ahriman_core_log -> ahriman_application_lock [fillcolor="#e53b05",minlen="2"];
|
||||
ahriman_core_log -> ahriman_core_alpm_pacman [fillcolor="#e53b05",minlen="2",weight="2"];
|
||||
ahriman_core_log -> ahriman_core_alpm_repo [fillcolor="#e53b05",minlen="2",weight="2"];
|
||||
ahriman_core_log -> ahriman_core_archive_archive_tree [fillcolor="#e53b05",minlen="2",weight="2"];
|
||||
ahriman_core_log -> ahriman_core_auth_auth [fillcolor="#e53b05",minlen="2",weight="2"];
|
||||
ahriman_core_log -> ahriman_core_build_tools_package_version [fillcolor="#e53b05",minlen="2",weight="2"];
|
||||
ahriman_core_log -> ahriman_core_build_tools_sources [fillcolor="#e53b05",minlen="2",weight="2"];
|
||||
ahriman_core_log -> ahriman_core_build_tools_task [fillcolor="#e53b05",minlen="2",weight="2"];
|
||||
ahriman_core_log -> ahriman_core_database_migrations [fillcolor="#e53b05",minlen="2",weight="2"];
|
||||
ahriman_core_log -> ahriman_core_database_operations_operations [fillcolor="#e53b05",minlen="2",weight="2"];
|
||||
ahriman_core_log -> ahriman_core_distributed_workers_cache [fillcolor="#e53b05",minlen="2",weight="2"];
|
||||
ahriman_core_log -> ahriman_core_gitremote_remote_pull [fillcolor="#e53b05",minlen="2",weight="2"];
|
||||
ahriman_core_log -> ahriman_core_gitremote_remote_push [fillcolor="#e53b05",minlen="2",weight="2"];
|
||||
ahriman_core_log -> ahriman_core_http_sync_http_client [fillcolor="#e53b05",minlen="2",weight="2"];
|
||||
ahriman_core_log -> ahriman_core_report_report [fillcolor="#e53b05",minlen="2",weight="2"];
|
||||
ahriman_core_log -> ahriman_core_repository_repository_properties [fillcolor="#e53b05",minlen="2",weight="2"];
|
||||
ahriman_core_log -> ahriman_core_spawn [fillcolor="#e53b05",weight="2"];
|
||||
ahriman_core_log -> ahriman_core_status_watcher [fillcolor="#e53b05",minlen="2",weight="2"];
|
||||
ahriman_core_log -> ahriman_core_triggers_trigger [fillcolor="#e53b05",minlen="2",weight="2"];
|
||||
ahriman_core_log -> ahriman_core_triggers_trigger_loader [fillcolor="#e53b05",minlen="2",weight="2"];
|
||||
ahriman_core_log -> ahriman_core_upload_upload [fillcolor="#e53b05",minlen="2",weight="2"];
|
||||
ahriman_core_log -> ahriman_models_package [fillcolor="#e53b05",minlen="2"];
|
||||
ahriman_core_log -> ahriman_models_repository_paths [fillcolor="#e53b05",minlen="2"];
|
||||
ahriman_core_log_http_log_handler -> ahriman_core_log_log_loader [fillcolor="#914730",weight="3"];
|
||||
ahriman_core_log_lazy_logging -> ahriman_core_log [fillcolor="blue",weight="3"];
|
||||
ahriman_core_log_log_context -> ahriman_core_log_lazy_logging [fillcolor="#db582f",weight="3"];
|
||||
ahriman_core_log_log_context -> ahriman_core_log_log_loader [fillcolor="#db582f",weight="3"];
|
||||
ahriman_core_log_log_context -> ahriman_web_middlewares_request_id_handler [fillcolor="#db582f",minlen="3"];
|
||||
ahriman_core_log_log_loader -> ahriman_application_handlers_handler [fillcolor="#7a3c28",minlen="3"];
|
||||
ahriman_core_log_lazy_logging -> ahriman_core_log [fillcolor="#b85a3d",weight="3"];
|
||||
ahriman_core_log_log_loader -> ahriman_application_handlers_handler [fillcolor="#82402b",minlen="3"];
|
||||
ahriman_core_module_loader -> ahriman_application_ahriman [fillcolor="#ce5e3b",minlen="2"];
|
||||
ahriman_core_module_loader -> ahriman_web_routes [fillcolor="#ce5e3b",minlen="2"];
|
||||
ahriman_core_report_console -> ahriman_core_report_report [fillcolor="blue",weight="3"];
|
||||
@@ -1003,7 +991,6 @@ digraph G {
|
||||
ahriman_core_types -> ahriman_core_report_jinja_template [fillcolor="#f94810",minlen="2",weight="2"];
|
||||
ahriman_core_types -> ahriman_core_report_rss [fillcolor="#f94810",minlen="2",weight="2"];
|
||||
ahriman_core_types -> ahriman_core_utils [fillcolor="#f94810",weight="2"];
|
||||
ahriman_core_types -> ahriman_web_server_info [fillcolor="#f94810",minlen="2"];
|
||||
ahriman_core_types -> ahriman_web_views_v1_distributed_workers [fillcolor="#f94810",minlen="3"];
|
||||
ahriman_core_types -> ahriman_web_views_v1_packages_packages [fillcolor="#f94810",minlen="3"];
|
||||
ahriman_core_types -> ahriman_web_views_v1_service_search [fillcolor="#f94810",minlen="3"];
|
||||
@@ -1073,9 +1060,8 @@ digraph G {
|
||||
ahriman_core_utils -> ahriman_models_repository_paths [fillcolor="#db3805",minlen="2"];
|
||||
ahriman_core_utils -> ahriman_models_repository_stats [fillcolor="#db3805",minlen="2"];
|
||||
ahriman_core_utils -> ahriman_models_worker [fillcolor="#db3805",minlen="2"];
|
||||
ahriman_core_utils -> ahriman_web_server_info [fillcolor="#db3805",minlen="2"];
|
||||
ahriman_core_utils -> ahriman_web_views_api_swagger [fillcolor="#db3805",minlen="3"];
|
||||
ahriman_core_utils -> ahriman_web_views_base [fillcolor="#db3805",minlen="3"];
|
||||
ahriman_core_utils -> ahriman_web_views_index [fillcolor="#db3805",minlen="3"];
|
||||
ahriman_core_utils -> ahriman_web_views_v1_packages_logs [fillcolor="#db3805",minlen="3"];
|
||||
ahriman_core_utils -> ahriman_web_views_v1_service_upload [fillcolor="#db3805",minlen="3"];
|
||||
ahriman_models -> ahriman_application_ahriman [fillcolor="#f94810",minlen="2"];
|
||||
@@ -1259,7 +1245,6 @@ digraph G {
|
||||
ahriman_models -> ahriman_web_views_v1_user_login [fillcolor="#f94810",minlen="3"];
|
||||
ahriman_models -> ahriman_web_views_v1_user_logout [fillcolor="#f94810",minlen="3"];
|
||||
ahriman_models -> ahriman_web_views_v2_packages_logs [fillcolor="#f94810",minlen="3"];
|
||||
ahriman_models -> ahriman_web_views_v2_status_info [fillcolor="#f94810",minlen="3"];
|
||||
ahriman_models -> ahriman_web_web [fillcolor="#f94810",minlen="2"];
|
||||
ahriman_models_action -> ahriman_application_handlers_change [fillcolor="#e75222",minlen="3"];
|
||||
ahriman_models_action -> ahriman_application_handlers_patch [fillcolor="#e75222",minlen="3"];
|
||||
@@ -1668,7 +1653,6 @@ digraph G {
|
||||
ahriman_models_user_access -> ahriman_web_views_v1_user_login [fillcolor="#f94810",minlen="3"];
|
||||
ahriman_models_user_access -> ahriman_web_views_v1_user_logout [fillcolor="#f94810",minlen="3"];
|
||||
ahriman_models_user_access -> ahriman_web_views_v2_packages_logs [fillcolor="#f94810",minlen="3"];
|
||||
ahriman_models_user_access -> ahriman_web_views_v2_status_info [fillcolor="#f94810",minlen="3"];
|
||||
ahriman_models_waiter -> ahriman_application_lock [fillcolor="#c45431",minlen="2"];
|
||||
ahriman_models_waiter -> ahriman_core_report_remote_call [fillcolor="#c45431",minlen="3"];
|
||||
ahriman_models_worker -> ahriman_application_application_workers_remote_updater [fillcolor="#e9410c",minlen="3"];
|
||||
@@ -1679,9 +1663,7 @@ digraph G {
|
||||
ahriman_web -> ahriman_application_handlers_web [fillcolor="#f94810",minlen="3"];
|
||||
ahriman_web_apispec -> ahriman_web_schemas_any_schema [fillcolor="#e53b05",minlen="2",weight="2"];
|
||||
ahriman_web_apispec -> ahriman_web_schemas_aur_package_schema [fillcolor="#e53b05",minlen="2",weight="2"];
|
||||
ahriman_web_apispec -> ahriman_web_schemas_auth_info_schema [fillcolor="#e53b05",minlen="2",weight="2"];
|
||||
ahriman_web_apispec -> ahriman_web_schemas_auth_schema [fillcolor="#e53b05",minlen="2",weight="2"];
|
||||
ahriman_web_apispec -> ahriman_web_schemas_auto_refresh_interval_schema [fillcolor="#e53b05",minlen="2",weight="2"];
|
||||
ahriman_web_apispec -> ahriman_web_schemas_build_options_schema [fillcolor="#e53b05",minlen="2",weight="2"];
|
||||
ahriman_web_apispec -> ahriman_web_schemas_changes_schema [fillcolor="#e53b05",minlen="2",weight="2"];
|
||||
ahriman_web_apispec -> ahriman_web_schemas_configuration_schema [fillcolor="#e53b05",minlen="2",weight="2"];
|
||||
@@ -1692,7 +1674,6 @@ digraph G {
|
||||
ahriman_web_apispec -> ahriman_web_schemas_event_search_schema [fillcolor="#e53b05",minlen="2",weight="2"];
|
||||
ahriman_web_apispec -> ahriman_web_schemas_file_schema [fillcolor="#e53b05",minlen="2",weight="2"];
|
||||
ahriman_web_apispec -> ahriman_web_schemas_info_schema [fillcolor="#e53b05",minlen="2",weight="2"];
|
||||
ahriman_web_apispec -> ahriman_web_schemas_info_v2_schema [fillcolor="#e53b05",minlen="2",weight="2"];
|
||||
ahriman_web_apispec -> ahriman_web_schemas_internal_status_schema [fillcolor="#e53b05",minlen="2",weight="2"];
|
||||
ahriman_web_apispec -> ahriman_web_schemas_log_schema [fillcolor="#e53b05",minlen="2",weight="2"];
|
||||
ahriman_web_apispec -> ahriman_web_schemas_login_schema [fillcolor="#e53b05",minlen="2",weight="2"];
|
||||
@@ -1721,9 +1702,9 @@ digraph G {
|
||||
ahriman_web_apispec -> ahriman_web_schemas_status_schema [fillcolor="#e53b05",minlen="2",weight="2"];
|
||||
ahriman_web_apispec -> ahriman_web_schemas_update_flags_schema [fillcolor="#e53b05",minlen="2",weight="2"];
|
||||
ahriman_web_apispec -> ahriman_web_schemas_worker_schema [fillcolor="#e53b05",minlen="2",weight="2"];
|
||||
ahriman_web_apispec -> ahriman_web_server_info [fillcolor="#e53b05",weight="2"];
|
||||
ahriman_web_apispec -> ahriman_web_views_api_docs [fillcolor="#e53b05",minlen="2",weight="2"];
|
||||
ahriman_web_apispec -> ahriman_web_views_api_swagger [fillcolor="#e53b05",minlen="2",weight="2"];
|
||||
ahriman_web_apispec -> ahriman_web_views_index [fillcolor="#e53b05",minlen="2",weight="2"];
|
||||
ahriman_web_apispec -> ahriman_web_views_v1_auditlog_events [fillcolor="#e53b05",minlen="2",weight="2"];
|
||||
ahriman_web_apispec -> ahriman_web_views_v1_distributed_workers [fillcolor="#e53b05",minlen="2",weight="2"];
|
||||
ahriman_web_apispec -> ahriman_web_views_v1_packages_changes [fillcolor="#e53b05",minlen="2",weight="2"];
|
||||
@@ -1751,7 +1732,6 @@ digraph G {
|
||||
ahriman_web_apispec -> ahriman_web_views_v1_user_login [fillcolor="#e53b05",minlen="2",weight="2"];
|
||||
ahriman_web_apispec -> ahriman_web_views_v1_user_logout [fillcolor="#e53b05",minlen="2",weight="2"];
|
||||
ahriman_web_apispec -> ahriman_web_views_v2_packages_logs [fillcolor="#e53b05",minlen="2",weight="2"];
|
||||
ahriman_web_apispec -> ahriman_web_views_v2_status_info [fillcolor="#e53b05",minlen="2",weight="2"];
|
||||
ahriman_web_apispec -> ahriman_web_web [fillcolor="#e53b05",weight="2"];
|
||||
ahriman_web_apispec_decorators -> ahriman_web_views_v1_auditlog_events [fillcolor="#bd3104",minlen="2",weight="2"];
|
||||
ahriman_web_apispec_decorators -> ahriman_web_views_v1_distributed_workers [fillcolor="#bd3104",minlen="2",weight="2"];
|
||||
@@ -1780,19 +1760,17 @@ digraph G {
|
||||
ahriman_web_apispec_decorators -> ahriman_web_views_v1_user_login [fillcolor="#bd3104",minlen="2",weight="2"];
|
||||
ahriman_web_apispec_decorators -> ahriman_web_views_v1_user_logout [fillcolor="#bd3104",minlen="2",weight="2"];
|
||||
ahriman_web_apispec_decorators -> ahriman_web_views_v2_packages_logs [fillcolor="#bd3104",minlen="2",weight="2"];
|
||||
ahriman_web_apispec_decorators -> ahriman_web_views_v2_status_info [fillcolor="#bd3104",minlen="2",weight="2"];
|
||||
ahriman_web_apispec_info -> ahriman_web_web [fillcolor="#a14f35",minlen="2",weight="2"];
|
||||
ahriman_web_cors -> ahriman_web_web [fillcolor="#b0573a",weight="2"];
|
||||
ahriman_web_keys -> ahriman_web_apispec_info [fillcolor="#823017",minlen="2",weight="2"];
|
||||
ahriman_web_keys -> ahriman_web_views_base [fillcolor="#823017",minlen="2",weight="2"];
|
||||
ahriman_web_keys -> ahriman_web_web [fillcolor="#823017",weight="2"];
|
||||
ahriman_web_middlewares -> ahriman_web_views_v1_status_metrics [fillcolor="#ef3e06",minlen="2",weight="2"];
|
||||
ahriman_web_middlewares -> ahriman_web_web [fillcolor="#ef3e06",weight="2"];
|
||||
ahriman_web_middlewares -> ahriman_web_views_v1_status_metrics [fillcolor="#e9410c",minlen="2",weight="2"];
|
||||
ahriman_web_middlewares -> ahriman_web_web [fillcolor="#e9410c",weight="2"];
|
||||
ahriman_web_middlewares_auth_handler -> ahriman_web_web [fillcolor="#733826",minlen="2",weight="2"];
|
||||
ahriman_web_middlewares_exception_handler -> ahriman_web_web [fillcolor="#994b33",minlen="2",weight="2"];
|
||||
ahriman_web_middlewares_metrics_handler -> ahriman_web_views_v1_status_metrics [fillcolor="#a34628",minlen="2",weight="2"];
|
||||
ahriman_web_middlewares_metrics_handler -> ahriman_web_web [fillcolor="#a34628",minlen="2",weight="2"];
|
||||
ahriman_web_middlewares_request_id_handler -> ahriman_web_web [fillcolor="#8a442e",minlen="2",weight="2"];
|
||||
ahriman_web_routes -> ahriman_web_web [fillcolor="#8a442e",weight="2"];
|
||||
ahriman_web_schemas -> ahriman_web_apispec_decorators [fillcolor="blue",minlen="2",weight="2"];
|
||||
ahriman_web_schemas -> ahriman_web_views_v1_auditlog_events [fillcolor="blue",minlen="2",weight="2"];
|
||||
@@ -1821,14 +1799,9 @@ digraph G {
|
||||
ahriman_web_schemas -> ahriman_web_views_v1_status_status [fillcolor="blue",minlen="2",weight="2"];
|
||||
ahriman_web_schemas -> ahriman_web_views_v1_user_login [fillcolor="blue",minlen="2",weight="2"];
|
||||
ahriman_web_schemas -> ahriman_web_views_v2_packages_logs [fillcolor="blue",minlen="2",weight="2"];
|
||||
ahriman_web_schemas -> ahriman_web_views_v2_status_info [fillcolor="blue",minlen="2",weight="2"];
|
||||
ahriman_web_schemas_any_schema -> ahriman_web_schemas [fillcolor="#b85a3d",weight="3"];
|
||||
ahriman_web_schemas_aur_package_schema -> ahriman_web_schemas [fillcolor="#b85a3d",weight="3"];
|
||||
ahriman_web_schemas_auth_info_schema -> ahriman_web_schemas [fillcolor="#c45431",weight="3"];
|
||||
ahriman_web_schemas_auth_info_schema -> ahriman_web_schemas_info_v2_schema [fillcolor="#c45431",weight="3"];
|
||||
ahriman_web_schemas_auth_schema -> ahriman_web_schemas [fillcolor="#b85a3d",weight="3"];
|
||||
ahriman_web_schemas_auto_refresh_interval_schema -> ahriman_web_schemas [fillcolor="#c45431",weight="3"];
|
||||
ahriman_web_schemas_auto_refresh_interval_schema -> ahriman_web_schemas_info_v2_schema [fillcolor="#c45431",weight="3"];
|
||||
ahriman_web_schemas_build_options_schema -> ahriman_web_schemas [fillcolor="#d04e24",weight="3"];
|
||||
ahriman_web_schemas_build_options_schema -> ahriman_web_schemas_package_names_schema [fillcolor="#d04e24",weight="3"];
|
||||
ahriman_web_schemas_build_options_schema -> ahriman_web_schemas_update_flags_schema [fillcolor="#d04e24",weight="3"];
|
||||
@@ -1842,7 +1815,6 @@ digraph G {
|
||||
ahriman_web_schemas_event_search_schema -> ahriman_web_schemas [fillcolor="blue",weight="3"];
|
||||
ahriman_web_schemas_file_schema -> ahriman_web_schemas [fillcolor="#b85a3d",weight="3"];
|
||||
ahriman_web_schemas_info_schema -> ahriman_web_schemas [fillcolor="blue",weight="3"];
|
||||
ahriman_web_schemas_info_v2_schema -> ahriman_web_schemas [fillcolor="blue",weight="3"];
|
||||
ahriman_web_schemas_internal_status_schema -> ahriman_web_schemas [fillcolor="blue",weight="3"];
|
||||
ahriman_web_schemas_log_schema -> ahriman_web_schemas [fillcolor="#b85a3d",weight="3"];
|
||||
ahriman_web_schemas_login_schema -> ahriman_web_schemas [fillcolor="#b85a3d",weight="3"];
|
||||
@@ -1875,7 +1847,6 @@ digraph G {
|
||||
ahriman_web_schemas_remote_schema -> ahriman_web_schemas_package_schema [fillcolor="#b44d2d",weight="3"];
|
||||
ahriman_web_schemas_repository_id_schema -> ahriman_web_schemas [fillcolor="#ef3e06",weight="3"];
|
||||
ahriman_web_schemas_repository_id_schema -> ahriman_web_schemas_info_schema [fillcolor="#ef3e06",weight="3"];
|
||||
ahriman_web_schemas_repository_id_schema -> ahriman_web_schemas_info_v2_schema [fillcolor="#ef3e06",weight="3"];
|
||||
ahriman_web_schemas_repository_id_schema -> ahriman_web_schemas_internal_status_schema [fillcolor="#ef3e06",weight="3"];
|
||||
ahriman_web_schemas_repository_id_schema -> ahriman_web_schemas_package_status_schema [fillcolor="#ef3e06",weight="3"];
|
||||
ahriman_web_schemas_repository_id_schema -> ahriman_web_schemas_package_version_schema [fillcolor="#ef3e06",weight="3"];
|
||||
@@ -1889,13 +1860,8 @@ digraph G {
|
||||
ahriman_web_schemas_status_schema -> ahriman_web_schemas_package_status_schema [fillcolor="#ca4116",weight="3"];
|
||||
ahriman_web_schemas_update_flags_schema -> ahriman_web_schemas [fillcolor="blue",weight="3"];
|
||||
ahriman_web_schemas_worker_schema -> ahriman_web_schemas [fillcolor="#b85a3d",weight="3"];
|
||||
ahriman_web_server_info -> ahriman_web_views_index [fillcolor="#93371a",minlen="2",weight="2"];
|
||||
ahriman_web_server_info -> ahriman_web_views_v1_status_info [fillcolor="#93371a",minlen="2",weight="2"];
|
||||
ahriman_web_server_info -> ahriman_web_views_v2_status_info [fillcolor="#93371a",minlen="2",weight="2"];
|
||||
ahriman_web_views -> ahriman_web_routes [fillcolor="#f94810",weight="2"];
|
||||
ahriman_web_views -> ahriman_web_server_info [fillcolor="#f94810",weight="2"];
|
||||
ahriman_web_views_base -> ahriman_web_routes [fillcolor="#952603",minlen="2",weight="2"];
|
||||
ahriman_web_views_base -> ahriman_web_server_info [fillcolor="#952603",minlen="2",weight="2"];
|
||||
ahriman_web_views_base -> ahriman_web_views_api_docs [fillcolor="#952603",weight="3"];
|
||||
ahriman_web_views_base -> ahriman_web_views_api_swagger [fillcolor="#952603",weight="3"];
|
||||
ahriman_web_views_base -> ahriman_web_views_index [fillcolor="#952603",weight="3"];
|
||||
@@ -1927,7 +1893,6 @@ digraph G {
|
||||
ahriman_web_views_base -> ahriman_web_views_v1_user_login [fillcolor="#952603",weight="3"];
|
||||
ahriman_web_views_base -> ahriman_web_views_v1_user_logout [fillcolor="#952603",weight="3"];
|
||||
ahriman_web_views_base -> ahriman_web_views_v2_packages_logs [fillcolor="#952603",weight="3"];
|
||||
ahriman_web_views_base -> ahriman_web_views_v2_status_info [fillcolor="#952603",weight="3"];
|
||||
ahriman_web_views_status_view_guard -> ahriman_web_views_v1_packages_changes [fillcolor="#ef3e06",weight="3"];
|
||||
ahriman_web_views_status_view_guard -> ahriman_web_views_v1_packages_dependencies [fillcolor="#ef3e06",weight="3"];
|
||||
ahriman_web_views_status_view_guard -> ahriman_web_views_v1_packages_logs [fillcolor="#ef3e06",weight="3"];
|
||||
@@ -1947,11 +1912,9 @@ digraph G {
|
||||
aiohttp -> ahriman_web_middlewares_auth_handler [fillcolor="#f9b506",minlen="3"];
|
||||
aiohttp -> ahriman_web_middlewares_exception_handler [fillcolor="#f9b506",minlen="3"];
|
||||
aiohttp -> ahriman_web_middlewares_metrics_handler [fillcolor="#f9b506",minlen="3"];
|
||||
aiohttp -> ahriman_web_middlewares_request_id_handler [fillcolor="#f9b506",minlen="3"];
|
||||
aiohttp -> ahriman_web_routes [fillcolor="#f9b506",minlen="2"];
|
||||
aiohttp -> ahriman_web_views_api_swagger [fillcolor="#f9b506",minlen="3"];
|
||||
aiohttp -> ahriman_web_views_base [fillcolor="#f9b506",minlen="3"];
|
||||
aiohttp -> ahriman_web_views_index [fillcolor="#f9b506",minlen="3"];
|
||||
aiohttp -> ahriman_web_views_static [fillcolor="#f9b506",minlen="3"];
|
||||
aiohttp -> ahriman_web_views_v1_auditlog_events [fillcolor="#f9b506",minlen="3"];
|
||||
aiohttp -> ahriman_web_views_v1_distributed_workers [fillcolor="#f9b506",minlen="3"];
|
||||
@@ -1980,7 +1943,6 @@ digraph G {
|
||||
aiohttp -> ahriman_web_views_v1_user_login [fillcolor="#f9b506",minlen="3"];
|
||||
aiohttp -> ahriman_web_views_v1_user_logout [fillcolor="#f9b506",minlen="3"];
|
||||
aiohttp -> ahriman_web_views_v2_packages_logs [fillcolor="#f9b506",minlen="3"];
|
||||
aiohttp -> ahriman_web_views_v2_status_info [fillcolor="#f9b506",minlen="3"];
|
||||
aiohttp -> ahriman_web_web [fillcolor="#f9b506",minlen="2"];
|
||||
aiohttp -> aiohttp_cors [fillcolor="#f9b506",minlen="2"];
|
||||
aiohttp -> aiohttp_jinja2 [fillcolor="#f9b506",minlen="2"];
|
||||
|
||||
@@ -12,14 +12,6 @@ ahriman.application.handlers.add module
|
||||
:no-undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
ahriman.application.handlers.archives module
|
||||
--------------------------------------------
|
||||
|
||||
.. automodule:: ahriman.application.handlers.archives
|
||||
:members:
|
||||
:no-undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
ahriman.application.handlers.backup module
|
||||
------------------------------------------
|
||||
|
||||
@@ -84,14 +76,6 @@ ahriman.application.handlers.help module
|
||||
:no-undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
ahriman.application.handlers.hold module
|
||||
----------------------------------------
|
||||
|
||||
.. automodule:: ahriman.application.handlers.hold
|
||||
:members:
|
||||
:no-undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
ahriman.application.handlers.key\_import module
|
||||
-----------------------------------------------
|
||||
|
||||
@@ -108,14 +92,6 @@ ahriman.application.handlers.patch module
|
||||
:no-undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
ahriman.application.handlers.pkgbuild module
|
||||
--------------------------------------------
|
||||
|
||||
.. automodule:: ahriman.application.handlers.pkgbuild
|
||||
:members:
|
||||
:no-undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
ahriman.application.handlers.rebuild module
|
||||
-------------------------------------------
|
||||
|
||||
@@ -164,14 +140,6 @@ ahriman.application.handlers.restore module
|
||||
:no-undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
ahriman.application.handlers.rollback module
|
||||
--------------------------------------------
|
||||
|
||||
.. automodule:: ahriman.application.handlers.rollback
|
||||
:members:
|
||||
:no-undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
ahriman.application.handlers.run module
|
||||
---------------------------------------
|
||||
|
||||
|
||||
@@ -28,14 +28,6 @@ ahriman.core.alpm.pacman\_database module
|
||||
:no-undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
ahriman.core.alpm.pacman\_handle module
|
||||
---------------------------------------
|
||||
|
||||
.. automodule:: ahriman.core.alpm.pacman_handle
|
||||
:members:
|
||||
:no-undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
ahriman.core.alpm.pkgbuild\_parser module
|
||||
-----------------------------------------
|
||||
|
||||
|
||||
@@ -140,22 +140,6 @@ ahriman.core.database.migrations.m016\_archive module
|
||||
:no-undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
ahriman.core.database.migrations.m017\_pkgbuild module
|
||||
------------------------------------------------------
|
||||
|
||||
.. automodule:: ahriman.core.database.migrations.m017_pkgbuild
|
||||
:members:
|
||||
:no-undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
ahriman.core.database.migrations.m018\_package\_hold module
|
||||
-----------------------------------------------------------
|
||||
|
||||
.. automodule:: ahriman.core.database.migrations.m018_package_hold
|
||||
:members:
|
||||
:no-undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
Module contents
|
||||
---------------
|
||||
|
||||
|
||||
@@ -76,14 +76,6 @@ ahriman.core.formatters.patch\_printer module
|
||||
:no-undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
ahriman.core.formatters.pkgbuild\_printer module
|
||||
------------------------------------------------
|
||||
|
||||
.. automodule:: ahriman.core.formatters.pkgbuild_printer
|
||||
:members:
|
||||
:no-undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
ahriman.core.formatters.printer module
|
||||
--------------------------------------
|
||||
|
||||
|
||||
@@ -28,14 +28,6 @@ ahriman.core.log.lazy\_logging module
|
||||
:no-undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
ahriman.core.log.log\_context module
|
||||
------------------------------------
|
||||
|
||||
.. automodule:: ahriman.core.log.log_context
|
||||
:members:
|
||||
:no-undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
ahriman.core.log.log\_loader module
|
||||
-----------------------------------
|
||||
|
||||
|
||||
@@ -12,14 +12,6 @@ ahriman.core.status.client module
|
||||
:no-undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
ahriman.core.status.event\_bus module
|
||||
-------------------------------------
|
||||
|
||||
.. automodule:: ahriman.core.status.event_bus
|
||||
:members:
|
||||
:no-undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
ahriman.core.status.local\_client module
|
||||
----------------------------------------
|
||||
|
||||
|
||||
@@ -12,14 +12,6 @@ ahriman.web.middlewares.auth\_handler module
|
||||
:no-undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
ahriman.web.middlewares.etag\_handler module
|
||||
--------------------------------------------
|
||||
|
||||
.. automodule:: ahriman.web.middlewares.etag_handler
|
||||
:members:
|
||||
:no-undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
ahriman.web.middlewares.exception\_handler module
|
||||
-------------------------------------------------
|
||||
|
||||
@@ -36,14 +28,6 @@ ahriman.web.middlewares.metrics\_handler module
|
||||
:no-undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
ahriman.web.middlewares.request\_id\_handler module
|
||||
---------------------------------------------------
|
||||
|
||||
.. automodule:: ahriman.web.middlewares.request_id_handler
|
||||
:members:
|
||||
:no-undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
Module contents
|
||||
---------------
|
||||
|
||||
|
||||
@@ -92,14 +92,6 @@ ahriman.web.schemas.error\_schema module
|
||||
:no-undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
ahriman.web.schemas.event\_bus\_filter\_schema module
|
||||
-----------------------------------------------------
|
||||
|
||||
.. automodule:: ahriman.web.schemas.event_bus_filter_schema
|
||||
:members:
|
||||
:no-undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
ahriman.web.schemas.event\_schema module
|
||||
----------------------------------------
|
||||
|
||||
@@ -124,14 +116,6 @@ ahriman.web.schemas.file\_schema module
|
||||
:no-undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
ahriman.web.schemas.hold\_schema module
|
||||
---------------------------------------
|
||||
|
||||
.. automodule:: ahriman.web.schemas.hold_schema
|
||||
:members:
|
||||
:no-undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
ahriman.web.schemas.info\_schema module
|
||||
---------------------------------------
|
||||
|
||||
@@ -260,14 +244,6 @@ ahriman.web.schemas.package\_version\_schema module
|
||||
:no-undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
ahriman.web.schemas.packager\_schema module
|
||||
-------------------------------------------
|
||||
|
||||
.. automodule:: ahriman.web.schemas.packager_schema
|
||||
:members:
|
||||
:no-undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
ahriman.web.schemas.pagination\_schema module
|
||||
---------------------------------------------
|
||||
|
||||
@@ -348,14 +324,6 @@ ahriman.web.schemas.repository\_stats\_schema module
|
||||
:no-undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
ahriman.web.schemas.rollback\_schema module
|
||||
-------------------------------------------
|
||||
|
||||
.. automodule:: ahriman.web.schemas.rollback_schema
|
||||
:members:
|
||||
:no-undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
ahriman.web.schemas.search\_schema module
|
||||
-----------------------------------------
|
||||
|
||||
@@ -364,14 +332,6 @@ ahriman.web.schemas.search\_schema module
|
||||
:no-undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
ahriman.web.schemas.sse\_schema module
|
||||
--------------------------------------
|
||||
|
||||
.. automodule:: ahriman.web.schemas.sse_schema
|
||||
:members:
|
||||
:no-undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
ahriman.web.schemas.status\_schema module
|
||||
-----------------------------------------
|
||||
|
||||
|
||||
@@ -4,14 +4,6 @@ ahriman.web.views.v1.auditlog package
|
||||
Submodules
|
||||
----------
|
||||
|
||||
ahriman.web.views.v1.auditlog.event\_bus module
|
||||
-----------------------------------------------
|
||||
|
||||
.. automodule:: ahriman.web.views.v1.auditlog.event_bus
|
||||
:members:
|
||||
:no-undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
ahriman.web.views.v1.auditlog.events module
|
||||
-------------------------------------------
|
||||
|
||||
|
||||
@@ -4,14 +4,6 @@ ahriman.web.views.v1.packages package
|
||||
Submodules
|
||||
----------
|
||||
|
||||
ahriman.web.views.v1.packages.archives module
|
||||
---------------------------------------------
|
||||
|
||||
.. automodule:: ahriman.web.views.v1.packages.archives
|
||||
:members:
|
||||
:no-undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
ahriman.web.views.v1.packages.changes module
|
||||
--------------------------------------------
|
||||
|
||||
@@ -28,14 +20,6 @@ ahriman.web.views.v1.packages.dependencies module
|
||||
:no-undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
ahriman.web.views.v1.packages.hold module
|
||||
-----------------------------------------
|
||||
|
||||
.. automodule:: ahriman.web.views.v1.packages.hold
|
||||
:members:
|
||||
:no-undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
ahriman.web.views.v1.packages.logs module
|
||||
-----------------------------------------
|
||||
|
||||
|
||||
@@ -68,14 +68,6 @@ ahriman.web.views.v1.service.request module
|
||||
:no-undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
ahriman.web.views.v1.service.rollback module
|
||||
--------------------------------------------
|
||||
|
||||
.. automodule:: ahriman.web.views.v1.service.rollback
|
||||
:members:
|
||||
:no-undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
ahriman.web.views.v1.service.search module
|
||||
------------------------------------------
|
||||
|
||||
|
||||
+13
-39
@@ -9,8 +9,7 @@ Packages have strict rules of importing:
|
||||
* ``ahriman.application`` package must not be used outside of this package.
|
||||
* ``ahriman.core`` and ``ahriman.models`` packages don't have any import restriction. Actually we would like to totally restrict importing of ``core`` package from ``models``, but it is impossible at the moment.
|
||||
* ``ahriman.web`` package is allowed to be imported from ``ahriman.application`` (web handler only, only ``ahriman.web.web`` methods).
|
||||
|
||||
The idea remains the same for all imports, if a package requires some specific dependencies, it must be imported locally to keep dependencies optional.
|
||||
* The idea remains the same for all imports, if an package requires some specific dependencies, it must be imported locally to keep dependencies optional.
|
||||
|
||||
Full dependency diagram:
|
||||
|
||||
@@ -43,7 +42,7 @@ This package contains everything required for the most of application actions an
|
||||
* ``ahriman.core.gitremote`` is a package with remote PKGBUILD triggers. Should not be called directly.
|
||||
* ``ahriman.core.housekeeping`` package provides few triggers for removing old data.
|
||||
* ``ahriman.core.http`` package provides HTTP clients which can be used later by other classes.
|
||||
* ``ahriman.core.log`` is a log utils package. It includes logger loader class, custom HTTP based logger, log context for injecting context variables into log records and some wrappers.
|
||||
* ``ahriman.core.log`` is a log utils package. It includes logger loader class, custom HTTP based logger and some wrappers.
|
||||
* ``ahriman.core.report`` is a package with reporting triggers. Should not be called directly.
|
||||
* ``ahriman.core.repository`` contains several traits and base repository (``ahriman.core.repository.Repository`` class) implementation.
|
||||
* ``ahriman.core.sign`` package provides sign feature (only gpg calls are available).
|
||||
@@ -86,7 +85,6 @@ Application run
|
||||
#. Call ``Handler.execute`` method.
|
||||
#. Define list of architectures to run. In case if there is more than one architecture specified run several subprocesses or continue in current process otherwise. Class attribute ``ALLOW_MULTI_ARCHITECTURE_RUN`` controls whether the application can be run in multiple processes or not - this feature is required for some handlers (e.g. ``Config``, which utilizes stdout to print messages).
|
||||
#. In each child process call lock functions.
|
||||
#. Load configuration and install logging.
|
||||
#. After success checks pass control to ``Handler.run`` method defined by specific handler class.
|
||||
#. Return result (success or failure) of each subprocess and exit from application.
|
||||
#. Some handlers may override their status and throw ``ExitCode`` exception. This exception is just silently suppressed and changes application exit code to ``1``.
|
||||
@@ -161,12 +159,12 @@ Having default root as ``/var/lib/ahriman`` (differs from container though), the
|
||||
├── aur.files -> aur.files.tar.gz
|
||||
└── aur.files.tar.gz
|
||||
|
||||
There are multiple subdirectories, some of them are common for any repository, but some of them are not.
|
||||
There are multiple subdirectories, some of them are commons for any repository, but some of them are not.
|
||||
|
||||
* ``archive`` is the package archive directory. It is common for all repositories and architectures and contains two subdirectories:
|
||||
|
||||
* ``archive/packages/{first_letter}/{package_base}`` stores the actual built package files and their signatures.
|
||||
* ``archive/repos/{YYYY}/{MM}/{DD}/{repository}/{architecture}`` contains daily repository snapshots. Each snapshot is a repository database with symlinks pointing to the corresponding packages in the ``archive/packages`` tree. These directories only appear if ``ahriman.core.archive.ArchiveTrigger`` is enabled.
|
||||
* ``archive/repos/{YYYY}/{MM}/{DD}/{repository}/{architecture}`` contains daily repository snapshots. Each snapshot is a repository database with symlinks pointing to the corresponding packages in the ``archive/packages`` tree.
|
||||
|
||||
The archive also allows the build process to skip rebuilding a package if a matching version already exists.
|
||||
|
||||
@@ -235,27 +233,15 @@ Remove packages
|
||||
|
||||
This flow removes package from filesystem, updates repository database and also runs synchronization and reporting methods.
|
||||
|
||||
Rollback packages
|
||||
^^^^^^^^^^^^^^^^^
|
||||
|
||||
This flow restores a package to a previously built version:
|
||||
|
||||
#. Load the current package definition from the repository database.
|
||||
#. Replace its version with the requested rollback target.
|
||||
#. Search the archive directory for built artifacts (packages and signatures) matching the target version.
|
||||
#. Add the found artifacts to the repository via the same path as ``package-add`` with ``PackageSource.Archive``.
|
||||
#. Trigger an immediate update to process the added packages.
|
||||
#. If ``--hold`` is enabled (the default), mark the package as held in the database to prevent automatic updates from overriding the rollback.
|
||||
|
||||
Check outdated packages
|
||||
^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
There are few ways for packages to be marked as out-of-date and hence requiring rebuild. Those are following:
|
||||
|
||||
#. User requested update of the package. It can be caused by calling ``package-add`` subcommand (or ``package-update`` with arguments).
|
||||
#. The most common way for packages to be marked as out-of-date is that the version in AUR (or the official repositories) is newer than in the repository.
|
||||
#. The most common way for packages to be marked as out-of-dated is that the version in AUR (or the official repositories) is newer than in the repository.
|
||||
#. In addition to the above, if package is named as VCS (e.g. has suffix ``-git``) and the last update was more than specified threshold ago, the service will also try to fetch sources and check if the revision is newer than the built one.
|
||||
#. In addition, there is ability to check if the dependencies of the package have been updated (e.g. if linked library has been renamed or the modules directory - e.g. in case of python and ruby packages - has been changed). And if so, the package will be marked as out-of-date as well.
|
||||
#. In addition, there is ability to check if the dependencies of the package have been updated (e.g. if linked library has been renamed or the modules directory - e.g. in case of python and ruby packages - has been changed). And if so, the package will be marked as out-of-dated as well.
|
||||
|
||||
Update packages
|
||||
^^^^^^^^^^^^^^^
|
||||
@@ -269,7 +255,6 @@ This feature is divided into the following stages: check AUR for updates and run
|
||||
|
||||
#. Download package data from AUR.
|
||||
#. Bump ``pkgrel`` if there is duplicate version in the local repository (see explanation below).
|
||||
#. Check if there is already built package of the same version in archive (cross-repository support). If so, then just copy built archives and skip steps below.
|
||||
#. Build every package in clean chroot.
|
||||
#. Sign packages if required.
|
||||
#. Add packages to database and sign database if required.
|
||||
@@ -328,7 +313,7 @@ Having the initial dependencies tree, the application is looking for packages wh
|
||||
|
||||
Those paths are also filtered by regular expressions set in the configuration.
|
||||
|
||||
All those implicit dependencies are stored in the database and extracted on each check. In case if any of the repository packages doesn't contain any entry anymore (e.g. so version has been changed or modules directory has been changed), the dependent package will be marked as out-of-date.
|
||||
All those implicit dependencies are stored in the database and extracted on each check. In case if any of the repository packages doesn't contain any entry anymore (e.g. so version has been changed or modules directory has been changed), the dependent package will be marked as out-of-dated.
|
||||
|
||||
Core functions reference
|
||||
------------------------
|
||||
@@ -359,8 +344,6 @@ The ``_Context`` class itself mimics default collection interface (as is ``Mappi
|
||||
|
||||
In order to provide statically typed interface, the ``ahriman.models.context_key.ContextKey`` class is used for both ``_Content.get`` and ``_Content.set`` methods; the context instance itself, however, does not store information about types.
|
||||
|
||||
Logging module has its own context variables, which are required to be registered in advance to avoid possible race conditions.
|
||||
|
||||
Submodules
|
||||
^^^^^^^^^^
|
||||
|
||||
@@ -387,7 +370,7 @@ Passwords must be stored in database as ``hash(password + salt)``, where ``passw
|
||||
|
||||
means that there is user ``username`` with ``read`` access and password ``password`` hashed by ``sha512`` with salt ``salt``.
|
||||
|
||||
OAuth provider uses library definitions (``aioauth-client``) in order to *authenticate* users. It still requires user permission to be set in database, thus it inherits mapping provider without any changes. Whereas we could override ``check_credentials`` (authentication method) by something custom, OAuth flow is a bit more complex than just forward request, thus we have to implement the flow in login form.
|
||||
OAuth provider uses library definitions (``aioauth-client``) in order *authenticate* users. It still requires user permission to be set in database, thus it inherits mapping provider without any changes. Whereas we could override ``check_credentials`` (authentication method) by something custom, OAuth flow is a bit more complex than just forward request, thus we have to implement the flow in login form.
|
||||
|
||||
OAuth's implementation also allows authenticating users via username + password (in the same way as mapping does) though it is not recommended for end-users and password must be left blank. In particular this feature can be used by service reporting (aka robots).
|
||||
|
||||
@@ -400,7 +383,7 @@ Triggers
|
||||
|
||||
Triggers are extensions which can be used in order to perform any actions on application start, after the update process and, finally, before the application exit.
|
||||
|
||||
The main idea is to load classes by their full path (e.g. ``ahriman.core.upload.UploadTrigger``) by using ``importlib``: get the last part of the import and treat it as class name, join the remaining part by ``.`` and interpret as module path, import module and extract attribute from it.
|
||||
The main idea is to load classes by their full path (e.g. ``ahriman.core.upload.UploadTrigger``) by using ``importlib``: get the last part of the import and treat it as class name, join remain part by ``.`` and interpret as module path, import module and extract attribute from it.
|
||||
|
||||
The loaded triggers will be called with ``ahriman.models.result.Result`` and ``list[Packages]`` arguments, which describes the process result and current repository packages respectively. Any exception raised will be suppressed and will generate an exception message in logs.
|
||||
|
||||
@@ -424,7 +407,7 @@ PKGBUILD parsing
|
||||
|
||||
The application provides a house-made shell parser ``ahriman.core.alpm.pkgbuild_parser.PkgbuildParser`` to process PKGBUILDs and extract package data from them. It relies on the ``shlex.shlex`` parser with some configuration tweaks and adds some token post-processing.
|
||||
|
||||
#. During the parser process, firstly, it extracts the next token from the source file (basically, the word) and tries to match it to the variable assignment. If so, then just processes accordingly.
|
||||
#. During the parser process, firstly, it extract next token from the source file (basically, the word) and tries to match it to the variable assignment. If so, then just processes accordingly.
|
||||
#. If it is not an assignment, the parser checks if the token was quoted.
|
||||
#. If it wasn't quoted then the parser tries to match the array starts (two consecutive tokens like ``array=`` and ``(``) or it is function (``function``, ``()`` and ``{``).
|
||||
#. The arrays are processed until the next closing bracket ``)``. After extraction, the parser tries to expand an array according to bash rules (``prefix{first,second}suffix`` constructions).
|
||||
@@ -437,15 +420,6 @@ The PKGBUILD class also provides some additional functions on top of that:
|
||||
* Ability to extract fields defined inside ``package*()`` functions, which are in particular used for the multi-packages.
|
||||
* Shell substitution, which supports constructions ``$var`` (including ``${var}``), ``${var#(#)pattern}``, ``${var%(%)pattern}`` and ``${var/(/)pattern/replacement}`` (including ``#pattern`` and ``%pattern``).
|
||||
|
||||
HTTP client
|
||||
^^^^^^^^^^^
|
||||
|
||||
The ``ahriman.core.http`` package provides a HTTP client built on top of the ``requests`` library.
|
||||
|
||||
The base class ``ahriman.core.http.SyncHttpClient`` wraps ``requests.Session`` and provides common features for all HTTP interactions: configurable timeouts, retry policies with exponential backoff (using ``urllib3.util.retry.Retry``), basic authentication, custom User-Agent header, error processing, and ``make_request`` method. The session is lazily created (via ``cached_property``).
|
||||
|
||||
On top of that, ``ahriman.core.http.SyncAhrimanClient`` extends the base client for communication with the ahriman web service specifically. It adds automatic login on session creation (using configured credentials), ``X-Request-ID`` header injection and Unix socket transport support (via ``requests-unixsocket2``) if required.
|
||||
|
||||
Additional features
|
||||
^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
@@ -471,7 +445,7 @@ Web application requires the following python packages to be installed:
|
||||
Middlewares
|
||||
^^^^^^^^^^^
|
||||
|
||||
Service provides some custom middlewares, e.g. logging every exception (except for user ones), user authorization and request tracing via ``X-Request-ID`` header.
|
||||
Service provides some custom middlewares, e.g. logging every exception (except for user ones) and user authorization.
|
||||
|
||||
HEAD and OPTIONS requests
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
@@ -483,7 +457,7 @@ On the other side, ``OPTIONS`` method is implemented in the ``ahriman.web.middle
|
||||
Web views
|
||||
^^^^^^^^^
|
||||
|
||||
All web views are defined in a separate package and derived from ``ahriman.web.views.base.Base`` class which provides typed interfaces for web application.
|
||||
All web views are defined in separated package and derived from ``ahriman.web.views.base.Base`` class which provides typed interfaces for web application.
|
||||
|
||||
REST API supports only JSON data.
|
||||
|
||||
@@ -502,7 +476,7 @@ The views are also divided by supporting API versions (e.g. ``v1``, ``v2``).
|
||||
Templating
|
||||
^^^^^^^^^^
|
||||
|
||||
Package provides base jinja templates which can be overridden by settings. The default web interface is a React application. The classic bootstrap-based template is still available as ``build-status-classic.jinja2`` and can be enabled via the ``web.template`` configuration option.
|
||||
Package provides base jinja templates which can be overridden by settings. Vanilla templates actively use bootstrap library.
|
||||
|
||||
Requests and scopes
|
||||
^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
@@ -180,15 +180,10 @@ Web server settings. This feature requires ``aiohttp`` libraries to be installed
|
||||
|
||||
* ``address`` - optional address in form ``proto://host:port`` (``port`` can be omitted in case of default ``proto`` ports), will be used instead of ``http://{host}:{port}`` in case if set, string, optional. This option is required in case if ``OAuth`` provider is used.
|
||||
* ``autorefresh_intervals`` - enable page auto refresh options, space separated list of integers, optional. The first defined interval will be used as default. If no intervals set, the auto refresh buttons will be disabled. If first element of the list equals ``0``, auto refresh will be disabled by default.
|
||||
* ``cors_allow_headers`` - allowed CORS headers, space separated list of strings, optional.
|
||||
* ``cors_allow_methods`` - allowed CORS methods, space separated list of strings, optional.
|
||||
* ``cors_allow_origins`` - allowed CORS origins, space separated list of strings, optional, default ``*``.
|
||||
* ``cors_expose_headers`` - exposed CORS headers, space separated list of strings, optional.
|
||||
* ``enable_archive_upload`` - allow to upload packages via HTTP (i.e. call of ``/api/v1/service/upload`` uri), boolean, optional, default ``no``.
|
||||
* ``host`` - host to bind, string, optional.
|
||||
* ``index_url`` - full URL of the repository index page, string, optional.
|
||||
* ``max_body_size`` - max body size in bytes to be validated for archive upload, integer, optional. If not set, validation will be disabled.
|
||||
* ``max_queue_size`` - max queue size for server sent event streams, integer, optional, default ``0``. If set to ``0``, queue is unlimited.
|
||||
* ``port`` - port to bind, integer, optional.
|
||||
* ``service_only`` - disable status routes (including logs), boolean, optional, default ``no``.
|
||||
* ``static_path`` - path to directory with static files, string, required.
|
||||
@@ -196,7 +191,7 @@ Web server settings. This feature requires ``aiohttp`` libraries to be installed
|
||||
* ``templates`` - path to templates directories, space separated list of paths, required.
|
||||
* ``unix_socket`` - path to the listening unix socket, string, optional. If set, server will create the socket on the specified address which can (and will) be used by application. Note, that unlike usual host/port configuration, unix socket allows to perform requests without authorization.
|
||||
* ``unix_socket_unsafe`` - set unsafe (o+w) permissions to unix socket, boolean, optional, default ``yes``. This option is enabled by default, because it is supposed that unix socket is created in safe environment (only web service is supposed to be used in unsafe), but it can be disabled by configuration.
|
||||
* ``wait_timeout`` - wait timeout in seconds, maximum amount of time to be waited before lock will be free, integer, optional. If set to ``0``, wait infinitely.
|
||||
* ``wait_timeout`` - wait timeout in seconds, maximum amount of time to be waited before lock will be free, integer, optional.
|
||||
|
||||
``archive`` group
|
||||
-----------------
|
||||
|
||||
@@ -33,28 +33,3 @@ The service provides several commands aim to do easy repository backup and resto
|
||||
.. code-block:: shell
|
||||
|
||||
sudo -u ahriman ahriman repo-rebuild --from-database
|
||||
|
||||
Package rollback
|
||||
================
|
||||
|
||||
If the ``archive.keep_built_packages`` option is enabled, the service keeps previously built package files in the archive directory. These archives can be used to rollback a package to a previous successfully built version.
|
||||
|
||||
#.
|
||||
List available archive versions for a package:
|
||||
|
||||
.. code-block:: shell
|
||||
|
||||
ahriman package-archives ahriman
|
||||
|
||||
#.
|
||||
Rollback the package to the desired version:
|
||||
|
||||
.. code-block:: shell
|
||||
|
||||
sudo -u ahriman ahriman package-rollback ahriman 2.19.0-1
|
||||
|
||||
By default, the ``--hold`` flag is enabled, which prevents the package from being automatically updated on subsequent ``repo-update`` runs. To rollback without holding the package use:
|
||||
|
||||
.. code-block:: shell
|
||||
|
||||
sudo -u ahriman ahriman package-rollback ahriman 2.19.0-1 --no-hold
|
||||
|
||||
@@ -7,13 +7,10 @@ aiohttp==3.11.18
|
||||
# ahriman (pyproject.toml)
|
||||
# aiohttp-cors
|
||||
# aiohttp-jinja2
|
||||
# aiohttp-sse
|
||||
aiohttp-cors==0.8.1
|
||||
# via ahriman (pyproject.toml)
|
||||
aiohttp-jinja2==1.6
|
||||
# via ahriman (pyproject.toml)
|
||||
aiohttp-sse==2.2.0
|
||||
# via ahriman (pyproject.toml)
|
||||
aiosignal==1.3.2
|
||||
# via aiohttp
|
||||
alabaster==1.0.0
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import js from "@eslint/js";
|
||||
import stylistic from "@stylistic/eslint-plugin";
|
||||
import react from "eslint-plugin-react";
|
||||
import reactHooks from "eslint-plugin-react-hooks";
|
||||
import reactRefresh from "eslint-plugin-react-refresh";
|
||||
import simpleImportSort from "eslint-plugin-simple-import-sort";
|
||||
@@ -9,11 +8,7 @@ import tseslint from "typescript-eslint";
|
||||
export default tseslint.config(
|
||||
{ ignores: ["dist"] },
|
||||
{
|
||||
extends: [
|
||||
js.configs.recommended,
|
||||
react.configs.flat.recommended,
|
||||
...tseslint.configs.recommendedTypeChecked,
|
||||
],
|
||||
extends: [js.configs.recommended, ...tseslint.configs.recommendedTypeChecked],
|
||||
files: ["src/**/*.{ts,tsx}"],
|
||||
languageOptions: {
|
||||
parserOptions: {
|
||||
@@ -22,37 +17,31 @@ export default tseslint.config(
|
||||
},
|
||||
},
|
||||
plugins: {
|
||||
"@stylistic": stylistic,
|
||||
"react-hooks": reactHooks,
|
||||
"react-refresh": reactRefresh,
|
||||
"simple-import-sort": simpleImportSort,
|
||||
"@stylistic": stylistic,
|
||||
},
|
||||
rules: {
|
||||
...reactHooks.configs.recommended.rules,
|
||||
"react/react-in-jsx-scope": "off",
|
||||
"react-refresh/only-export-components": ["warn", { allowConstantExport: true }],
|
||||
|
||||
// imports
|
||||
"simple-import-sort/exports": "error",
|
||||
"simple-import-sort/imports": "error",
|
||||
"simple-import-sort/exports": "error",
|
||||
|
||||
// core
|
||||
// brackets
|
||||
"curly": "error",
|
||||
"eqeqeq": "error",
|
||||
"no-console": ["warn", { allow: ["warn", "error"] }],
|
||||
"no-eval": "error",
|
||||
"@stylistic/brace-style": ["error", "1tbs"],
|
||||
|
||||
// stylistic
|
||||
"@stylistic/array-bracket-spacing": ["error", "never"],
|
||||
"@stylistic/arrow-parens": ["error", "as-needed"],
|
||||
"@stylistic/brace-style": ["error", "1tbs"],
|
||||
"@stylistic/comma-dangle": ["error", "always-multiline"],
|
||||
"@stylistic/comma-spacing": ["error", { before: false, after: true }],
|
||||
"@stylistic/eol-last": ["error", "always"],
|
||||
"@stylistic/indent": ["error", 4],
|
||||
"@stylistic/jsx-curly-brace-presence": ["error", { props: "never", children: "never" }],
|
||||
"@stylistic/jsx-quotes": ["error", "prefer-double"],
|
||||
"@stylistic/jsx-self-closing-comp": ["error", { component: true, html: true }],
|
||||
"@stylistic/max-len": ["error", {
|
||||
code: 120,
|
||||
ignoreComments: true,
|
||||
@@ -60,7 +49,6 @@ export default tseslint.config(
|
||||
ignoreTemplateLiterals: true,
|
||||
ignoreUrls: true,
|
||||
}],
|
||||
"@stylistic/member-delimiter-style": ["error", { multiline: { delimiter: "semi" }, singleline: { delimiter: "semi" } }],
|
||||
"@stylistic/no-extra-parens": ["error", "all"],
|
||||
"@stylistic/no-multi-spaces": "error",
|
||||
"@stylistic/no-multiple-empty-lines": ["error", { max: 1 }],
|
||||
@@ -70,15 +58,10 @@ export default tseslint.config(
|
||||
"@stylistic/semi": ["error", "always"],
|
||||
|
||||
// typescript
|
||||
"@typescript-eslint/consistent-type-definitions": ["error", "interface"],
|
||||
"@typescript-eslint/consistent-type-imports": ["error", { prefer: "type-imports" }],
|
||||
"@typescript-eslint/explicit-function-return-type": ["error", { allowExpressions: true }],
|
||||
"@typescript-eslint/no-deprecated": "error",
|
||||
"@typescript-eslint/no-floating-promises": "error",
|
||||
"@typescript-eslint/no-unused-vars": ["error", { argsIgnorePattern: "^_" }],
|
||||
"@typescript-eslint/prefer-nullish-coalescing": "error",
|
||||
"@typescript-eslint/prefer-optional-chain": "error",
|
||||
"@typescript-eslint/switch-exhaustiveness-check": "error",
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
+30
-32
@@ -1,36 +1,8 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"@emotion/react": ">=11.14.0 <11.15.0",
|
||||
"@emotion/styled": ">=11.14.0 <11.15.0",
|
||||
"@mui/icons-material": ">=7.3.0 <7.4.0",
|
||||
"@mui/material": ">=7.3.0 <7.4.0",
|
||||
"@mui/x-data-grid": ">=8.28.0 <8.29.0",
|
||||
"@tanstack/react-query": ">=5.101.0 <5.102.0",
|
||||
"chart.js": ">=4.5.0 <4.6.0",
|
||||
"react": ">=19.2.0 <19.3.0",
|
||||
"react-chartjs-2": ">=5.3.0 <5.4.0",
|
||||
"react-dom": ">=19.2.0 <19.3.0",
|
||||
"react-error-boundary": ">=6.1.0 <6.2.0",
|
||||
"react-syntax-highlighter": ">=16.1.0 <16.2.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/js": ">=9.39.0 <9.40.0",
|
||||
"@stylistic/eslint-plugin": ">=5.10.0 <5.11.0",
|
||||
"@types/react": ">=19.2.0 <19.3.0",
|
||||
"@types/react-dom": ">=19.2.0 <19.3.0",
|
||||
"@types/react-syntax-highlighter": ">=15.5.0 <15.6.0",
|
||||
"@vitejs/plugin-react": ">=6.0.0 <6.1.0",
|
||||
"eslint": ">=9.39.0 <9.40.0",
|
||||
"eslint-plugin-react": ">=7.37.0 <7.38.0",
|
||||
"eslint-plugin-react-hooks": ">=7.1.0 <7.2.0",
|
||||
"eslint-plugin-react-refresh": ">=0.5.0 <0.6.0",
|
||||
"eslint-plugin-simple-import-sort": ">=12.1.0 <12.2.0",
|
||||
"typescript": ">=5.9.0 <5.10.0",
|
||||
"typescript-eslint": ">=8.57.0 <8.58.0",
|
||||
"vite": ">=8.1.0 <8.2.0"
|
||||
},
|
||||
"name": "ahriman-frontend",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"version": "2.20.0-rc4",
|
||||
"scripts": {
|
||||
"build": "tsc && vite build",
|
||||
"dev": "vite",
|
||||
@@ -38,6 +10,32 @@
|
||||
"lint:fix": "eslint --fix src/",
|
||||
"preview": "vite preview"
|
||||
},
|
||||
"type": "module",
|
||||
"version": "2.20.0"
|
||||
"dependencies": {
|
||||
"@emotion/react": "^11.11.0",
|
||||
"@emotion/styled": "^11.11.0",
|
||||
"@mui/icons-material": "^7.3.8",
|
||||
"@mui/material": "^7.3.8",
|
||||
"@mui/x-data-grid": "^8.27.3",
|
||||
"@tanstack/react-query": "^5.0.0",
|
||||
"chart.js": "^4.5.0",
|
||||
"highlight.js": "^11.11.0",
|
||||
"react": "^19.2.4",
|
||||
"react-chartjs-2": "^5.2.0",
|
||||
"react-dom": "^19.2.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/js": "^9.39.3",
|
||||
"@stylistic/eslint-plugin": "^5.9.0",
|
||||
"@types/react": "^19.2.14",
|
||||
"@types/react-dom": "^19.2.3",
|
||||
"@vitejs/plugin-react": "^5.0.0",
|
||||
"eslint": "^9.39.3",
|
||||
"eslint-plugin-react-hooks": "^7.0.1",
|
||||
"eslint-plugin-react-refresh": "^0.5.2",
|
||||
"eslint-plugin-simple-import-sort": "^12.1.1",
|
||||
"typescript": "^5.3.0",
|
||||
"typescript-eslint": "^8.56.1",
|
||||
"vite": "^7.3.1",
|
||||
"vite-tsconfig-paths": "^6.1.1"
|
||||
}
|
||||
}
|
||||
|
||||
+13
-10
@@ -17,38 +17,41 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import CssBaseline from "@mui/material/CssBaseline";
|
||||
import { ThemeProvider } from "@mui/material/styles";
|
||||
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
||||
import AppLayout from "components/layout/AppLayout";
|
||||
import { AuthProvider } from "contexts/AuthProvider";
|
||||
import { ClientProvider } from "contexts/ClientProvider";
|
||||
import { EventStreamProvider } from "contexts/EventStreamProvider";
|
||||
import { NotificationProvider } from "contexts/NotificationProvider";
|
||||
import { RepositoryProvider } from "contexts/RepositoryProvider";
|
||||
import { ThemeProvider } from "contexts/ThemeProvider";
|
||||
import type React from "react";
|
||||
import Theme from "theme/Theme";
|
||||
|
||||
const queryClient = new QueryClient({
|
||||
defaultOptions: {
|
||||
queries: {
|
||||
staleTime: 30_000,
|
||||
retry: 1,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export default function App(): React.JSX.Element {
|
||||
return <QueryClientProvider client={queryClient}>
|
||||
<ThemeProvider>
|
||||
<NotificationProvider>
|
||||
return (
|
||||
<QueryClientProvider client={queryClient}>
|
||||
<ThemeProvider theme={Theme}>
|
||||
<CssBaseline />
|
||||
<ClientProvider>
|
||||
<AuthProvider>
|
||||
<RepositoryProvider>
|
||||
<EventStreamProvider>
|
||||
<NotificationProvider>
|
||||
<AppLayout />
|
||||
</EventStreamProvider>
|
||||
</NotificationProvider>
|
||||
</RepositoryProvider>
|
||||
</AuthProvider>
|
||||
</ClientProvider>
|
||||
</NotificationProvider>
|
||||
</ThemeProvider>
|
||||
</QueryClientProvider>;
|
||||
</ThemeProvider>
|
||||
</QueryClientProvider>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -17,15 +17,14 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import { Client } from "api/client/Client";
|
||||
import { FetchClient } from "api/client/FetchClient";
|
||||
import { ServiceClient } from "api/client/ServiceClient";
|
||||
import { BaseClient } from "api/client/BaseClient";
|
||||
import { FetchMixin } from "api/client/FetchMixin";
|
||||
import { ServiceMixin } from "api/client/ServiceMixin";
|
||||
import type { LoginRequest } from "models/LoginRequest";
|
||||
import { applyMixins } from "utils";
|
||||
|
||||
export class AhrimanClient extends Client {
|
||||
|
||||
readonly fetch = new FetchClient(this);
|
||||
readonly service = new ServiceClient(this);
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-declaration-merging */
|
||||
export class AhrimanClient extends BaseClient {
|
||||
|
||||
async login(data: LoginRequest): Promise<void> {
|
||||
return this.request("/api/v1/login", { method: "POST", json: data });
|
||||
@@ -35,3 +34,7 @@ export class AhrimanClient extends Client {
|
||||
return this.request("/api/v1/logout", { method: "POST" });
|
||||
}
|
||||
}
|
||||
|
||||
export interface AhrimanClient extends FetchMixin, ServiceMixin {}
|
||||
/* eslint-enable @typescript-eslint/no-unsafe-declaration-merging */
|
||||
applyMixins(AhrimanClient, [FetchMixin, ServiceMixin]);
|
||||
|
||||
@@ -18,10 +18,9 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
export class ApiError extends Error {
|
||||
|
||||
body: string;
|
||||
status: number;
|
||||
statusText: string;
|
||||
body: string;
|
||||
|
||||
constructor(status: number, statusText: string, body: string) {
|
||||
super(`${status} ${statusText}`);
|
||||
|
||||
@@ -20,12 +20,10 @@
|
||||
import { ApiError } from "api/client/ApiError";
|
||||
import type { RequestOptions } from "api/client/RequestOptions";
|
||||
|
||||
export class Client {
|
||||
export class BaseClient {
|
||||
|
||||
private static readonly DEFAULT_TIMEOUT = 30_000;
|
||||
|
||||
async request<T>(url: string, options: RequestOptions = {}): Promise<T> {
|
||||
const { method, query, json, timeout = Client.DEFAULT_TIMEOUT } = options;
|
||||
protected async request<T>(url: string, options: RequestOptions = {}): Promise<T> {
|
||||
const { method, query, json } = options;
|
||||
|
||||
let fullUrl = url;
|
||||
if (query) {
|
||||
@@ -40,41 +38,35 @@ export class Client {
|
||||
|
||||
const headers: Record<string, string> = {
|
||||
Accept: "application/json",
|
||||
"X-Request-ID": crypto.randomUUID?.() ?? Date.now().toString(),
|
||||
};
|
||||
if (json !== undefined) {
|
||||
headers["Content-Type"] = "application/json";
|
||||
}
|
||||
|
||||
const controller = new AbortController();
|
||||
const timeoutId = setTimeout(() => controller.abort(), timeout);
|
||||
|
||||
const requestInit: RequestInit = {
|
||||
method: method ?? (json ? "POST" : "GET"),
|
||||
method: method || (json ? "POST" : "GET"),
|
||||
headers,
|
||||
signal: controller.signal,
|
||||
};
|
||||
|
||||
if (json !== undefined) {
|
||||
requestInit.body = JSON.stringify(json);
|
||||
}
|
||||
|
||||
let response: Response;
|
||||
try {
|
||||
response = await fetch(fullUrl, requestInit);
|
||||
} finally {
|
||||
clearTimeout(timeoutId);
|
||||
}
|
||||
const response = await fetch(fullUrl, requestInit);
|
||||
|
||||
if (!response.ok) {
|
||||
const body = await response.text();
|
||||
throw new ApiError(response.status, response.statusText, body);
|
||||
}
|
||||
|
||||
const contentType = response.headers.get("Content-Type") ?? "";
|
||||
if (!contentType.includes("application/json")) {
|
||||
if (response.redirected) {
|
||||
return undefined as T;
|
||||
}
|
||||
return await response.json() as T;
|
||||
|
||||
const contentType = response.headers.get("Content-Type") ?? "";
|
||||
if (contentType.includes("application/json")) {
|
||||
return await response.json() as T;
|
||||
}
|
||||
return await response.text() as T;
|
||||
}
|
||||
}
|
||||
@@ -17,46 +17,33 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import type { Client } from "api/client/Client";
|
||||
import { BaseClient } from "api/client/BaseClient";
|
||||
import type { Changes } from "models/Changes";
|
||||
import type { Dependencies } from "models/Dependencies";
|
||||
import type { Event } from "models/Event";
|
||||
import type { InfoResponse } from "models/InfoResponse";
|
||||
import type { InternalStatus } from "models/InternalStatus";
|
||||
import type { LogRecord } from "models/LogRecord";
|
||||
import type { Package } from "models/Package";
|
||||
import type { PackageStatus } from "models/PackageStatus";
|
||||
import type { Patch } from "models/Patch";
|
||||
import { RepositoryId } from "models/RepositoryId";
|
||||
|
||||
export class FetchClient {
|
||||
|
||||
protected client: Client;
|
||||
|
||||
constructor(client: Client) {
|
||||
this.client = client;
|
||||
}
|
||||
export class FetchMixin extends BaseClient {
|
||||
|
||||
async fetchPackage(packageBase: string, repository: RepositoryId): Promise<PackageStatus[]> {
|
||||
return this.client.request<PackageStatus[]>(`/api/v1/packages/${encodeURIComponent(packageBase)}`, {
|
||||
query: repository.toQuery(),
|
||||
});
|
||||
}
|
||||
|
||||
async fetchPackageArtifacts(packageBase: string, repository: RepositoryId): Promise<Package[]> {
|
||||
return this.client.request<Package[]>(`/api/v1/packages/${encodeURIComponent(packageBase)}/archives`, {
|
||||
return this.request<PackageStatus[]>(`/api/v1/packages/${encodeURIComponent(packageBase)}`, {
|
||||
query: repository.toQuery(),
|
||||
});
|
||||
}
|
||||
|
||||
async fetchPackageChanges(packageBase: string, repository: RepositoryId): Promise<Changes> {
|
||||
return this.client.request<Changes>(`/api/v1/packages/${encodeURIComponent(packageBase)}/changes`, {
|
||||
return this.request<Changes>(`/api/v1/packages/${encodeURIComponent(packageBase)}/changes`, {
|
||||
query: repository.toQuery(),
|
||||
});
|
||||
}
|
||||
|
||||
async fetchPackageDependencies(packageBase: string, repository: RepositoryId): Promise<Dependencies> {
|
||||
return this.client.request<Dependencies>(`/api/v1/packages/${encodeURIComponent(packageBase)}/dependencies`, {
|
||||
return this.request<Dependencies>(`/api/v1/packages/${encodeURIComponent(packageBase)}/dependencies`, {
|
||||
query: repository.toQuery(),
|
||||
});
|
||||
}
|
||||
@@ -69,7 +56,7 @@ export class FetchClient {
|
||||
if (limit) {
|
||||
query.limit = limit;
|
||||
}
|
||||
return this.client.request<Event[]>("/api/v1/events", { query });
|
||||
return this.request<Event[]>("/api/v1/events", { query });
|
||||
}
|
||||
|
||||
async fetchPackageLogs(
|
||||
@@ -89,28 +76,26 @@ export class FetchClient {
|
||||
if (head) {
|
||||
query.head = true;
|
||||
}
|
||||
return this.client.request<LogRecord[]>(`/api/v2/packages/${encodeURIComponent(packageBase)}/logs`, { query });
|
||||
return this.request<LogRecord[]>(`/api/v2/packages/${encodeURIComponent(packageBase)}/logs`, { query });
|
||||
}
|
||||
|
||||
async fetchPackagePatches(packageBase: string): Promise<Patch[]> {
|
||||
return this.client.request<Patch[]>(`/api/v1/packages/${encodeURIComponent(packageBase)}/patches`);
|
||||
return this.request<Patch[]>(`/api/v1/packages/${encodeURIComponent(packageBase)}/patches`);
|
||||
}
|
||||
|
||||
async fetchPackages(repository: RepositoryId): Promise<PackageStatus[]> {
|
||||
return this.client.request<PackageStatus[]>("/api/v1/packages", { query: repository.toQuery() });
|
||||
return this.request<PackageStatus[]>("/api/v1/packages", { query: repository.toQuery() });
|
||||
}
|
||||
|
||||
async fetchServerInfo(): Promise<InfoResponse> {
|
||||
const info = await this.client.request<InfoResponse>("/api/v2/info");
|
||||
return {
|
||||
...info,
|
||||
repositories: info.repositories.map(repo =>
|
||||
new RepositoryId(repo.architecture, repo.repository),
|
||||
),
|
||||
};
|
||||
const info = await this.request<InfoResponse>("/api/v2/info");
|
||||
info.repositories = info.repositories.map(repositories =>
|
||||
new RepositoryId(repositories.architecture, repositories.repository),
|
||||
);
|
||||
return info;
|
||||
}
|
||||
|
||||
async fetchServerStatus(repository: RepositoryId): Promise<InternalStatus> {
|
||||
return this.client.request<InternalStatus>("/api/v1/status", { query: repository.toQuery() });
|
||||
return this.request<InternalStatus>("/api/v1/status", { query: repository.toQuery() });
|
||||
}
|
||||
}
|
||||
@@ -18,8 +18,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
export interface RequestOptions {
|
||||
json?: unknown;
|
||||
method?: string;
|
||||
query?: Record<string, string | number | boolean>;
|
||||
timeout?: number;
|
||||
json?: unknown;
|
||||
}
|
||||
|
||||
+11
-34
@@ -17,42 +17,27 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import type { Client } from "api/client/Client";
|
||||
import { BaseClient } from "api/client/BaseClient";
|
||||
import type { AURPackage } from "models/AURPackage";
|
||||
import type { PackageActionRequest } from "models/PackageActionRequest";
|
||||
import type { PGPKey } from "models/PGPKey";
|
||||
import type { PGPKeyRequest } from "models/PGPKeyRequest";
|
||||
import type { RepositoryId } from "models/RepositoryId";
|
||||
import type { RollbackRequest } from "models/RollbackRequest";
|
||||
|
||||
export class ServiceClient {
|
||||
|
||||
protected client: Client;
|
||||
|
||||
constructor(client: Client) {
|
||||
this.client = client;
|
||||
}
|
||||
export class ServiceMixin extends BaseClient {
|
||||
|
||||
async servicePackageAdd(repository: RepositoryId, data: PackageActionRequest): Promise<void> {
|
||||
return this.client.request("/api/v1/service/add", { method: "POST", query: repository.toQuery(), json: data });
|
||||
}
|
||||
|
||||
async servicePackageHold(packageBase: string, repository: RepositoryId, isHeld: boolean): Promise<void> {
|
||||
return this.client.request(`/api/v1/packages/${encodeURIComponent(packageBase)}/hold`, {
|
||||
method: "POST",
|
||||
query: repository.toQuery(),
|
||||
json: { is_held: isHeld },
|
||||
});
|
||||
return this.request("/api/v1/service/add", { method: "POST", query: repository.toQuery(), json: data });
|
||||
}
|
||||
|
||||
async servicePackagePatchRemove(packageBase: string, key: string): Promise<void> {
|
||||
return this.client.request(`/api/v1/packages/${encodeURIComponent(packageBase)}/patches/${encodeURIComponent(key)}`, {
|
||||
return this.request(`/api/v1/packages/${encodeURIComponent(packageBase)}/patches/${encodeURIComponent(key)}`, {
|
||||
method: "DELETE",
|
||||
});
|
||||
}
|
||||
|
||||
async servicePackageRemove(repository: RepositoryId, packages: string[]): Promise<void> {
|
||||
return this.client.request("/api/v1/service/remove", {
|
||||
return this.request("/api/v1/service/remove", {
|
||||
method: "POST",
|
||||
query: repository.toQuery(),
|
||||
json: { packages },
|
||||
@@ -60,15 +45,7 @@ export class ServiceClient {
|
||||
}
|
||||
|
||||
async servicePackageRequest(repository: RepositoryId, data: PackageActionRequest): Promise<void> {
|
||||
return this.client.request("/api/v1/service/request", {
|
||||
method: "POST",
|
||||
query: repository.toQuery(),
|
||||
json: data,
|
||||
});
|
||||
}
|
||||
|
||||
async servicePackageRollback(repository: RepositoryId, data: RollbackRequest): Promise<void> {
|
||||
return this.client.request("/api/v1/service/rollback", {
|
||||
return this.request("/api/v1/service/request", {
|
||||
method: "POST",
|
||||
query: repository.toQuery(),
|
||||
json: data,
|
||||
@@ -76,11 +53,11 @@ export class ServiceClient {
|
||||
}
|
||||
|
||||
async servicePackageSearch(query: string): Promise<AURPackage[]> {
|
||||
return this.client.request<AURPackage[]>("/api/v1/service/search", { query: { for: query } });
|
||||
return this.request<AURPackage[]>("/api/v1/service/search", { query: { for: query } });
|
||||
}
|
||||
|
||||
async servicePackageUpdate(repository: RepositoryId, data: PackageActionRequest): Promise<void> {
|
||||
return this.client.request("/api/v1/service/update", {
|
||||
return this.request("/api/v1/service/update", {
|
||||
method: "POST",
|
||||
query: repository.toQuery(),
|
||||
json: data,
|
||||
@@ -88,15 +65,15 @@ export class ServiceClient {
|
||||
}
|
||||
|
||||
async servicePGPFetch(key: string, server: string): Promise<PGPKey> {
|
||||
return this.client.request<PGPKey>("/api/v1/service/pgp", { query: { key, server } });
|
||||
return this.request<PGPKey>("/api/v1/service/pgp", { query: { key, server } });
|
||||
}
|
||||
|
||||
async servicePGPImport(data: PGPKeyRequest): Promise<void> {
|
||||
return this.client.request("/api/v1/service/pgp", { method: "POST", json: data });
|
||||
return this.request("/api/v1/service/pgp", { method: "POST", json: data });
|
||||
}
|
||||
|
||||
async serviceRebuild(repository: RepositoryId, packages: string[]): Promise<void> {
|
||||
return this.client.request("/api/v1/service/rebuild", {
|
||||
return this.request("/api/v1/service/rebuild", {
|
||||
method: "POST",
|
||||
query: repository.toQuery(),
|
||||
json: { packages },
|
||||
@@ -17,7 +17,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import { blue } from "@mui/material/colors";
|
||||
import type { Event } from "models/Event";
|
||||
import type React from "react";
|
||||
import { Line } from "react-chartjs-2";
|
||||
@@ -32,11 +31,9 @@ export default function EventDurationLineChart({ events }: EventDurationLineChar
|
||||
labels: updateEvents.map(event => new Date(event.created * 1000).toISOStringShort()),
|
||||
datasets: [
|
||||
{
|
||||
backgroundColor: blue[200],
|
||||
borderColor: blue[500],
|
||||
cubicInterpolationMode: "monotone" as const,
|
||||
data: updateEvents.map(event => event.data?.took ?? 0),
|
||||
label: "update duration, s",
|
||||
data: updateEvents.map(event => event.data?.took ?? 0),
|
||||
cubicInterpolationMode: "monotone" as const,
|
||||
tension: 0.4,
|
||||
},
|
||||
],
|
||||
|
||||
@@ -29,26 +29,26 @@ interface PackageCountBarChartProps {
|
||||
export default function PackageCountBarChart({ stats }: PackageCountBarChartProps): React.JSX.Element {
|
||||
return <Bar
|
||||
data={{
|
||||
labels: ["packages"],
|
||||
datasets: [
|
||||
{
|
||||
backgroundColor: indigo[300],
|
||||
data: [stats.bases ?? 0],
|
||||
label: "bases",
|
||||
label: "archives",
|
||||
data: [stats.packages ?? 0],
|
||||
backgroundColor: blue[500],
|
||||
},
|
||||
{
|
||||
backgroundColor: blue[500],
|
||||
data: [stats.packages ?? 0],
|
||||
label: "archives",
|
||||
label: "bases",
|
||||
data: [stats.bases ?? 0],
|
||||
backgroundColor: indigo[300],
|
||||
},
|
||||
],
|
||||
labels: ["packages"],
|
||||
}}
|
||||
options={{
|
||||
maintainAspectRatio: false,
|
||||
responsive: true,
|
||||
scales: {
|
||||
x: { stacked: true },
|
||||
y: { stacked: false },
|
||||
y: { stacked: true },
|
||||
},
|
||||
}}
|
||||
/>;
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import type { BuildStatus } from "models/BuildStatus";
|
||||
import type { BuildStatus } from "models/BuildStatus.ts";
|
||||
import type { Counters } from "models/Counters";
|
||||
import type React from "react";
|
||||
import { Pie } from "react-chartjs-2";
|
||||
@@ -30,14 +30,14 @@ interface StatusPieChartProps {
|
||||
export default function StatusPieChart({ counters }: StatusPieChartProps): React.JSX.Element {
|
||||
const labels = ["unknown", "pending", "building", "failed", "success"] as BuildStatus[];
|
||||
const data = {
|
||||
labels: labels,
|
||||
datasets: [
|
||||
{
|
||||
backgroundColor: labels.map(label => StatusColors[label]),
|
||||
data: labels.map(label => counters[label]),
|
||||
label: "packages in status",
|
||||
data: labels.map(label => counters[label]),
|
||||
backgroundColor: labels.map(label => StatusColors[label]),
|
||||
},
|
||||
],
|
||||
labels: labels,
|
||||
};
|
||||
|
||||
return <Pie data={data} options={{ responsive: true }} />;
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2026 ahriman team.
|
||||
*
|
||||
* This file is part of ahriman
|
||||
* (see https://github.com/arcan1s/ahriman).
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import CheckIcon from "@mui/icons-material/Check";
|
||||
import TimerIcon from "@mui/icons-material/Timer";
|
||||
import TimerOffIcon from "@mui/icons-material/TimerOff";
|
||||
import { IconButton, ListItemIcon, ListItemText, Menu, MenuItem, Tooltip } from "@mui/material";
|
||||
import type { AutoRefreshInterval } from "models/AutoRefreshInterval";
|
||||
import React, { useState } from "react";
|
||||
|
||||
interface AutoRefreshControlProps {
|
||||
intervals: AutoRefreshInterval[];
|
||||
currentInterval: number;
|
||||
onIntervalChange: (interval: number) => void;
|
||||
}
|
||||
|
||||
export default function AutoRefreshControl({
|
||||
intervals,
|
||||
currentInterval,
|
||||
onIntervalChange,
|
||||
}: AutoRefreshControlProps): React.JSX.Element | null {
|
||||
const [anchorEl, setAnchorEl] = useState<HTMLElement | null>(null);
|
||||
|
||||
if (intervals.length === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const enabled = currentInterval > 0;
|
||||
|
||||
return <>
|
||||
<Tooltip title="Auto-refresh">
|
||||
<IconButton
|
||||
size="small"
|
||||
onClick={event => setAnchorEl(event.currentTarget)}
|
||||
color={enabled ? "primary" : "default"}
|
||||
>
|
||||
{enabled ? <TimerIcon fontSize="small" /> : <TimerOffIcon fontSize="small" />}
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
<Menu
|
||||
anchorEl={anchorEl}
|
||||
open={Boolean(anchorEl)}
|
||||
onClose={() => setAnchorEl(null)}
|
||||
>
|
||||
<MenuItem
|
||||
selected={!enabled}
|
||||
onClick={() => {
|
||||
onIntervalChange(0);
|
||||
setAnchorEl(null);
|
||||
}}
|
||||
>
|
||||
<ListItemIcon>
|
||||
{!enabled && <CheckIcon fontSize="small" />}
|
||||
</ListItemIcon>
|
||||
<ListItemText>Off</ListItemText>
|
||||
</MenuItem>
|
||||
{intervals.map(interval =>
|
||||
<MenuItem
|
||||
key={interval.interval}
|
||||
selected={enabled && interval.interval === currentInterval}
|
||||
onClick={() => {
|
||||
onIntervalChange(interval.interval);
|
||||
setAnchorEl(null);
|
||||
}}
|
||||
>
|
||||
<ListItemIcon>
|
||||
{enabled && interval.interval === currentInterval && <CheckIcon fontSize="small" />}
|
||||
</ListItemIcon>
|
||||
<ListItemText>{interval.text}</ListItemText>
|
||||
</MenuItem>,
|
||||
)}
|
||||
</Menu>
|
||||
</>;
|
||||
}
|
||||
@@ -17,54 +17,51 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import "components/common/syntaxLanguages";
|
||||
|
||||
import { Box, useTheme } from "@mui/material";
|
||||
import { Box } from "@mui/material";
|
||||
import CopyButton from "components/common/CopyButton";
|
||||
import { useThemeMode } from "hooks/useThemeMode";
|
||||
import React, { type RefObject } from "react";
|
||||
import { Light as SyntaxHighlighter } from "react-syntax-highlighter";
|
||||
import { githubGist, vs2015 } from "react-syntax-highlighter/dist/esm/styles/hljs";
|
||||
|
||||
interface CodeBlockProps {
|
||||
content: string;
|
||||
height?: number | string;
|
||||
language?: string;
|
||||
onScroll?: () => void;
|
||||
codeRef?: RefObject<HTMLElement | null>;
|
||||
preRef?: RefObject<HTMLElement | null>;
|
||||
className?: string;
|
||||
getText: () => string;
|
||||
height?: number | string;
|
||||
onScroll?: () => void;
|
||||
wordBreak?: boolean;
|
||||
}
|
||||
|
||||
export default function CodeBlock({
|
||||
content,
|
||||
height,
|
||||
language = "text",
|
||||
onScroll,
|
||||
codeRef,
|
||||
preRef,
|
||||
className,
|
||||
getText,
|
||||
height,
|
||||
onScroll,
|
||||
wordBreak,
|
||||
}: CodeBlockProps): React.JSX.Element {
|
||||
const { mode } = useThemeMode();
|
||||
const theme = useTheme();
|
||||
|
||||
return <Box sx={{ position: "relative" }}>
|
||||
<Box
|
||||
onScroll={onScroll}
|
||||
ref={preRef}
|
||||
sx={{ overflow: "auto", height }}
|
||||
component="pre"
|
||||
onScroll={onScroll}
|
||||
sx={{
|
||||
backgroundColor: "grey.100",
|
||||
p: 2,
|
||||
borderRadius: 1,
|
||||
overflow: "auto",
|
||||
height,
|
||||
fontSize: "0.8rem",
|
||||
fontFamily: "monospace",
|
||||
...wordBreak ? { whiteSpace: "pre-wrap", wordBreak: "break-all" } : {},
|
||||
}}
|
||||
>
|
||||
<SyntaxHighlighter
|
||||
customStyle={{
|
||||
borderRadius: `${theme.shape.borderRadius}px`,
|
||||
fontSize: "0.8rem",
|
||||
padding: theme.spacing(2),
|
||||
}}
|
||||
language={language}
|
||||
style={mode === "dark" ? vs2015 : githubGist}
|
||||
wrapLongLines
|
||||
>
|
||||
{content}
|
||||
</SyntaxHighlighter>
|
||||
<code ref={codeRef} className={className}>
|
||||
{!codeRef && getText()}
|
||||
</code>
|
||||
</Box>
|
||||
<Box sx={{ position: "absolute", top: 8, right: 8 }}>
|
||||
<CopyButton getText={getText} />
|
||||
</Box>
|
||||
{content && <Box sx={{ position: "absolute", right: 8, top: 8 }}>
|
||||
<CopyButton text={content} />
|
||||
</Box>}
|
||||
</Box>;
|
||||
}
|
||||
|
||||
@@ -23,24 +23,24 @@ import { IconButton, Tooltip } from "@mui/material";
|
||||
import React, { useEffect, useRef, useState } from "react";
|
||||
|
||||
interface CopyButtonProps {
|
||||
text: string;
|
||||
getText: () => string;
|
||||
}
|
||||
|
||||
export default function CopyButton({ text }: CopyButtonProps): React.JSX.Element {
|
||||
export default function CopyButton({ getText }: CopyButtonProps): React.JSX.Element {
|
||||
const [copied, setCopied] = useState(false);
|
||||
const timer = useRef<ReturnType<typeof setTimeout>>(undefined);
|
||||
|
||||
useEffect(() => () => clearTimeout(timer.current), []);
|
||||
|
||||
const handleCopy: () => Promise<void> = async () => {
|
||||
await navigator.clipboard.writeText(text);
|
||||
await navigator.clipboard.writeText(getText());
|
||||
setCopied(true);
|
||||
clearTimeout(timer.current);
|
||||
timer.current = setTimeout(() => setCopied(false), 2000);
|
||||
};
|
||||
|
||||
return <Tooltip title={copied ? "Copied!" : "Copy"}>
|
||||
<IconButton aria-label={copied ? "Copied" : "Copy"} onClick={() => void handleCopy()} size="small">
|
||||
<IconButton size="small" aria-label={copied ? "Copied" : "Copy"} onClick={() => void handleCopy()}>
|
||||
{copied ? <CheckIcon fontSize="small" /> : <ContentCopyIcon fontSize="small" />}
|
||||
</IconButton>
|
||||
</Tooltip>;
|
||||
|
||||
@@ -28,7 +28,7 @@ interface DialogHeaderProps {
|
||||
}
|
||||
|
||||
export default function DialogHeader({ children, onClose, sx }: DialogHeaderProps): React.JSX.Element {
|
||||
return <DialogTitle sx={{ alignItems: "center", display: "flex", justifyContent: "space-between", ...sx }}>
|
||||
return <DialogTitle sx={{ display: "flex", alignItems: "center", justifyContent: "space-between", ...sx }}>
|
||||
{children}
|
||||
<IconButton aria-label="Close" onClick={onClose} size="small" sx={{ color: "inherit" }}>
|
||||
<CloseIcon />
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2026 ahriman team.
|
||||
*
|
||||
* This file is part of ahriman
|
||||
* (see https://github.com/arcan1s/ahriman).
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import { Box, Button, Typography } from "@mui/material";
|
||||
import type React from "react";
|
||||
import type { FallbackProps } from "react-error-boundary";
|
||||
|
||||
interface ErrorDetails {
|
||||
message: string;
|
||||
stack: string | undefined;
|
||||
}
|
||||
|
||||
export default function ErrorFallback({ error }: FallbackProps): React.JSX.Element {
|
||||
|
||||
const details: ErrorDetails = error instanceof Error
|
||||
? { message: error.message, stack: error.stack }
|
||||
: { message: String(error), stack: undefined };
|
||||
|
||||
return <Box role="alert" sx={{ color: "text.primary", minHeight: "100vh", p: 6 }}>
|
||||
<Typography sx={{ fontWeight: 700 }} variant="h4">
|
||||
Something went wrong
|
||||
</Typography>
|
||||
|
||||
<Typography color="error" sx={{ fontFamily: "monospace", mt: 2 }}>
|
||||
{details.message}
|
||||
</Typography>
|
||||
|
||||
{details.stack && <Typography
|
||||
component="pre"
|
||||
sx={{ color: "text.secondary", fontFamily: "monospace", fontSize: "0.75rem", mt: 3, whiteSpace: "pre-wrap", wordBreak: "break-word" }}
|
||||
>
|
||||
{details.stack}
|
||||
</Typography>}
|
||||
|
||||
<Box sx={{ display: "flex", gap: 2, mt: 4 }}>
|
||||
<Button onClick={() => window.location.reload()} variant="outlined">Reload page</Button>
|
||||
</Box>
|
||||
</Box>;
|
||||
}
|
||||
@@ -25,14 +25,14 @@ import type React from "react";
|
||||
export default function RepositorySelect({
|
||||
repositorySelect,
|
||||
}: { repositorySelect: SelectedRepositoryResult }): React.JSX.Element {
|
||||
const { repositories, currentRepository } = useRepository();
|
||||
const { repositories, current } = useRepository();
|
||||
|
||||
return <FormControl fullWidth margin="normal">
|
||||
<InputLabel>repository</InputLabel>
|
||||
<Select
|
||||
value={repositorySelect.selectedKey || (current?.key ?? "")}
|
||||
label="repository"
|
||||
onChange={event => repositorySelect.setSelectedKey(event.target.value)}
|
||||
value={repositorySelect.selectedKey || (currentRepository?.key ?? "")}
|
||||
>
|
||||
{repositories.map(repository =>
|
||||
<MenuItem key={repository.key} value={repository.key}>
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2026 ahriman team.
|
||||
*
|
||||
* This file is part of ahriman
|
||||
* (see https://github.com/arcan1s/ahriman).
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import { Light as SyntaxHighlighter } from "react-syntax-highlighter";
|
||||
import bash from "react-syntax-highlighter/dist/esm/languages/hljs/bash";
|
||||
import diff from "react-syntax-highlighter/dist/esm/languages/hljs/diff";
|
||||
import plaintext from "react-syntax-highlighter/dist/esm/languages/hljs/plaintext";
|
||||
|
||||
SyntaxHighlighter.registerLanguage("bash", bash);
|
||||
SyntaxHighlighter.registerLanguage("diff", diff);
|
||||
SyntaxHighlighter.registerLanguage("text", plaintext);
|
||||
@@ -30,23 +30,23 @@ import type React from "react";
|
||||
import { StatusHeaderStyles } from "theme/StatusColors";
|
||||
|
||||
interface DashboardDialogProps {
|
||||
onClose: () => void;
|
||||
open: boolean;
|
||||
onClose: () => void;
|
||||
}
|
||||
|
||||
export default function DashboardDialog({ onClose, open }: DashboardDialogProps): React.JSX.Element {
|
||||
export default function DashboardDialog({ open, onClose }: DashboardDialogProps): React.JSX.Element {
|
||||
const client = useClient();
|
||||
const { currentRepository } = useRepository();
|
||||
const { current } = useRepository();
|
||||
|
||||
const { data: status } = useQuery<InternalStatus>({
|
||||
queryKey: current ? QueryKeys.status(current) : ["status"],
|
||||
queryFn: current ? () => client.fetchServerStatus(current) : skipToken,
|
||||
enabled: open,
|
||||
queryFn: currentRepository ? () => client.fetch.fetchServerStatus(currentRepository) : skipToken,
|
||||
queryKey: currentRepository ? QueryKeys.status(currentRepository) : ["status"],
|
||||
});
|
||||
|
||||
const headerStyle = status ? StatusHeaderStyles[status.status.status] : {};
|
||||
|
||||
return <Dialog fullWidth maxWidth="lg" onClose={onClose} open={open}>
|
||||
return <Dialog open={open} onClose={onClose} keepMounted maxWidth="lg" fullWidth>
|
||||
<DialogHeader onClose={onClose} sx={headerStyle}>
|
||||
System health
|
||||
</DialogHeader>
|
||||
@@ -55,43 +55,43 @@ export default function DashboardDialog({ onClose, open }: DashboardDialogProps)
|
||||
{status &&
|
||||
<>
|
||||
<Grid container spacing={2} sx={{ mt: 1 }}>
|
||||
<Grid size={{ md: 3, xs: 6 }}>
|
||||
<Typography align="right" color="text.secondary" variant="body2">Repository name</Typography>
|
||||
<Grid size={{ xs: 6, md: 3 }}>
|
||||
<Typography variant="body2" color="text.secondary" align="right">Repository name</Typography>
|
||||
</Grid>
|
||||
<Grid size={{ md: 3, xs: 6 }}>
|
||||
<Grid size={{ xs: 6, md: 3 }}>
|
||||
<Typography variant="body2">{status.repository}</Typography>
|
||||
</Grid>
|
||||
<Grid size={{ md: 3, xs: 6 }}>
|
||||
<Typography align="right" color="text.secondary" variant="body2">Repository architecture</Typography>
|
||||
<Grid size={{ xs: 6, md: 3 }}>
|
||||
<Typography variant="body2" color="text.secondary" align="right">Repository architecture</Typography>
|
||||
</Grid>
|
||||
<Grid size={{ md: 3, xs: 6 }}>
|
||||
<Grid size={{ xs: 6, md: 3 }}>
|
||||
<Typography variant="body2">{status.architecture}</Typography>
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
||||
<Grid container spacing={2} sx={{ mt: 1 }}>
|
||||
<Grid size={{ md: 3, xs: 6 }}>
|
||||
<Typography align="right" color="text.secondary" variant="body2">Current status</Typography>
|
||||
<Grid size={{ xs: 6, md: 3 }}>
|
||||
<Typography variant="body2" color="text.secondary" align="right">Current status</Typography>
|
||||
</Grid>
|
||||
<Grid size={{ md: 3, xs: 6 }}>
|
||||
<Grid size={{ xs: 6, md: 3 }}>
|
||||
<Typography variant="body2">{status.status.status}</Typography>
|
||||
</Grid>
|
||||
<Grid size={{ md: 3, xs: 6 }}>
|
||||
<Typography align="right" color="text.secondary" variant="body2">Updated at</Typography>
|
||||
<Grid size={{ xs: 6, md: 3 }}>
|
||||
<Typography variant="body2" color="text.secondary" align="right">Updated at</Typography>
|
||||
</Grid>
|
||||
<Grid size={{ md: 3, xs: 6 }}>
|
||||
<Grid size={{ xs: 6, md: 3 }}>
|
||||
<Typography variant="body2">{new Date(status.status.timestamp * 1000).toISOStringShort()}</Typography>
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
||||
<Grid container spacing={2} sx={{ mt: 2 }}>
|
||||
<Grid size={{ md: 6, xs: 12 }}>
|
||||
<Box sx={{ height: 300 }}>
|
||||
<Grid size={{ xs: 12, md: 6 }}>
|
||||
<Box sx={{ maxHeight: 300 }}>
|
||||
<PackageCountBarChart stats={status.stats} />
|
||||
</Box>
|
||||
</Grid>
|
||||
<Grid size={{ md: 6, xs: 12 }}>
|
||||
<Box sx={{ alignItems: "center", display: "flex", height: 300, justifyContent: "center" }}>
|
||||
<Grid size={{ xs: 12, md: 6 }}>
|
||||
<Box sx={{ maxHeight: 300, display: "flex", justifyContent: "center", alignItems: "center" }}>
|
||||
<StatusPieChart counters={status.packages} />
|
||||
</Box>
|
||||
</Grid>
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user