-
Notifications
You must be signed in to change notification settings - Fork 792
[BUG] Fails to parse default value syntax (e.g., ${VAR:-default}) in .env File, resulting in invalid configmap #2010
Copy link
Copy link
Closed
Labels
kind/bugCategorizes issue or PR as related to a bug.Categorizes issue or PR as related to a bug.
Description
Expected Behavior
When using the env_file attribute in docker-compose.yml to load environment variables:
- Default value syntax (e.g., ${VAR:-default}) in the .env file should be parsed and resolved correctly.
- Example: DOC_ENGINE=${DOC_ENGINE:-elasticsearch} should resolve to DOC_ENGINE=elasticsearch if the variable is unset.
- The generated ConfigMap (from the .env file) should contain resolved values, not raw expressions.
- References between variables in .env (e.g., COMPOSE_PROFILES=${DOC_ENGINE}) should inherit the resolved value.
Actual Behavior
Kompose does not parse default value syntax in .env files. Instead:
- The generated ConfigMap contains malformed values (e.g., :-elasticsearch}), indicating a failure to resolve ${VAR:-default}.
Example:
apiVersion: v1
data:
DOC_ENGINE: :-elasticsearch} # Invalid syntax
COMPOSE_PROFILES: :-elasticsearch}
kind: ConfigMap
metadata:
labels:
io.kompose.service: minio-env
name: env
- Variables referencing unresolved values (e.g., COMPOSE_PROFILES=${DOC_ENGINE}) inherit the malformed syntax, breaking dependent configurations.
Steps To Reproduce
- Create docker-compose.yml:
version: '3'
services:
minio:
image: quay.io/minio/minio:latest
env_file: .env # Load variables from .env
ports:
- 9000:9000
- Create .env file with:
DOC_ENGINE=${DOC_ENGINE:-elasticsearch}
COMPOSE_PROFILES=${DOC_ENGINE} # Reference the variable with default
- Run:
kompose -f docker-compose.yml convert -c
Kompose Version
1.35.0
Docker-Compose file
version: '3'
services:
minio:
image: quay.io/minio/minio:latest
env_file: .env # Load variables from .env
ports:
- 9000:9000Anything else?
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
kind/bugCategorizes issue or PR as related to a bug.Categorizes issue or PR as related to a bug.