From f926409a3f9c85dda74bdfb8aa0d5fcdc099e793 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn-Michael=20Miehe?= Date: Mon, 24 Jan 2022 17:39:55 +0100 Subject: [PATCH] rename CONFDIR -> CONFIGDIR --- README.md | 4 ++-- example/{hello-world.project/conf => config}/html/index.html | 0 example/hello-world.project/docker-compose.yml | 4 ++-- kiwi_scp/_constants.py | 5 +++-- kiwi_scp/project.py | 2 +- kiwi_scp/scripts/kiwi.py | 2 +- kiwi_scp/service.py | 4 ++-- tests/test_service.py | 4 ++-- 8 files changed, 13 insertions(+), 12 deletions(-) rename example/{hello-world.project/conf => config}/html/index.html (100%) diff --git a/README.md b/README.md index 2b4828a..a4da112 100644 --- a/README.md +++ b/README.md @@ -112,11 +112,11 @@ networks: ``` -#### The `CONFDIR` +#### The `CONFIGDIR` Sometimes, it's convenient to re-use configuration files across projects. For this use case, create a directory named `conf` in a project. -Those will all be combined into a directory available as **${CONFDIR}** in your `docker-compose.yml` files. +Those will all be combined into a directory available as **${CONFIGDIR}** in your `docker-compose.yml` files. #### `kiwi.yml` options diff --git a/example/hello-world.project/conf/html/index.html b/example/config/html/index.html similarity index 100% rename from example/hello-world.project/conf/html/index.html rename to example/config/html/index.html diff --git a/example/hello-world.project/docker-compose.yml b/example/hello-world.project/docker-compose.yml index cdb4328..2cc054d 100644 --- a/example/hello-world.project/docker-compose.yml +++ b/example/hello-world.project/docker-compose.yml @@ -46,10 +46,10 @@ services: - "8081:8080" another-web: - # Another webserver just to show off the ${CONFDIR} variable + # Another webserver just to show off the ${CONFIGDIR} variable image: nginx:stable-alpine restart: unless-stopped ports: - "8082:80" volumes: - - "${CONFDIR}/html/index.html:/usr/share/nginx/html/index.html:ro" + - "${CONFIGDIR}/html/index.html:/usr/share/nginx/html/index.html:ro" diff --git a/kiwi_scp/_constants.py b/kiwi_scp/_constants.py index e1e54cc..e5db944 100644 --- a/kiwi_scp/_constants.py +++ b/kiwi_scp/_constants.py @@ -34,8 +34,9 @@ HEADER_KIWI_CONF_NAME = f"{KIWI_ROOT}/data/etc/kiwi_header.yml" DEFAULT_KIWI_CONF_NAME = f"{KIWI_ROOT}/data/etc/kiwi_default.yml" DEFAULT_DOCKER_COMPOSE_NAME = f"{KIWI_ROOT}/data/etc/docker-compose_default.yml" -# special config directory in projects -CONF_DIRECTORY_NAME = 'conf' +# special config directory +CONF_DIRECTORY_NAME = 'config' + # location for auxiliary Dockerfiles IMAGES_DIRECTORY_NAME = f"{KIWI_ROOT}/data/images" diff --git a/kiwi_scp/project.py b/kiwi_scp/project.py index 47e0699..5b9515d 100644 --- a/kiwi_scp/project.py +++ b/kiwi_scp/project.py @@ -49,7 +49,7 @@ class Project: "COMPOSE_PROJECT_NAME": project_name, "KIWI_HUB_NAME": kiwi_hub_name, "TARGETROOT": str(target_root_dir), - "CONFDIR": str(conf_dir), + "CONFIGDIR": str(conf_dir), "TARGETDIR": str(target_dir), }, } diff --git a/kiwi_scp/scripts/kiwi.py b/kiwi_scp/scripts/kiwi.py index 4b00c07..6f96b5d 100644 --- a/kiwi_scp/scripts/kiwi.py +++ b/kiwi_scp/scripts/kiwi.py @@ -18,7 +18,7 @@ def main(verbose: int) -> None: - Manage full instances using just your favorite version control system - Group services into projects, each with their own docker-compose.yml - Build service-specific, private docker images from Dockerfiles - - Make use of the local file system by referring to ${TARGETDIR}, ${TARGETROOT} and ${CONFDIR} in compose files + - Make use of the local file system by referring to ${TARGETDIR}, ${TARGETROOT} and ${CONFIGDIR} in compose files - Create your own instance-global variables for compose files using the kiwi.yml "environment" section """ diff --git a/kiwi_scp/service.py b/kiwi_scp/service.py index c85652f..243c2a6 100644 --- a/kiwi_scp/service.py +++ b/kiwi_scp/service.py @@ -22,7 +22,7 @@ class Service: content: CommentedMap = attr.ib() parent: "Project" = attr.ib() - _RE_CONFDIR = re.compile(r"^\s*\$(?:CONFDIR|{CONFDIR})/+(.*)$", flags=re.UNICODE) + _RE_CONFIGDIR = re.compile(r"^\s*\$(?:CONFIGDIR|{CONFIGDIR})/+(.*)$", flags=re.UNICODE) @property def configs(self) -> Generator[Path, None, None]: @@ -31,7 +31,7 @@ class Service: for volume in self.content["volumes"]: host_part = volume.split(":")[0] - cd_match = Service._RE_CONFDIR.match(host_part) + cd_match = Service._RE_CONFIGDIR.match(host_part) if cd_match: yield Path(cd_match.group(1)) diff --git a/tests/test_service.py b/tests/test_service.py index 4024bdd..a5fa324 100644 --- a/tests/test_service.py +++ b/tests/test_service.py @@ -51,8 +51,8 @@ class TestDefault: content=CommentedMap({ "image": "repo/image:tag", "volumes": [ - "${CONFDIR}/some/config:/path/to/some/config", - "$CONFDIR/other/config:/path/to/other/config", + "${CONFIGDIR}/some/config:/path/to/some/config", + "CONFIGDIR/other/config:/path/to/other/config", ] }), parent=None,