fix: resolve env_file variable interpolation issues by adding support for and default syntax

This commit is contained in:
yuefanxiao
2025-05-08 01:23:08 +08:00
parent 1b29e031e3
commit 22d9233f8b
9 changed files with 276 additions and 20 deletions
+8
View File
@@ -282,6 +282,14 @@ k8s_output="$KOMPOSE_ROOT/script/test/fixtures/compose-env-no-interpolation/outp
convert::expect_success "$k8s_cmd" "$k8s_output" || exit 1
convert::expect_success "$os_cmd" "$os_output" || exit 1
# Test configmap generated by env_file with variable interpolation
k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/env-lookup/compose.yaml convert --stdout --with-kompose-annotation=false"
os_cmd="kompose --provider=openshift -f $KOMPOSE_ROOT/script/test/fixtures/env-lookup/compose.yaml convert --stdout --with-kompose-annotation=false"
k8s_output="$KOMPOSE_ROOT/script/test/fixtures/env-lookup/output-k8s.yaml"
os_output="$KOMPOSE_ROOT/script/test/fixtures/env-lookup/output-os.yaml"
convert::expect_success_and_warning "$k8s_cmd" "$k8s_output" || exit 1
convert::expect_success_and_warning "$os_cmd" "$os_output" || exit 1
# Test support for subpath volume
k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/vols-subpath/compose.yaml convert --stdout --with-kompose-annotation=false"
k8s_output="$KOMPOSE_ROOT/script/test/fixtures/vols-subpath/output-k8s.yaml"
+4
View File
@@ -0,0 +1,4 @@
DOC_ENGINE=${DOC_ENGINE:-elasticsearch}
COMPOSE_PROFILES=${DOC_ENGINE}
MINIO_CONSOLE_PORT=9001
MINIO_PORT=9000
+14
View File
@@ -0,0 +1,14 @@
version: '3'
services:
minio:
image: quay.io/minio/minio:RELEASE.2023-12-20T01-00-02Z
container_name: ragflow-minio
command: server --console-address ":9001" /data
ports:
- ${MINIO_PORT}:9000
- ${MINIO_CONSOLE_PORT}:9001
env_file: .env
environment:
- DOC_ENGINE=test-env
restart: on-failure
@@ -0,0 +1,56 @@
---
apiVersion: v1
kind: Service
metadata:
labels:
io.kompose.service: minio
name: minio
spec:
ports:
- name: "9000"
port: 9000
targetPort: 9000
- name: "9001"
port: 9001
targetPort: 9001
selector:
io.kompose.service: minio
---
apiVersion: v1
kind: Pod
metadata:
labels:
io.kompose.service: minio
name: minio
spec:
containers:
- args:
- server
- --console-address
- :9001
- /data
envFrom:
- configMapRef:
name: env
image: quay.io/minio/minio:RELEASE.2023-12-20T01-00-02Z
name: ragflow-minio
ports:
- containerPort: 9000
protocol: TCP
- containerPort: 9001
protocol: TCP
restartPolicy: OnFailure
---
apiVersion: v1
data:
COMPOSE_PROFILES: test-env
DOC_ENGINE: test-env
MINIO_CONSOLE_PORT: "9001"
MINIO_PORT: "9000"
kind: ConfigMap
metadata:
labels:
io.kompose.service: minio-env
name: env
@@ -0,0 +1,56 @@
---
apiVersion: v1
kind: Service
metadata:
labels:
io.kompose.service: minio
name: minio
spec:
ports:
- name: "9000"
port: 9000
targetPort: 9000
- name: "9001"
port: 9001
targetPort: 9001
selector:
io.kompose.service: minio
---
apiVersion: v1
kind: Pod
metadata:
labels:
io.kompose.service: minio
name: minio
spec:
containers:
- args:
- server
- --console-address
- :9001
- /data
envFrom:
- configMapRef:
name: env
image: quay.io/minio/minio:RELEASE.2023-12-20T01-00-02Z
name: ragflow-minio
ports:
- containerPort: 9000
protocol: TCP
- containerPort: 9001
protocol: TCP
restartPolicy: OnFailure
---
apiVersion: v1
data:
COMPOSE_PROFILES: test-env
DOC_ENGINE: test-env
MINIO_CONSOLE_PORT: "9001"
MINIO_PORT: "9000"
kind: ConfigMap
metadata:
labels:
io.kompose.service: minio-env
name: env