diff --git a/pkg/loader/compose/v3.go b/pkg/loader/compose/v3.go index 49296b8b..6e88963d 100755 --- a/pkg/loader/compose/v3.go +++ b/pkg/loader/compose/v3.go @@ -164,9 +164,8 @@ func loadV3Volumes(volumes []types.ServiceVolumeConfig) []string { var volArray []string for _, vol := range volumes { - // There will *always* be Source when parsing - v := normalizeVolumes(vol.Source) + v := vol.Source if vol.Target != "" { v = v + ":" + vol.Target diff --git a/pkg/transformer/kubernetes/kubernetes.go b/pkg/transformer/kubernetes/kubernetes.go index 2c5dce4b..1565652d 100755 --- a/pkg/transformer/kubernetes/kubernetes.go +++ b/pkg/transformer/kubernetes/kubernetes.go @@ -907,7 +907,13 @@ func (k *Kubernetes) ConfigHostPathVolumeSource(path string) (*api.VolumeSource, if err != nil { return nil, err } - absPath := filepath.Join(dir, path) + absPath := path + if !filepath.IsAbs(path) { + absPath = filepath.Join(dir, path) + } + + log.Debugf("fuck path: %s,%s", path, absPath) + return &api.VolumeSource{ HostPath: &api.HostPathVolumeSource{Path: absPath}, }, nil diff --git a/script/test/cmd/tests.sh b/script/test/cmd/tests.sh index c38650a9..38ba84d4 100755 --- a/script/test/cmd/tests.sh +++ b/script/test/cmd/tests.sh @@ -218,6 +218,20 @@ 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 convert::expect_success "$cmd" "/tmp/output-os.json" +cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/volume-mounts/hostpath/docker-compose-v3.yml convert --stdout -j --volumes hostPath" +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 +convert::expect_success "$cmd" "/tmp/output-k8s.json" + +# openshift test +cmd="kompose --provider=openshift -f $KOMPOSE_ROOT/script/test/fixtures/volume-mounts/hostpath/docker-compose-v3.yml convert --stdout -j --volumes hostPath" +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 +convert::expect_success "$cmd" "/tmp/output-os.json" + + + + ###### # Tests related to docker-compose file in /script/test/fixtures/volume-mounts/volumes-from # kubernetes test diff --git a/script/test/fixtures/volume-mounts/hostpath/docker-compose-v3.yml b/script/test/fixtures/volume-mounts/hostpath/docker-compose-v3.yml new file mode 100644 index 00000000..9dc4c91e --- /dev/null +++ b/script/test/fixtures/volume-mounts/hostpath/docker-compose-v3.yml @@ -0,0 +1,8 @@ +version: '3' +services: + db: + image: postgres:10.1 + ports: + - "5432" + volumes: + - ./data_sux:/var/lib/postgresql/data_sux \ No newline at end of file