From 24006c7a00429d1a5bf67e0d019d3dee293c8498 Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Mon, 11 Mar 2024 18:14:26 +0000 Subject: [PATCH] Address comments. Signed-off-by: Adam Warner --- README.md | 8 +++++--- build-and-test.sh | 2 +- src/bash_functions.sh | 4 ++++ test/Dockerfile | 2 +- test/cmd.sh | 1 - test/tests/conftest.py | 2 +- test/tests/test_bash_functions.py | 11 ----------- test/tests/test_general.py | 6 ++---- 8 files changed, 14 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index c6c4d75..5c12981 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ services: - "53:53/udp" # Default HTTP Port - "80:80/tcp" - # Default HTTPs Port. FTL Will generate a self-signed certificate + # Default HTTPs Port. FTL will generate a self-signed certificate - "443:443/tcp" # Uncomment the below if using Pi-hole as your DHCP Server #- "67:67/udp" @@ -80,7 +80,9 @@ There are multiple different ways to run DHCP from within your Docker Pi-hole co ## Configuration -It is recommended that you use environment variables to configure the Pi-hole docker container (more details below), however if you are persisting your `/etc/pihole` directory, you may also set them via the web interface or by directly editing `pihole.toml` +It is recommended that you use environment variables to configure the Pi-hole docker container (more details below), however if you are persisting your `/etc/pihole` directory, you may choose instead to set them via the web interface or by directly editing `pihole.toml`. + +**Please Note**: Settings that are set via environment variables effectively become read-only, meaning that you will not be able to change them in the web interface or CLI. This is to ensure a "single source of truth" on the config. ### Web interface password @@ -217,7 +219,7 @@ Valid args are: ### Pi-hole features -Here are some relevant wiki pages from [Pi-hole's documentation](https://github.com/pi-hole/pi-hole/blob/master/README.md#get-help-or-connect-with-us-on-the-web). The web interface or command line tools can be used to implement changes to pihole. +Here are some relevant wiki pages from [Pi-hole's documentation](https://docs.pi-hole.net). We install all pihole utilities so the the built in [pihole commands](https://discourse.pi-hole.net/t/the-pihole-command-with-examples/738) will work via `docker exec ` like so: diff --git a/build-and-test.sh b/build-and-test.sh index 1efec10..3c34bbd 100755 --- a/build-and-test.sh +++ b/build-and-test.sh @@ -6,7 +6,7 @@ if [[ "$1" == "enter" ]]; then fi GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD | sed "s/\//-/g") -GIT_TAG=$(git describe --tags --exact-match 2> /dev/null || true) +GIT_TAG=$(git describe --tags --exact-match 2>/dev/null || true) GIT_TAG="${GIT_TAG:-$GIT_BRANCH}" PLATFORM="${PLATFORM:-linux/amd64}" diff --git a/src/bash_functions.sh b/src/bash_functions.sh index 6ea6af1..48cf90d 100644 --- a/src/bash_functions.sh +++ b/src/bash_functions.sh @@ -70,6 +70,10 @@ ensure_basic_configuration() { exit 1 fi + setup_web_password +} + +setup_web_password() { # If FTLCONF_webserver_api_password is not set if [ -z "${FTLCONF_webserver_api_password+x}" ]; then # Is this already set to something other than blank (default) in FTL's config file? (maybe in a volume mount) diff --git a/test/Dockerfile b/test/Dockerfile index 3c5e42e..2380232 100644 --- a/test/Dockerfile +++ b/test/Dockerfile @@ -1,5 +1,5 @@ ARG alpine_version="3.19" -ARG docker_version="24.0.7" +ARG docker_version="25.0.4" FROM docker:${docker_version}-cli-alpine${alpine_version} diff --git a/test/cmd.sh b/test/cmd.sh index 193585c..6324a36 100755 --- a/test/cmd.sh +++ b/test/cmd.sh @@ -8,5 +8,4 @@ docker images pihole:${GIT_TAG} python -m black ./test/tests/ # TODO: Add junitxml output and have something consume it -# 2 parallel max b/c race condition with docker fixture (I think?) py.test -vv -n auto ./test/tests/ diff --git a/test/tests/conftest.py b/test/tests/conftest.py index eb1887f..4a35063 100644 --- a/test/tests/conftest.py +++ b/test/tests/conftest.py @@ -37,7 +37,7 @@ def run_and_stream_command_output(): @pytest.fixture() def args_env(): - return '-e TZ="Europe/London" -e FTLCONF_ENV_ONLY=true' + return '-e TZ="Europe/London" -e FTLCONF_dns_upstreams="8.8.8.8"' @pytest.fixture() diff --git a/test/tests/test_bash_functions.py b/test/tests/test_bash_functions.py index 1511fb4..6178cb3 100644 --- a/test/tests/test_bash_functions.py +++ b/test/tests/test_bash_functions.py @@ -18,11 +18,9 @@ def test_ftlconf_dns_upstreams(docker): CMD_SETUP_WEB_PASSWORD = ". bash_functions.sh ; setup_web_password" -@pytest.mark.parametrize("test_args", ['-e "FTLCONF_ENV_ONLY=false"']) def test_random_password_assigned_fresh_start(docker): func = docker.run(CMD_SETUP_WEB_PASSWORD) assert "assigning random password:" in func.stdout - assert "New password set" in func.stdout @pytest.mark.parametrize( @@ -31,12 +29,3 @@ def test_random_password_assigned_fresh_start(docker): def test_password_set_by_envvar(docker): func = docker.run(CMD_SETUP_WEB_PASSWORD) assert "Assigning password defined by Environment Variable" in func.stdout - - -@pytest.mark.parametrize("test_args", ['-e "FTLCONF_ENV_ONLY=true"']) -def test_password_envonly_true(docker): - func = docker.run(CMD_SETUP_WEB_PASSWORD) - assert ( - "No password supplied via FTLCONF_webserver_api_password, but FTLCONF_ENV_ONLY is set to true, using default (none)" - in func.stdout - ) diff --git a/test/tests/test_general.py b/test/tests/test_general.py index a0f5398..78f1604 100644 --- a/test/tests/test_general.py +++ b/test/tests/test_general.py @@ -13,10 +13,8 @@ def test_pihole_gid_env_var(docker): assert "456" in func.stdout -# We immediately remove the adlists.list file so that gravity does not attempt to download a default list -# Wait 5 seconds for gravity to finish, then kill the start.sh script -# Finally, tail the FTL log to see if it shuts down cleanly -@pytest.mark.parametrize("test_args", ['-e "PH_VERBOSE=1"']) +# Wait 5 seconds for startup, then kill the start.sh script +# Finally, tail the FTL log to see if it has been shut down cleanly def test_pihole_ftl_clean_shutdown(docker): func = docker.run( """