diff --git a/src/main/groovy/io/seqera/wave/service/k8s/K8sServiceImpl.groovy b/src/main/groovy/io/seqera/wave/service/k8s/K8sServiceImpl.groovy index 522e11c68..e95ef9dc2 100644 --- a/src/main/groovy/io/seqera/wave/service/k8s/K8sServiceImpl.groovy +++ b/src/main/groovy/io/seqera/wave/service/k8s/K8sServiceImpl.groovy @@ -168,21 +168,17 @@ class K8sServiceImpl implements K8sService { protected V1VolumeMount mountBuildStorage(Path workDir, @Nullable String storageMountPath) { assert workDir, "K8s mount build storage is mandatory" + final vol = new V1VolumeMount() + .name('build-data') + .mountPath(workDir.toString()) + if( storageMountPath ) { - final vol = new V1VolumeMount() - .name('build-data') - .mountPath(storageMountPath) // check sub-path final rel = Path.of(storageMountPath).relativize(workDir).toString() - if( rel ) + if (rel) vol.subPath(rel) - return vol - } - else { - return new V1VolumeMount() - .name('build-data') - .mountPath(workDir.toString()) } + return vol } /** diff --git a/src/test/groovy/io/seqera/wave/service/k8s/K8sServiceImplTest.groovy b/src/test/groovy/io/seqera/wave/service/k8s/K8sServiceImplTest.groovy index 3de2ac4c6..4e7f000c8 100644 --- a/src/test/groovy/io/seqera/wave/service/k8s/K8sServiceImplTest.groovy +++ b/src/test/groovy/io/seqera/wave/service/k8s/K8sServiceImplTest.groovy @@ -74,7 +74,7 @@ class K8sServiceImplTest extends Specification { result = k8sService.mountBuildStorage(Path.of('/foo/work/x1'), '/foo') then: result.name == 'build-data' - result.mountPath == '/foo' + result.mountPath == '/foo/work/x1' result.subPath == 'work/x1' when: