Is your feature improvement request related to a problem? Please describe.
In container images, it is common to control specific behaviour via environment variables. However once an environment variable is set, it makes it hard for users to unset such as value.
For example, the ghcr.io/thin-edge/tedge container image sets a few environment variables to offer sensible defaults when running in a container, below shows one of the environment variables set:
# file: containers/tedge/Dockerfile
ENV TEDGE_HTTP_CLIENT_HOST=tedge
If the user wants to unset the tedge config value, then overriding the environment values when starting the container (or by building your own Dockerfile which uses ghcr.io/thin-edge/tedge as the base image) does not force the value back to it's original value. Instead it just sets it to an empty value. Below shows an example of this:
docker pull ghcr.io/thin-edge/tedge:1.4.2
docker run -it --rm \
-e "TEDGE_HTTP_CLIENT_HOST=" \
ghcr.io/thin-edge/tedge:1.4.2 tedge config list http.client.host
# Output (empty value!!!)
http.client.host=
Workaround
The clearing of the environment value could be cleared by first starting a shell, unsetting the undesired environment variable, and then starting thin-edge.io, however this is not very container friendly.
docker pull ghcr.io/thin-edge/tedge:1.4.2
docker run -it --rm \
-e TEDGE_HTTP_CLIENT_HOST= \
ghcr.io/thin-edge/tedge:1.4.2 sh -c 'unset TEDGE_HTTP_CLIENT_HOST; tedge config list http.client.host'
# Output
http.client.host=127.0.0.1
Describe the solution you'd like
For environment values, an empty value (string length of zero), should be treated the same as when the environment variable does not exist.
Below shows some of the expected output by cases
Test Case 1: Use value from env variable
TEDGE_HTTP_CLIENT_HOST=example tedge config list http.client.host
# expected:
http.client.host=example
Test Case 2: Clear env variable by setting it to an empty string
In this case, setting the env variable should result in tedge using the default value (assuming someone has not set an explicit value in the tedge.toml file).
TEDGE_HTTP_CLIENT_HOST="" tedge config list http.client.host
# expected:
http.client.host=127.0.0.1
Describe alternatives you've considered
An alternative approach would be to just not set any environment variable ENV in the provided Dockerfile, however this increases the configuration effort required by all users of the container file, and it also does not allow for users to build their own docker images which set some default values, and then allow their users to customize the behaviour.
Additional context
Is your feature improvement request related to a problem? Please describe.
In container images, it is common to control specific behaviour via environment variables. However once an environment variable is set, it makes it hard for users to unset such as value.
For example, the
ghcr.io/thin-edge/tedgecontainer image sets a few environment variables to offer sensible defaults when running in a container, below shows one of the environment variables set:# file: containers/tedge/Dockerfile ENV TEDGE_HTTP_CLIENT_HOST=tedgeIf the user wants to unset the tedge config value, then overriding the environment values when starting the container (or by building your own Dockerfile which uses
ghcr.io/thin-edge/tedgeas the base image) does not force the value back to it's original value. Instead it just sets it to an empty value. Below shows an example of this:docker pull ghcr.io/thin-edge/tedge:1.4.2 docker run -it --rm \ -e "TEDGE_HTTP_CLIENT_HOST=" \ ghcr.io/thin-edge/tedge:1.4.2 tedge config list http.client.host # Output (empty value!!!) http.client.host=Workaround
The clearing of the environment value could be cleared by first starting a shell, unsetting the undesired environment variable, and then starting thin-edge.io, however this is not very container friendly.
docker pull ghcr.io/thin-edge/tedge:1.4.2 docker run -it --rm \ -e TEDGE_HTTP_CLIENT_HOST= \ ghcr.io/thin-edge/tedge:1.4.2 sh -c 'unset TEDGE_HTTP_CLIENT_HOST; tedge config list http.client.host' # Output http.client.host=127.0.0.1Describe the solution you'd like
For environment values, an empty value (string length of zero), should be treated the same as when the environment variable does not exist.
Below shows some of the expected output by cases
Test Case 1: Use value from env variable
TEDGE_HTTP_CLIENT_HOST=example tedge config list http.client.host # expected: http.client.host=exampleTest Case 2: Clear env variable by setting it to an empty string
In this case, setting the env variable should result in tedge using the default value (assuming someone has not set an explicit value in the
tedge.tomlfile).Describe alternatives you've considered
An alternative approach would be to just not set any environment variable
ENVin the provided Dockerfile, however this increases the configuration effort required by all users of the container file, and it also does not allow for users to build their own docker images which set some default values, and then allow their users to customize the behaviour.Additional context