mirror of
https://github.com/arcan1s/ahriman.git
synced 2025-04-24 23:37:18 +00:00
add salt generator to setup command instead
This commit is contained in:
parent
8e9da5baab
commit
b80ea80e9d
@ -875,6 +875,8 @@ def _set_service_setup_parser(root: SubParserAction) -> argparse.ArgumentParser:
|
|||||||
parser.add_argument("--build-command", help="build command prefix", default="ahriman")
|
parser.add_argument("--build-command", help="build command prefix", default="ahriman")
|
||||||
parser.add_argument("--from-configuration", help="path to default devtools pacman configuration",
|
parser.add_argument("--from-configuration", help="path to default devtools pacman configuration",
|
||||||
type=Path, default=Path("/usr") / "share" / "devtools" / "pacman.conf.d" / "extra.conf")
|
type=Path, default=Path("/usr") / "share" / "devtools" / "pacman.conf.d" / "extra.conf")
|
||||||
|
parser.add_argument("--generate-salt", help="generate salt for user passwords",
|
||||||
|
action=argparse.BooleanOptionalAction, default=False)
|
||||||
parser.add_argument("--makeflags-jobs", help="append MAKEFLAGS variable with parallelism set to number of cores",
|
parser.add_argument("--makeflags-jobs", help="append MAKEFLAGS variable with parallelism set to number of cores",
|
||||||
action=argparse.BooleanOptionalAction, default=True)
|
action=argparse.BooleanOptionalAction, default=True)
|
||||||
parser.add_argument("--mirror", help="use the specified explicitly mirror instead of including mirrorlist")
|
parser.add_argument("--mirror", help="use the specified explicitly mirror instead of including mirrorlist")
|
||||||
|
@ -26,6 +26,7 @@ from ahriman.application.application import Application
|
|||||||
from ahriman.application.handlers import Handler
|
from ahriman.application.handlers import Handler
|
||||||
from ahriman.core.configuration import Configuration
|
from ahriman.core.configuration import Configuration
|
||||||
from ahriman.models.repository_paths import RepositoryPaths
|
from ahriman.models.repository_paths import RepositoryPaths
|
||||||
|
from ahriman.models.user import User
|
||||||
|
|
||||||
|
|
||||||
class Setup(Handler):
|
class Setup(Handler):
|
||||||
@ -126,6 +127,9 @@ class Setup(Handler):
|
|||||||
if args.web_unix_socket is not None:
|
if args.web_unix_socket is not None:
|
||||||
configuration.set_option(section, "unix_socket", str(args.web_unix_socket))
|
configuration.set_option(section, "unix_socket", str(args.web_unix_socket))
|
||||||
|
|
||||||
|
if args.generate_salt:
|
||||||
|
configuration.set_option("auth", "salt", User.generate_password(20))
|
||||||
|
|
||||||
target = root.include / "00-setup-overrides.ini"
|
target = root.include / "00-setup-overrides.ini"
|
||||||
with target.open("w") as ahriman_configuration:
|
with target.open("w") as ahriman_configuration:
|
||||||
configuration.write(ahriman_configuration)
|
configuration.write(ahriman_configuration)
|
||||||
|
@ -26,6 +26,7 @@ def _default_args(args: argparse.Namespace) -> argparse.Namespace:
|
|||||||
args.build_as_user = "ahriman"
|
args.build_as_user = "ahriman"
|
||||||
args.build_command = "ahriman"
|
args.build_command = "ahriman"
|
||||||
args.from_configuration = Path("/usr/share/devtools/pacman.conf.d/extra.conf")
|
args.from_configuration = Path("/usr/share/devtools/pacman.conf.d/extra.conf")
|
||||||
|
args.generate_salt = True
|
||||||
args.makeflags_jobs = True
|
args.makeflags_jobs = True
|
||||||
args.mirror = "mirror"
|
args.mirror = "mirror"
|
||||||
args.multilib = True
|
args.multilib = True
|
||||||
@ -97,6 +98,7 @@ def test_configuration_create_ahriman(args: argparse.Namespace, configuration: C
|
|||||||
MockCall(Configuration.section_name("sign", "x86_64"), "key", args.sign_key),
|
MockCall(Configuration.section_name("sign", "x86_64"), "key", args.sign_key),
|
||||||
MockCall(Configuration.section_name("web", "x86_64"), "port", str(args.web_port)),
|
MockCall(Configuration.section_name("web", "x86_64"), "port", str(args.web_port)),
|
||||||
MockCall(Configuration.section_name("web", "x86_64"), "unix_socket", str(args.web_unix_socket)),
|
MockCall(Configuration.section_name("web", "x86_64"), "unix_socket", str(args.web_unix_socket)),
|
||||||
|
MockCall("auth", "salt", pytest.helpers.anyvar(str, strict=True)),
|
||||||
])
|
])
|
||||||
write_mock.assert_called_once_with(pytest.helpers.anyvar(int))
|
write_mock.assert_called_once_with(pytest.helpers.anyvar(int))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user