Skip to content

Commit 21da725

Browse files
committed
Clean target volume path
Signed-off-by: Nicolas De Loof <[email protected]>
1 parent f936ff2 commit 21da725

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

transform/volume.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
package transform
1818

1919
import (
20+
"path"
21+
2022
"github.com/compose-spec/compose-go/v2/format"
2123
"github.com/compose-spec/compose-go/v2/tree"
2224
"github.com/pkg/errors"
@@ -31,9 +33,17 @@ func transformVolumeMount(data any, p tree.Path) (any, error) {
3133
if err != nil {
3234
return nil, err
3335
}
36+
volume.Target = cleanTarget(volume.Target)
3437

3538
return encode(volume)
3639
default:
3740
return data, errors.Errorf("%s: invalid type %T for service volume mount", p, v)
3841
}
3942
}
43+
44+
func cleanTarget(target string) string {
45+
if target == "" {
46+
return ""
47+
}
48+
return path.Clean(target)
49+
}

0 commit comments

Comments
 (0)