diff --git a/CONFIGURING.md b/CONFIGURING.md index 55f5feee..3c140905 100644 --- a/CONFIGURING.md +++ b/CONFIGURING.md @@ -1,6 +1,6 @@ # ahriman configuration -Some groups can be specified for each architecture separately. E.g. if there are `build` and `build_x86_64` groups it will use the option from `build_x86_64` for the `x86_64` architecture and `build` for any other (architecture specific group has higher priority). In case if both groups are presented, architecture specific options will be merged into global ones overriding them. +Some groups can be specified for each architecture separately. E.g. if there are `build` and `build:x86_64` groups it will use the option from `build:x86_64` for the `x86_64` architecture and `build` for any other (architecture specific group has higher priority). In case if both groups are presented, architecture specific options will be merged into global ones overriding them. ## `settings` group @@ -18,9 +18,9 @@ libalpm and AUR related configuration. * `repositories` - list of pacman repositories, space separated list of strings, required. * `root` - root for alpm library, string, required. -## `build_*` groups +## `build:*` groups -Build related configuration. Group name must refer to architecture, e.g. it should be `build_x86_64` for x86_64 architecture. +Build related configuration. Group name must refer to architecture, e.g. it should be `build:x86_64` for x86_64 architecture. * `archbuild_flags` - additional flags passed to `archbuild` command, space separated list of strings, optional. * `build_command` - default build command, string, required. @@ -35,9 +35,9 @@ Base repository settings. * `name` - repository name, string, required. * `root` - root path for application, string, required. -## `sign_*` groups +## `sign:*` groups -Settings for signing packages or repository. Group name must refer to architecture, e.g. it should be `sign_x86_64` for x86_64 architecture. +Settings for signing packages or repository. Group name must refer to architecture, e.g. it should be `sign:x86_64` for x86_64 architecture. * `target` - configuration flag to enable signing, space separated list of strings, required. Allowed values are `package` (sign each package separately), `repository` (sign repository database file). * `key` - default PGP key, string, required. This key will also be used for database signing if enabled. @@ -49,9 +49,9 @@ Report generation settings. * `target` - list of reports to be generated, space separated list of strings, optional. Allowed values are `html`. -### `html_*` groups +### `html:*` groups -Group name must refer to architecture, e.g. it should be `html_x86_64` for x86_64 architecture. +Group name must refer to architecture, e.g. it should be `html:x86_64` for x86_64 architecture. * `path` - path to html report file, string, required. * `homepage` - link to homepage, string, optional. @@ -64,23 +64,23 @@ Remote synchronization settings. * `target` - list of synchronizations to be used, space separated list of strings, optional. Allowed values are `rsync`, `s3`. -### `rsync_*` groups +### `rsync:*` groups -Group name must refer to architecture, e.g. it should be `rsync_x86_64` for x86_64 architecture. Requires `rsync` package to be installed. Do not forget to configure ssh for user `ahriman`. +Group name must refer to architecture, e.g. it should be `rsync:x86_64` for x86_64 architecture. Requires `rsync` package to be installed. Do not forget to configure ssh for user `ahriman`. * `command` - rsync command to run, space separated list of string, required. * `remote` - remote server to rsync (e.g. `1.2.3.4:5678:path/to/sync`), string, required. -### `s3_*` groups +### `s3:*` groups -Group name must refer to architecture, e.g. it should be `s3_x86_64` for x86_64 architecture. Requires `aws-cli` package to be installed. Do not forget to configure it for user `ahriman`. +Group name must refer to architecture, e.g. it should be `s3:x86_64` for x86_64 architecture. Requires `aws-cli` package to be installed. Do not forget to configure it for user `ahriman`. * `command` - s3 command to run, space separated list of string, required. * `bucket` - bucket name (e.g. `s3://bucket/path`), string, required. -## `web_*` groups +## `web:*` groups -Web server settings. If any of `host`/`port` is not set, web integration will be disabled. Group name must refer to architecture, e.g. it should be `web_x86_64` for x86_64 architecture. +Web server settings. If any of `host`/`port` is not set, web integration will be disabled. Group name must refer to architecture, e.g. it should be `web:x86_64` for x86_64 architecture. * `host` - host to bind, string, optional. * `port` - port to bind, int, optional. diff --git a/src/ahriman/core/configuration.py b/src/ahriman/core/configuration.py index 8a74880e..c8b6d31d 100644 --- a/src/ahriman/core/configuration.py +++ b/src/ahriman/core/configuration.py @@ -84,7 +84,7 @@ class Configuration(configparser.RawConfigParser): :param architecture: repository architecture :return: correct section name for repository specific section """ - return f"{section}_{architecture}" + return f"{section}:{architecture}" def dump(self) -> Dict[str, Dict[str, str]]: """ @@ -183,6 +183,6 @@ class Configuration(configparser.RawConfigParser): # remove any arch specific section for foreign in self.sections(): # we would like to use lambda filter here, but pylint is too dumb - if not foreign.startswith(f"{section}_"): + if not foreign.startswith(f"{section}:"): continue self.remove_section(foreign) diff --git a/tests/ahriman/core/test_configuration.py b/tests/ahriman/core/test_configuration.py index 8a977851..36fadbe7 100644 --- a/tests/ahriman/core/test_configuration.py +++ b/tests/ahriman/core/test_configuration.py @@ -25,7 +25,7 @@ def test_section_name(configuration: Configuration) -> None: """ must return architecture specific group """ - assert configuration.section_name("build", "x86_64") == "build_x86_64" + assert configuration.section_name("build", "x86_64") == "build:x86_64" def test_absolute_path_for_absolute(configuration: Configuration) -> None: @@ -60,14 +60,15 @@ def test_dump_architecture_specific(configuration: Configuration) -> None: """ dump must contain architecture specific settings """ - configuration.add_section("build_x86_64") - configuration.set("build_x86_64", "archbuild_flags", "hello flag") + section = configuration.section_name("build", "x86_64") + configuration.add_section(section) + configuration.set(section, "archbuild_flags", "hello flag") configuration.merge_sections("x86_64") dump = configuration.dump() assert dump assert "build" in dump - assert "build_x86_64" not in dump + assert section not in dump assert dump["build"]["archbuild_flags"] == "hello flag" @@ -125,9 +126,10 @@ def test_merge_sections_missing(configuration: Configuration) -> None: """ must merge create section if not exists """ + section = configuration.section_name("build", "x86_64") configuration.remove_section("build") - configuration.add_section("build_x86_64") - configuration.set("build_x86_64", "key", "value") + configuration.add_section(section) + configuration.set(section, "key", "value") configuration.merge_sections("x86_64") assert configuration.get("build", "key") == "value"