forked from LaconicNetwork/kompose
Fix hostpath path translate error (#1221)
This commit is contained in:
parent
a3862b8812
commit
ae138029a1
@ -224,7 +224,7 @@ func libComposeToKomposeMapping(composeObject *project.Project) (kobject.Kompose
|
|||||||
|
|
||||||
if composeServiceConfig.Volumes != nil {
|
if composeServiceConfig.Volumes != nil {
|
||||||
for _, volume := range composeServiceConfig.Volumes.Volumes {
|
for _, volume := range composeServiceConfig.Volumes.Volumes {
|
||||||
v := normalizeVolumes(volume.String())
|
v := volume.String()
|
||||||
serviceConfig.VolList = append(serviceConfig.VolList, v)
|
serviceConfig.VolList = append(serviceConfig.VolList, v)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -416,11 +416,13 @@ func ParseVols(volNames []string, svcName string) ([]kobject.Volumes, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrapf(err, "could not parse volume %q: %v", vn, err)
|
return nil, errors.Wrapf(err, "could not parse volume %q: %v", vn, err)
|
||||||
}
|
}
|
||||||
|
v.VolumeName = normalizeVolumes(v.VolumeName)
|
||||||
v.SvcName = svcName
|
v.SvcName = svcName
|
||||||
v.MountPath = fmt.Sprintf("%s:%s", v.Host, v.Container)
|
v.MountPath = fmt.Sprintf("%s:%s", v.Host, v.Container)
|
||||||
v.PVCName = fmt.Sprintf("%s-claim%d", v.SvcName, i)
|
v.PVCName = fmt.Sprintf("%s-claim%d", v.SvcName, i)
|
||||||
volumes = append(volumes, v)
|
volumes = append(volumes, v)
|
||||||
}
|
}
|
||||||
|
|
||||||
return volumes, nil
|
return volumes, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -208,13 +208,13 @@ convert::expect_success "$cmd" "/tmp/output-os.json"
|
|||||||
# Tests related to docker-compose file in /script/test/fixtures/volume-mounts/hostpath
|
# Tests related to docker-compose file in /script/test/fixtures/volume-mounts/hostpath
|
||||||
# kubernetes test
|
# kubernetes test
|
||||||
cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/volume-mounts/hostpath/docker-compose.yml convert --stdout -j --volumes hostPath"
|
cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/volume-mounts/hostpath/docker-compose.yml convert --stdout -j --volumes hostPath"
|
||||||
hostpath=$KOMPOSE_ROOT/script/test/fixtures/volume-mounts/hostpath/data
|
hostpath=$KOMPOSE_ROOT/script/test/fixtures/volume-mounts/hostpath/data_sux
|
||||||
sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" -e "s;%HOSTPATH%;$hostpath;g" $KOMPOSE_ROOT/script/test/fixtures/volume-mounts/hostpath/output-k8s-template.json > /tmp/output-k8s.json
|
sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" -e "s;%HOSTPATH%;$hostpath;g" $KOMPOSE_ROOT/script/test/fixtures/volume-mounts/hostpath/output-k8s-template.json > /tmp/output-k8s.json
|
||||||
convert::expect_success "$cmd" "/tmp/output-k8s.json"
|
convert::expect_success "$cmd" "/tmp/output-k8s.json"
|
||||||
|
|
||||||
# openshift test
|
# openshift test
|
||||||
cmd="kompose --provider=openshift -f $KOMPOSE_ROOT/script/test/fixtures/volume-mounts/hostpath/docker-compose.yml convert --stdout -j --volumes hostPath"
|
cmd="kompose --provider=openshift -f $KOMPOSE_ROOT/script/test/fixtures/volume-mounts/hostpath/docker-compose.yml convert --stdout -j --volumes hostPath"
|
||||||
hostpath=$KOMPOSE_ROOT/script/test/fixtures/volume-mounts/hostpath/data
|
hostpath=$KOMPOSE_ROOT/script/test/fixtures/volume-mounts/hostpath/data_sux
|
||||||
sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" -e "s;%HOSTPATH%;$hostpath;g" $KOMPOSE_ROOT/script/test/fixtures/volume-mounts/hostpath/output-os-template.json > /tmp/output-os.json
|
sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" -e "s;%HOSTPATH%;$hostpath;g" $KOMPOSE_ROOT/script/test/fixtures/volume-mounts/hostpath/output-os-template.json > /tmp/output-os.json
|
||||||
convert::expect_success "$cmd" "/tmp/output-os.json"
|
convert::expect_success "$cmd" "/tmp/output-os.json"
|
||||||
|
|
||||||
|
|||||||
@ -5,4 +5,4 @@ services:
|
|||||||
ports:
|
ports:
|
||||||
- "5432"
|
- "5432"
|
||||||
volumes:
|
volumes:
|
||||||
- ./data:/var/lib/postgresql/data
|
- ./data_sux:/var/lib/postgresql/data_sux
|
||||||
@ -82,7 +82,7 @@
|
|||||||
"resources": {},
|
"resources": {},
|
||||||
"volumeMounts": [
|
"volumeMounts": [
|
||||||
{
|
{
|
||||||
"mountPath": "/var/lib/postgresql/data",
|
"mountPath": "/var/lib/postgresql/data_sux",
|
||||||
"name": "db-hostpath0"
|
"name": "db-hostpath0"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@ -104,7 +104,7 @@
|
|||||||
"volumeMounts": [
|
"volumeMounts": [
|
||||||
{
|
{
|
||||||
"name": "db-hostpath0",
|
"name": "db-hostpath0",
|
||||||
"mountPath": "/var/lib/postgresql/data"
|
"mountPath": "/var/lib/postgresql/data_sux"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user