forked from LaconicNetwork/kompose
fix: env_file configmap name length (#1743)
* fix: env_file configmap name length fix filename to configmap name transformer * fix configmap names in tests * add env-multiple fixture and test * adjust to test * disable env-multiple suite
This commit is contained in:
@@ -853,8 +853,15 @@ func GetContentFromFile(file string) (string, error) {
|
|||||||
// FormatEnvName format env name
|
// FormatEnvName format env name
|
||||||
func FormatEnvName(name string) string {
|
func FormatEnvName(name string) string {
|
||||||
envName := strings.Trim(name, "./")
|
envName := strings.Trim(name, "./")
|
||||||
|
// only take string after the last slash only if the string contains a slash
|
||||||
|
if strings.Contains(envName, "/") {
|
||||||
|
envName = envName[strings.LastIndex(envName, "/")+1:]
|
||||||
|
}
|
||||||
|
// take only last 63 chars
|
||||||
|
if len(envName) > 63 {
|
||||||
|
envName = envName[len(envName)-63:]
|
||||||
|
}
|
||||||
envName = strings.Replace(envName, ".", "-", -1)
|
envName = strings.Replace(envName, ".", "-", -1)
|
||||||
envName = strings.Replace(envName, "/", "-", -1)
|
|
||||||
return envName
|
return envName
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -296,3 +296,12 @@ os_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/env/docker-compose.yml con
|
|||||||
os_output="$KOMPOSE_ROOT/script/test/fixtures/env/output-os.yaml"
|
os_output="$KOMPOSE_ROOT/script/test/fixtures/env/output-os.yaml"
|
||||||
convert::expect_success "$k8s_cmd" "$k8s_output" || exit 1
|
convert::expect_success "$k8s_cmd" "$k8s_output" || exit 1
|
||||||
convert::expect_success "$os_cmd" "$os_output" || exit 1
|
convert::expect_success "$os_cmd" "$os_output" || exit 1
|
||||||
|
|
||||||
|
# disabled until FormatEnvName can take into account conflicting/duplicate file names
|
||||||
|
# Test env_file support for multiple env_file with the same name from different dirs
|
||||||
|
# k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/env-multiple/docker-compose.yml convert --stdout --with-kompose-annotation=false"
|
||||||
|
# k8s_output="$KOMPOSE_ROOT/script/test/fixtures/env-multiple/output-k8s.yaml"
|
||||||
|
# os_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/env-multiple/docker-compose.yml convert --provider openshift --stdout --with-kompose-annotation=false"
|
||||||
|
# os_output="$KOMPOSE_ROOT/script/test/fixtures/env-multiple/output-os.yaml"
|
||||||
|
# convert::expect_success "$k8s_cmd" "$k8s_output" || exit 1
|
||||||
|
# convert::expect_success "$os_cmd" "$os_output" || exit 1
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
version: '3'
|
||||||
|
services:
|
||||||
|
namenode:
|
||||||
|
image: bde2020/hadoop-namenode:2.0.0-hadoop2.7.4-java8
|
||||||
|
environment:
|
||||||
|
- CLUSTER_NAME=test
|
||||||
|
env_file:
|
||||||
|
- env1/hadoop-hive-namenode.env
|
||||||
|
ports:
|
||||||
|
- "50070:50070"
|
||||||
|
- "8020:8020"
|
||||||
|
another-namenode:
|
||||||
|
image: bde2020/hadoop-namenode:2.0.0-hadoop2.7.4-java8
|
||||||
|
ports:
|
||||||
|
- "50070:50070"
|
||||||
|
- "8020:8020"
|
||||||
|
env_file:
|
||||||
|
- env2/hadoop-hive-namenode.env
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
FOO=BAR
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
BAR=FOO
|
||||||
+148
@@ -0,0 +1,148 @@
|
|||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
creationTimestamp: null
|
||||||
|
labels:
|
||||||
|
io.kompose.service: another-namenode
|
||||||
|
name: another-namenode
|
||||||
|
spec:
|
||||||
|
ports:
|
||||||
|
- name: "50070"
|
||||||
|
port: 50070
|
||||||
|
targetPort: 50070
|
||||||
|
- name: "8020"
|
||||||
|
port: 8020
|
||||||
|
targetPort: 8020
|
||||||
|
selector:
|
||||||
|
io.kompose.service: another-namenode
|
||||||
|
status:
|
||||||
|
loadBalancer: {}
|
||||||
|
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
creationTimestamp: null
|
||||||
|
labels:
|
||||||
|
io.kompose.service: namenode
|
||||||
|
name: namenode
|
||||||
|
spec:
|
||||||
|
ports:
|
||||||
|
- name: "50070"
|
||||||
|
port: 50070
|
||||||
|
targetPort: 50070
|
||||||
|
- name: "8020"
|
||||||
|
port: 8020
|
||||||
|
targetPort: 8020
|
||||||
|
selector:
|
||||||
|
io.kompose.service: namenode
|
||||||
|
status:
|
||||||
|
loadBalancer: {}
|
||||||
|
|
||||||
|
---
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
creationTimestamp: null
|
||||||
|
labels:
|
||||||
|
io.kompose.service: another-namenode
|
||||||
|
name: another-namenode
|
||||||
|
spec:
|
||||||
|
replicas: 1
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
io.kompose.service: another-namenode
|
||||||
|
strategy: {}
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
creationTimestamp: null
|
||||||
|
labels:
|
||||||
|
io.kompose.network/env-default: "true"
|
||||||
|
io.kompose.service: another-namenode
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- env:
|
||||||
|
- name: BAR
|
||||||
|
valueFrom:
|
||||||
|
configMapKeyRef:
|
||||||
|
key: BAR
|
||||||
|
name: hadoop-hive-namenode-env
|
||||||
|
image: bde2020/hadoop-namenode:2.0.0-hadoop2.7.4-java8
|
||||||
|
name: another-namenode
|
||||||
|
ports:
|
||||||
|
- containerPort: 50070
|
||||||
|
hostPort: 50070
|
||||||
|
protocol: TCP
|
||||||
|
- containerPort: 8020
|
||||||
|
hostPort: 8020
|
||||||
|
protocol: TCP
|
||||||
|
resources: {}
|
||||||
|
restartPolicy: Always
|
||||||
|
status: {}
|
||||||
|
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
data:
|
||||||
|
FOO: BAR
|
||||||
|
kind: ConfigMap
|
||||||
|
metadata:
|
||||||
|
creationTimestamp: null
|
||||||
|
labels:
|
||||||
|
io.kompose.service: hadoop-hive-namenode-env
|
||||||
|
name: hadoop-hive-namenode-env
|
||||||
|
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
data:
|
||||||
|
BAR: FOO
|
||||||
|
kind: ConfigMap
|
||||||
|
metadata:
|
||||||
|
creationTimestamp: null
|
||||||
|
labels:
|
||||||
|
io.kompose.service: another-namenode-hadoop-hive-namenode-env
|
||||||
|
name: hadoop-hive-namenode-env1
|
||||||
|
|
||||||
|
---
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
creationTimestamp: null
|
||||||
|
labels:
|
||||||
|
io.kompose.service: namenode
|
||||||
|
name: namenode
|
||||||
|
spec:
|
||||||
|
replicas: 1
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
io.kompose.service: namenode
|
||||||
|
strategy: {}
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
creationTimestamp: null
|
||||||
|
labels:
|
||||||
|
io.kompose.network/env-default: "true"
|
||||||
|
io.kompose.service: namenode
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- env:
|
||||||
|
- name: CLUSTER_NAME
|
||||||
|
value: test
|
||||||
|
- name: FOO
|
||||||
|
valueFrom:
|
||||||
|
configMapKeyRef:
|
||||||
|
key: FOO
|
||||||
|
name: hadoop-hive-namenode-env
|
||||||
|
image: bde2020/hadoop-namenode:2.0.0-hadoop2.7.4-java8
|
||||||
|
name: namenode
|
||||||
|
ports:
|
||||||
|
- containerPort: 50070
|
||||||
|
hostPort: 50070
|
||||||
|
protocol: TCP
|
||||||
|
- containerPort: 8020
|
||||||
|
hostPort: 8020
|
||||||
|
protocol: TCP
|
||||||
|
resources: {}
|
||||||
|
restartPolicy: Always
|
||||||
|
status: {}
|
||||||
|
|
||||||
+230
@@ -0,0 +1,230 @@
|
|||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
creationTimestamp: null
|
||||||
|
labels:
|
||||||
|
io.kompose.service: another-namenode
|
||||||
|
name: another-namenode
|
||||||
|
spec:
|
||||||
|
ports:
|
||||||
|
- name: "50070"
|
||||||
|
port: 50070
|
||||||
|
targetPort: 50070
|
||||||
|
- name: "8020"
|
||||||
|
port: 8020
|
||||||
|
targetPort: 8020
|
||||||
|
selector:
|
||||||
|
io.kompose.service: another-namenode
|
||||||
|
status:
|
||||||
|
loadBalancer: {}
|
||||||
|
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
creationTimestamp: null
|
||||||
|
labels:
|
||||||
|
io.kompose.service: namenode
|
||||||
|
name: namenode
|
||||||
|
spec:
|
||||||
|
ports:
|
||||||
|
- name: "50070"
|
||||||
|
port: 50070
|
||||||
|
targetPort: 50070
|
||||||
|
- name: "8020"
|
||||||
|
port: 8020
|
||||||
|
targetPort: 8020
|
||||||
|
selector:
|
||||||
|
io.kompose.service: namenode
|
||||||
|
status:
|
||||||
|
loadBalancer: {}
|
||||||
|
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
data:
|
||||||
|
FOO: BAR
|
||||||
|
kind: ConfigMap
|
||||||
|
metadata:
|
||||||
|
creationTimestamp: null
|
||||||
|
labels:
|
||||||
|
io.kompose.service: hadoop-hive-namenode-env
|
||||||
|
name: hadoop-hive-namenode-env
|
||||||
|
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
data:
|
||||||
|
BAR: FOO
|
||||||
|
kind: ConfigMap
|
||||||
|
metadata:
|
||||||
|
creationTimestamp: null
|
||||||
|
labels:
|
||||||
|
io.kompose.service: another-namenode-hadoop-hive-namenode-env
|
||||||
|
name: hadoop-hive-namenode-env1
|
||||||
|
|
||||||
|
---
|
||||||
|
apiVersion: apps.openshift.io/v1
|
||||||
|
kind: DeploymentConfig
|
||||||
|
metadata:
|
||||||
|
creationTimestamp: null
|
||||||
|
labels:
|
||||||
|
io.kompose.service: another-namenode
|
||||||
|
name: another-namenode
|
||||||
|
spec:
|
||||||
|
replicas: 1
|
||||||
|
selector:
|
||||||
|
io.kompose.service: another-namenode
|
||||||
|
strategy:
|
||||||
|
resources: {}
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
creationTimestamp: null
|
||||||
|
labels:
|
||||||
|
io.kompose.network/env-default: "true"
|
||||||
|
io.kompose.service: another-namenode
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- env:
|
||||||
|
- name: BAR
|
||||||
|
valueFrom:
|
||||||
|
configMapKeyRef:
|
||||||
|
key: BAR
|
||||||
|
name: hadoop-hive-namenode-env1
|
||||||
|
image: ' '
|
||||||
|
name: another-namenode
|
||||||
|
ports:
|
||||||
|
- containerPort: 50070
|
||||||
|
hostPort: 50070
|
||||||
|
protocol: TCP
|
||||||
|
- containerPort: 8020
|
||||||
|
hostPort: 8020
|
||||||
|
protocol: TCP
|
||||||
|
resources: {}
|
||||||
|
restartPolicy: Always
|
||||||
|
test: false
|
||||||
|
triggers:
|
||||||
|
- type: ConfigChange
|
||||||
|
- imageChangeParams:
|
||||||
|
automatic: true
|
||||||
|
containerNames:
|
||||||
|
- another-namenode
|
||||||
|
from:
|
||||||
|
kind: ImageStreamTag
|
||||||
|
name: another-namenode:2.0.0-hadoop2.7.4-java8
|
||||||
|
type: ImageChange
|
||||||
|
status:
|
||||||
|
availableReplicas: 0
|
||||||
|
latestVersion: 0
|
||||||
|
observedGeneration: 0
|
||||||
|
replicas: 0
|
||||||
|
unavailableReplicas: 0
|
||||||
|
updatedReplicas: 0
|
||||||
|
|
||||||
|
---
|
||||||
|
apiVersion: image.openshift.io/v1
|
||||||
|
kind: ImageStream
|
||||||
|
metadata:
|
||||||
|
creationTimestamp: null
|
||||||
|
labels:
|
||||||
|
io.kompose.service: another-namenode
|
||||||
|
name: another-namenode
|
||||||
|
spec:
|
||||||
|
lookupPolicy:
|
||||||
|
local: false
|
||||||
|
tags:
|
||||||
|
- annotations: null
|
||||||
|
from:
|
||||||
|
kind: DockerImage
|
||||||
|
name: bde2020/hadoop-namenode:2.0.0-hadoop2.7.4-java8
|
||||||
|
generation: null
|
||||||
|
importPolicy: {}
|
||||||
|
name: 2.0.0-hadoop2.7.4-java8
|
||||||
|
referencePolicy:
|
||||||
|
type: ""
|
||||||
|
status:
|
||||||
|
dockerImageRepository: ""
|
||||||
|
|
||||||
|
---
|
||||||
|
apiVersion: apps.openshift.io/v1
|
||||||
|
kind: DeploymentConfig
|
||||||
|
metadata:
|
||||||
|
creationTimestamp: null
|
||||||
|
labels:
|
||||||
|
io.kompose.service: namenode
|
||||||
|
name: namenode
|
||||||
|
spec:
|
||||||
|
replicas: 1
|
||||||
|
selector:
|
||||||
|
io.kompose.service: namenode
|
||||||
|
strategy:
|
||||||
|
resources: {}
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
creationTimestamp: null
|
||||||
|
labels:
|
||||||
|
io.kompose.network/env-default: "true"
|
||||||
|
io.kompose.service: namenode
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- env:
|
||||||
|
- name: CLUSTER_NAME
|
||||||
|
value: test
|
||||||
|
- name: FOO
|
||||||
|
valueFrom:
|
||||||
|
configMapKeyRef:
|
||||||
|
key: FOO
|
||||||
|
name: hadoop-hive-namenode-env
|
||||||
|
image: ' '
|
||||||
|
name: namenode
|
||||||
|
ports:
|
||||||
|
- containerPort: 50070
|
||||||
|
hostPort: 50070
|
||||||
|
protocol: TCP
|
||||||
|
- containerPort: 8020
|
||||||
|
hostPort: 8020
|
||||||
|
protocol: TCP
|
||||||
|
resources: {}
|
||||||
|
restartPolicy: Always
|
||||||
|
test: false
|
||||||
|
triggers:
|
||||||
|
- type: ConfigChange
|
||||||
|
- imageChangeParams:
|
||||||
|
automatic: true
|
||||||
|
containerNames:
|
||||||
|
- namenode
|
||||||
|
from:
|
||||||
|
kind: ImageStreamTag
|
||||||
|
name: namenode:2.0.0-hadoop2.7.4-java8
|
||||||
|
type: ImageChange
|
||||||
|
status:
|
||||||
|
availableReplicas: 0
|
||||||
|
latestVersion: 0
|
||||||
|
observedGeneration: 0
|
||||||
|
replicas: 0
|
||||||
|
unavailableReplicas: 0
|
||||||
|
updatedReplicas: 0
|
||||||
|
|
||||||
|
---
|
||||||
|
apiVersion: image.openshift.io/v1
|
||||||
|
kind: ImageStream
|
||||||
|
metadata:
|
||||||
|
creationTimestamp: null
|
||||||
|
labels:
|
||||||
|
io.kompose.service: namenode
|
||||||
|
name: namenode
|
||||||
|
spec:
|
||||||
|
lookupPolicy:
|
||||||
|
local: false
|
||||||
|
tags:
|
||||||
|
- annotations: null
|
||||||
|
from:
|
||||||
|
kind: DockerImage
|
||||||
|
name: bde2020/hadoop-namenode:2.0.0-hadoop2.7.4-java8
|
||||||
|
generation: null
|
||||||
|
importPolicy: {}
|
||||||
|
name: 2.0.0-hadoop2.7.4-java8
|
||||||
|
referencePolicy:
|
||||||
|
type: ""
|
||||||
|
status:
|
||||||
|
dockerImageRepository: ""
|
||||||
|
|
||||||
+6
-6
@@ -67,12 +67,12 @@ spec:
|
|||||||
valueFrom:
|
valueFrom:
|
||||||
configMapKeyRef:
|
configMapKeyRef:
|
||||||
key: BAR
|
key: BAR
|
||||||
name: home-runner-work-kompose-kompose-script-test-fixtures-env-hadoop-hive-namenode-env
|
name: hadoop-hive-namenode-env
|
||||||
- name: FOO
|
- name: FOO
|
||||||
valueFrom:
|
valueFrom:
|
||||||
configMapKeyRef:
|
configMapKeyRef:
|
||||||
key: FOO
|
key: FOO
|
||||||
name: home-runner-work-kompose-kompose-script-test-fixtures-env-hadoop-hive-namenode-env
|
name: hadoop-hive-namenode-env
|
||||||
image: bde2020/hadoop-namenode:2.0.0-hadoop2.7.4-java8
|
image: bde2020/hadoop-namenode:2.0.0-hadoop2.7.4-java8
|
||||||
name: another-namenode
|
name: another-namenode
|
||||||
ports:
|
ports:
|
||||||
@@ -95,8 +95,8 @@ kind: ConfigMap
|
|||||||
metadata:
|
metadata:
|
||||||
creationTimestamp: null
|
creationTimestamp: null
|
||||||
labels:
|
labels:
|
||||||
io.kompose.service: another-namenode-home-runner-work-kompose-kompose-script-test-fixtures-env-hadoop-hive-namenode-env
|
io.kompose.service: another-namenode-hadoop-hive-namenode-env
|
||||||
name: home-runner-work-kompose-kompose-script-test-fixtures-env-hadoop-hive-namenode-env
|
name: hadoop-hive-namenode-env
|
||||||
|
|
||||||
---
|
---
|
||||||
apiVersion: apps/v1
|
apiVersion: apps/v1
|
||||||
@@ -125,14 +125,14 @@ spec:
|
|||||||
valueFrom:
|
valueFrom:
|
||||||
configMapKeyRef:
|
configMapKeyRef:
|
||||||
key: BAR
|
key: BAR
|
||||||
name: home-runner-work-kompose-kompose-script-test-fixtures-env-hadoop-hive-namenode-env
|
name: hadoop-hive-namenode-env
|
||||||
- name: CLUSTER_NAME
|
- name: CLUSTER_NAME
|
||||||
value: test
|
value: test
|
||||||
- name: FOO
|
- name: FOO
|
||||||
valueFrom:
|
valueFrom:
|
||||||
configMapKeyRef:
|
configMapKeyRef:
|
||||||
key: FOO
|
key: FOO
|
||||||
name: home-runner-work-kompose-kompose-script-test-fixtures-env-hadoop-hive-namenode-env
|
name: hadoop-hive-namenode-env
|
||||||
image: bde2020/hadoop-namenode:2.0.0-hadoop2.7.4-java8
|
image: bde2020/hadoop-namenode:2.0.0-hadoop2.7.4-java8
|
||||||
name: namenode
|
name: namenode
|
||||||
ports:
|
ports:
|
||||||
|
|||||||
+6
-6
@@ -49,8 +49,8 @@ kind: ConfigMap
|
|||||||
metadata:
|
metadata:
|
||||||
creationTimestamp: null
|
creationTimestamp: null
|
||||||
labels:
|
labels:
|
||||||
io.kompose.service: another-namenode-home-runner-work-kompose-kompose-script-test-fixtures-env-hadoop-hive-namenode-env
|
io.kompose.service: another-namenode-hadoop-hive-namenode-env
|
||||||
name: home-runner-work-kompose-kompose-script-test-fixtures-env-hadoop-hive-namenode-env
|
name: hadoop-hive-namenode-env
|
||||||
|
|
||||||
---
|
---
|
||||||
apiVersion: apps.openshift.io/v1
|
apiVersion: apps.openshift.io/v1
|
||||||
@@ -79,12 +79,12 @@ spec:
|
|||||||
valueFrom:
|
valueFrom:
|
||||||
configMapKeyRef:
|
configMapKeyRef:
|
||||||
key: BAR
|
key: BAR
|
||||||
name: home-runner-work-kompose-kompose-script-test-fixtures-env-hadoop-hive-namenode-env
|
name: hadoop-hive-namenode-env
|
||||||
- name: FOO
|
- name: FOO
|
||||||
valueFrom:
|
valueFrom:
|
||||||
configMapKeyRef:
|
configMapKeyRef:
|
||||||
key: FOO
|
key: FOO
|
||||||
name: home-runner-work-kompose-kompose-script-test-fixtures-env-hadoop-hive-namenode-env
|
name: hadoop-hive-namenode-env
|
||||||
image: ' '
|
image: ' '
|
||||||
name: another-namenode
|
name: another-namenode
|
||||||
ports:
|
ports:
|
||||||
@@ -166,14 +166,14 @@ spec:
|
|||||||
valueFrom:
|
valueFrom:
|
||||||
configMapKeyRef:
|
configMapKeyRef:
|
||||||
key: BAR
|
key: BAR
|
||||||
name: home-runner-work-kompose-kompose-script-test-fixtures-env-hadoop-hive-namenode-env
|
name: hadoop-hive-namenode-env
|
||||||
- name: CLUSTER_NAME
|
- name: CLUSTER_NAME
|
||||||
value: test
|
value: test
|
||||||
- name: FOO
|
- name: FOO
|
||||||
valueFrom:
|
valueFrom:
|
||||||
configMapKeyRef:
|
configMapKeyRef:
|
||||||
key: FOO
|
key: FOO
|
||||||
name: home-runner-work-kompose-kompose-script-test-fixtures-env-hadoop-hive-namenode-env
|
name: hadoop-hive-namenode-env
|
||||||
image: ' '
|
image: ' '
|
||||||
name: namenode
|
name: namenode
|
||||||
ports:
|
ports:
|
||||||
|
|||||||
Reference in New Issue
Block a user