* fix issue https://github.com/kubernetes/kompose/issues/1683

* add tests, die if inputfiles not specified

* fix GetComposeFileDir function and use it

* use fixed GetComposeFileDir instead of filepath.Dir

* return error instead of fatal

* add pod configmap creation to openshift
This commit is contained in:
Tomer Zait
2024-01-02 14:48:59 -05:00
committed by GitHub
parent 63f60e66fe
commit 92ca12ae5b
10 changed files with 241 additions and 11 deletions
+8
View File
@@ -142,6 +142,14 @@ os_output="$KOMPOSE_ROOT/script/test/fixtures/configmap-volume/output-os-withlab
convert::expect_success_and_warning "$k8s_cmd" "$k8s_output" || exit 1
convert::expect_success "$os_cmd" "$os_output" || exit 1
# test configmap pod generation
k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/configmap-pod/docker-compose.yml convert --stdout --with-kompose-annotation=false"
k8s_output="$KOMPOSE_ROOT/script/test/fixtures/configmap-pod/output-k8s.yaml"
os_output="$KOMPOSE_ROOT/script/test/fixtures/configmap-pod/output-os.yaml"
os_cmd="kompose --provider=openshift -f $KOMPOSE_ROOT/script/test/fixtures/configmap-pod/docker-compose.yml convert --stdout --with-kompose-annotation=false"
convert::expect_success "$k8s_cmd" "$k8s_output" || exit 1
convert::expect_success "$os_cmd" "$os_output" || exit 1
# Test that emptyDir works
k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/change-in-volume/docker-compose.yml convert --with-kompose-annotation=false --stdout --volumes emptyDir"
k8s_output="$KOMPOSE_ROOT/script/test/fixtures/change-in-volume/output-k8s-empty-vols-template.yaml"
+3
View File
@@ -0,0 +1,3 @@
# Multi-line test
FOO=BAR
BAR=FOO
+16
View File
@@ -0,0 +1,16 @@
version: '3'
services:
redis:
image: 'bitnami/redis:latest'
environment:
- ALLOW_EMPTY_PASSWORD=no
# Env file will override environment / warn!
env_file:
- "foo.env"
- bar.env
labels:
kompose.service.type: nodeport
ports:
- '6379:6379'
restart: "no"
+2
View File
@@ -0,0 +1,2 @@
# Test comment!
ALLOW_EMPTY_PASSWORD=yes
+76
View File
@@ -0,0 +1,76 @@
---
apiVersion: v1
kind: Service
metadata:
creationTimestamp: null
labels:
io.kompose.service: redis
name: redis
spec:
ports:
- name: "6379"
port: 6379
targetPort: 6379
selector:
io.kompose.service: redis
type: NodePort
---
apiVersion: v1
kind: Pod
metadata:
creationTimestamp: null
labels:
io.kompose.network/configmap-pod-default: "true"
io.kompose.service: redis
name: redis
spec:
containers:
- env:
- name: ALLOW_EMPTY_PASSWORD
valueFrom:
configMapKeyRef:
key: ALLOW_EMPTY_PASSWORD
name: foo-env
- name: BAR
valueFrom:
configMapKeyRef:
key: BAR
name: bar-env
- name: FOO
valueFrom:
configMapKeyRef:
key: FOO
name: bar-env
image: bitnami/redis:latest
name: redis
ports:
- containerPort: 6379
hostPort: 6379
protocol: TCP
resources: {}
restartPolicy: Never
---
apiVersion: v1
data:
ALLOW_EMPTY_PASSWORD: "yes"
kind: ConfigMap
metadata:
creationTimestamp: null
labels:
io.kompose.service: redis-foo-env
name: foo-env
---
apiVersion: v1
data:
BAR: FOO
FOO: BAR
kind: ConfigMap
metadata:
creationTimestamp: null
labels:
io.kompose.service: redis-bar-env
name: bar-env
+76
View File
@@ -0,0 +1,76 @@
---
apiVersion: v1
kind: Service
metadata:
creationTimestamp: null
labels:
io.kompose.service: redis
name: redis
spec:
ports:
- name: "6379"
port: 6379
targetPort: 6379
selector:
io.kompose.service: redis
type: NodePort
---
apiVersion: v1
kind: Pod
metadata:
creationTimestamp: null
labels:
io.kompose.network/configmap-pod-default: "true"
io.kompose.service: redis
name: redis
spec:
containers:
- env:
- name: ALLOW_EMPTY_PASSWORD
valueFrom:
configMapKeyRef:
key: ALLOW_EMPTY_PASSWORD
name: foo-env
- name: BAR
valueFrom:
configMapKeyRef:
key: BAR
name: bar-env
- name: FOO
valueFrom:
configMapKeyRef:
key: FOO
name: bar-env
image: bitnami/redis:latest
name: redis
ports:
- containerPort: 6379
hostPort: 6379
protocol: TCP
resources: {}
restartPolicy: Never
---
apiVersion: v1
data:
ALLOW_EMPTY_PASSWORD: "yes"
kind: ConfigMap
metadata:
creationTimestamp: null
labels:
io.kompose.service: redis-foo-env
name: foo-env
---
apiVersion: v1
data:
BAR: FOO
FOO: BAR
kind: ConfigMap
metadata:
creationTimestamp: null
labels:
io.kompose.service: redis-bar-env
name: bar-env