Skip to content

Commit

Permalink
Fix absolute path handling for inherited volumes
Browse files Browse the repository at this point in the history
Volumes keep unix-like absolute paths untouched, which was not the case for
inherited volumes from extended services. Fix this by using the same
method, which is used by standard volume path resolution.

Signed-off-by: Oldřich Jedlička <[email protected]>
  • Loading branch information
oldium committed Sep 8, 2022
1 parent f4cd055 commit fe74f69
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion loader/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ func loadServiceWithExtends(filename, name string, servicesDict map[string]inter
if vol.Type != types.VolumeTypeBind {
continue
}
baseService.Volumes[i].Source = absPath(baseFileParent, vol.Source)
baseService.Volumes[i].Source = resolveMaybeUnixPath(vol.Source, baseFileParent, lookupEnv)
}
}

Expand Down
6 changes: 6 additions & 0 deletions loader/loader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1834,6 +1834,12 @@ func TestLoadWithExtends(t *testing.T) {
},
Environment: types.MappingWithEquals{},
Networks: map[string]*types.ServiceNetworkConfig{"default": nil},
Volumes: []types.ServiceVolumeConfig{{
Type: "bind",
Source: "/opt/data",
Target: "/var/lib/mysql",
Bind: &types.ServiceVolumeBind{CreateHostPath: true},
}},
Scale: 1,
},
}
Expand Down
2 changes: 2 additions & 0 deletions loader/testdata/compose-test-extends-imported.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
services:
imported:
image: nginx
volumes:
- /opt/data:/var/lib/mysql

0 comments on commit fe74f69

Please sign in to comment.