forked from LaconicNetwork/kompose
fix: make resources names lowercase (#1755)
Signed-off-by: AhmedGrati <ahmedgrati1999@gmail.com>
This commit is contained in:
parent
ce0288b7bc
commit
fd3fee64fb
@ -463,7 +463,7 @@ func dockerComposeToKomposeMapping(composeObject *types.Project) (kobject.Kompos
|
|||||||
for _, composeServiceConfig := range composeObject.Services {
|
for _, composeServiceConfig := range composeObject.Services {
|
||||||
// Standard import
|
// Standard import
|
||||||
// No need to modify before importation
|
// No need to modify before importation
|
||||||
name := composeServiceConfig.Name
|
name := strings.ToLower(composeServiceConfig.Name)
|
||||||
serviceConfig := kobject.ServiceConfig{}
|
serviceConfig := kobject.ServiceConfig{}
|
||||||
serviceConfig.Name = name
|
serviceConfig.Name = name
|
||||||
serviceConfig.Image = composeServiceConfig.Image
|
serviceConfig.Image = composeServiceConfig.Image
|
||||||
|
|||||||
@ -315,3 +315,11 @@ export COMPOSE_FILE="$KOMPOSE_ROOT/script/test/fixtures/compose-file-env-variabl
|
|||||||
k8s_cmd="kompose convert --stdout --with-kompose-annotation=false"
|
k8s_cmd="kompose convert --stdout --with-kompose-annotation=false"
|
||||||
k8s_output="$KOMPOSE_ROOT/script/test/fixtures/compose-file-env-variable/output-k8s.yaml"
|
k8s_output="$KOMPOSE_ROOT/script/test/fixtures/compose-file-env-variable/output-k8s.yaml"
|
||||||
convert::expect_success "$k8s_cmd" "$k8s_output" || exit 1
|
convert::expect_success "$k8s_cmd" "$k8s_output" || exit 1
|
||||||
|
|
||||||
|
# Test resources names lowercase
|
||||||
|
k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/resources-lowercase/docker-compose.yaml convert --stdout --with-kompose-annotation=false"
|
||||||
|
k8s_output="$KOMPOSE_ROOT/script/test/fixtures/resources-lowercase/output-k8s.yaml"
|
||||||
|
os_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/resources-lowercase/docker-compose.yaml convert --provider openshift --stdout --with-kompose-annotation=false"
|
||||||
|
os_output="$KOMPOSE_ROOT/script/test/fixtures/resources-lowercase/output-os.yaml"
|
||||||
|
convert::expect_success "$k8s_cmd" "$k8s_output" || exit 1
|
||||||
|
convert::expect_success "$os_cmd" "$os_output" || exit 1
|
||||||
|
|||||||
6
script/test/fixtures/resources-lowercase/docker-compose.yaml
vendored
Normal file
6
script/test/fixtures/resources-lowercase/docker-compose.yaml
vendored
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
version: '3'
|
||||||
|
services:
|
||||||
|
NGINX:
|
||||||
|
image: nginx:latest
|
||||||
|
ports:
|
||||||
|
- 80:80
|
||||||
47
script/test/fixtures/resources-lowercase/output-k8s.yaml
vendored
Normal file
47
script/test/fixtures/resources-lowercase/output-k8s.yaml
vendored
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
creationTimestamp: null
|
||||||
|
labels:
|
||||||
|
io.kompose.service: nginx
|
||||||
|
name: nginx
|
||||||
|
spec:
|
||||||
|
ports:
|
||||||
|
- name: "80"
|
||||||
|
port: 80
|
||||||
|
targetPort: 80
|
||||||
|
selector:
|
||||||
|
io.kompose.service: nginx
|
||||||
|
|
||||||
|
---
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
creationTimestamp: null
|
||||||
|
labels:
|
||||||
|
io.kompose.service: nginx
|
||||||
|
name: nginx
|
||||||
|
spec:
|
||||||
|
replicas: 1
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
io.kompose.service: nginx
|
||||||
|
strategy: {}
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
creationTimestamp: null
|
||||||
|
labels:
|
||||||
|
io.kompose.network/resources-lowercase-default: "true"
|
||||||
|
io.kompose.service: nginx
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- image: nginx:latest
|
||||||
|
name: nginx
|
||||||
|
ports:
|
||||||
|
- containerPort: 80
|
||||||
|
hostPort: 80
|
||||||
|
protocol: TCP
|
||||||
|
resources: {}
|
||||||
|
restartPolicy: Always
|
||||||
|
|
||||||
80
script/test/fixtures/resources-lowercase/output-os.yaml
vendored
Normal file
80
script/test/fixtures/resources-lowercase/output-os.yaml
vendored
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
creationTimestamp: null
|
||||||
|
labels:
|
||||||
|
io.kompose.service: nginx
|
||||||
|
name: nginx
|
||||||
|
spec:
|
||||||
|
ports:
|
||||||
|
- name: "80"
|
||||||
|
port: 80
|
||||||
|
targetPort: 80
|
||||||
|
selector:
|
||||||
|
io.kompose.service: nginx
|
||||||
|
|
||||||
|
---
|
||||||
|
apiVersion: apps.openshift.io/v1
|
||||||
|
kind: DeploymentConfig
|
||||||
|
metadata:
|
||||||
|
creationTimestamp: null
|
||||||
|
labels:
|
||||||
|
io.kompose.service: nginx
|
||||||
|
name: nginx
|
||||||
|
spec:
|
||||||
|
replicas: 1
|
||||||
|
selector:
|
||||||
|
io.kompose.service: nginx
|
||||||
|
strategy:
|
||||||
|
resources: {}
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
creationTimestamp: null
|
||||||
|
labels:
|
||||||
|
io.kompose.network/resources-lowercase-default: "true"
|
||||||
|
io.kompose.service: nginx
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- image: ' '
|
||||||
|
name: nginx
|
||||||
|
ports:
|
||||||
|
- containerPort: 80
|
||||||
|
hostPort: 80
|
||||||
|
protocol: TCP
|
||||||
|
resources: {}
|
||||||
|
restartPolicy: Always
|
||||||
|
test: false
|
||||||
|
triggers:
|
||||||
|
- type: ConfigChange
|
||||||
|
- imageChangeParams:
|
||||||
|
automatic: true
|
||||||
|
containerNames:
|
||||||
|
- nginx
|
||||||
|
from:
|
||||||
|
kind: ImageStreamTag
|
||||||
|
name: nginx:latest
|
||||||
|
type: ImageChange
|
||||||
|
|
||||||
|
---
|
||||||
|
apiVersion: image.openshift.io/v1
|
||||||
|
kind: ImageStream
|
||||||
|
metadata:
|
||||||
|
creationTimestamp: null
|
||||||
|
labels:
|
||||||
|
io.kompose.service: nginx
|
||||||
|
name: nginx
|
||||||
|
spec:
|
||||||
|
lookupPolicy:
|
||||||
|
local: false
|
||||||
|
tags:
|
||||||
|
- annotations: null
|
||||||
|
from:
|
||||||
|
kind: DockerImage
|
||||||
|
name: nginx:latest
|
||||||
|
generation: null
|
||||||
|
importPolicy: {}
|
||||||
|
name: latest
|
||||||
|
referencePolicy:
|
||||||
|
type: ""
|
||||||
|
|
||||||
Loading…
Reference in New Issue
Block a user