Skip to content

Commit 5517322

Browse files
committed
api/types: move MountPoint to api/types/container
This moves the `MountPoint` type to the container package, and deprecates the old location. Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent c130ce1 commit 5517322

11 files changed

Lines changed: 91 additions & 86 deletions

api/types/container/container.go

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import (
44
"io"
55
"os"
66
"time"
7+
8+
"github.com/docker/docker/api/types/mount"
79
)
810

911
// PruneReport contains the response for Engine API:
@@ -42,3 +44,47 @@ type StatsResponseReader struct {
4244
Body io.ReadCloser `json:"body"`
4345
OSType string `json:"ostype"`
4446
}
47+
48+
// MountPoint represents a mount point configuration inside the container.
49+
// This is used for reporting the mountpoints in use by a container.
50+
type MountPoint struct {
51+
// Type is the type of mount, see `Type<foo>` definitions in
52+
// github.com/docker/docker/api/types/mount.Type
53+
Type mount.Type `json:",omitempty"`
54+
55+
// Name is the name reference to the underlying data defined by `Source`
56+
// e.g., the volume name.
57+
Name string `json:",omitempty"`
58+
59+
// Source is the source location of the mount.
60+
//
61+
// For volumes, this contains the storage location of the volume (within
62+
// `/var/lib/docker/volumes/`). For bind-mounts, and `npipe`, this contains
63+
// the source (host) part of the bind-mount. For `tmpfs` mount points, this
64+
// field is empty.
65+
Source string
66+
67+
// Destination is the path relative to the container root (`/`) where the
68+
// Source is mounted inside the container.
69+
Destination string
70+
71+
// Driver is the volume driver used to create the volume (if it is a volume).
72+
Driver string `json:",omitempty"`
73+
74+
// Mode is a comma separated list of options supplied by the user when
75+
// creating the bind/volume mount.
76+
//
77+
// The default is platform-specific (`"z"` on Linux, empty on Windows).
78+
Mode string
79+
80+
// RW indicates whether the mount is mounted writable (read-write).
81+
RW bool
82+
83+
// Propagation describes how mounts are propagated from the host into the
84+
// mount point, and vice-versa. Refer to the Linux kernel documentation
85+
// for details:
86+
// https://www.kernel.org/doc/Documentation/filesystems/sharedsubtree.txt
87+
//
88+
// This field is not used on Windows.
89+
Propagation mount.Propagation
90+
}

api/types/types.go

Lines changed: 2 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"github.com/docker/docker/api/types/container"
77
"github.com/docker/docker/api/types/filters"
88
"github.com/docker/docker/api/types/image"
9-
"github.com/docker/docker/api/types/mount"
109
"github.com/docker/docker/api/types/swarm"
1110
"github.com/docker/docker/api/types/volume"
1211
)
@@ -155,7 +154,7 @@ type Container struct {
155154
Annotations map[string]string `json:",omitempty"`
156155
}
157156
NetworkSettings *container.NetworkSettingsSummary
158-
Mounts []MountPoint
157+
Mounts []container.MountPoint
159158
}
160159

161160
// Ping contains response of Engine API:
@@ -251,55 +250,11 @@ type ContainerJSONBase struct {
251250
// ContainerJSON is newly used struct along with MountPoint
252251
type ContainerJSON struct {
253252
*ContainerJSONBase
254-
Mounts []MountPoint
253+
Mounts []container.MountPoint
255254
Config *container.Config
256255
NetworkSettings *container.NetworkSettings
257256
}
258257

259-
// MountPoint represents a mount point configuration inside the container.
260-
// This is used for reporting the mountpoints in use by a container.
261-
type MountPoint struct {
262-
// Type is the type of mount, see `Type<foo>` definitions in
263-
// github.com/docker/docker/api/types/mount.Type
264-
Type mount.Type `json:",omitempty"`
265-
266-
// Name is the name reference to the underlying data defined by `Source`
267-
// e.g., the volume name.
268-
Name string `json:",omitempty"`
269-
270-
// Source is the source location of the mount.
271-
//
272-
// For volumes, this contains the storage location of the volume (within
273-
// `/var/lib/docker/volumes/`). For bind-mounts, and `npipe`, this contains
274-
// the source (host) part of the bind-mount. For `tmpfs` mount points, this
275-
// field is empty.
276-
Source string
277-
278-
// Destination is the path relative to the container root (`/`) where the
279-
// Source is mounted inside the container.
280-
Destination string
281-
282-
// Driver is the volume driver used to create the volume (if it is a volume).
283-
Driver string `json:",omitempty"`
284-
285-
// Mode is a comma separated list of options supplied by the user when
286-
// creating the bind/volume mount.
287-
//
288-
// The default is platform-specific (`"z"` on Linux, empty on Windows).
289-
Mode string
290-
291-
// RW indicates whether the mount is mounted writable (read-write).
292-
RW bool
293-
294-
// Propagation describes how mounts are propagated from the host into the
295-
// mount point, and vice-versa. Refer to the Linux kernel documentation
296-
// for details:
297-
// https://www.kernel.org/doc/Documentation/filesystems/sharedsubtree.txt
298-
//
299-
// This field is not used on Windows.
300-
Propagation mount.Propagation
301-
}
302-
303258
// DiskUsageObject represents an object type used for disk usage query filtering.
304259
type DiskUsageObject string
305260

api/types/types_deprecated.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,3 +249,9 @@ type Health = container.Health
249249
//
250250
// Deprecated: use [container.HealthcheckResult].
251251
type HealthcheckResult = container.HealthcheckResult
252+
253+
// MountPoint represents a mount point configuration inside the container.
254+
// This is used for reporting the mountpoints in use by a container.
255+
//
256+
// Deprecated: use [container.MountPoint].
257+
type MountPoint = container.MountPoint

container/container_unix.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010

1111
"github.com/containerd/continuity/fs"
1212
"github.com/containerd/log"
13-
"github.com/docker/docker/api/types"
1413
containertypes "github.com/docker/docker/api/types/container"
1514
"github.com/docker/docker/api/types/events"
1615
mounttypes "github.com/docker/docker/api/types/mount"
@@ -432,10 +431,10 @@ func (container *Container) TmpfsMounts() ([]Mount, error) {
432431
}
433432

434433
// GetMountPoints gives a platform specific transformation to types.MountPoint. Callers must hold a Container lock.
435-
func (container *Container) GetMountPoints() []types.MountPoint {
436-
mountPoints := make([]types.MountPoint, 0, len(container.MountPoints))
434+
func (container *Container) GetMountPoints() []containertypes.MountPoint {
435+
mountPoints := make([]containertypes.MountPoint, 0, len(container.MountPoints))
437436
for _, m := range container.MountPoints {
438-
mountPoints = append(mountPoints, types.MountPoint{
437+
mountPoints = append(mountPoints, containertypes.MountPoint{
439438
Type: m.Type,
440439
Name: m.Name,
441440
Source: m.Path(),

container/container_windows.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"os"
77
"path/filepath"
88

9-
"github.com/docker/docker/api/types"
109
containertypes "github.com/docker/docker/api/types/container"
1110
"github.com/docker/docker/api/types/events"
1211
swarmtypes "github.com/docker/docker/api/types/swarm"
@@ -188,10 +187,10 @@ func (container *Container) BuildHostnameFile() error {
188187
}
189188

190189
// GetMountPoints gives a platform specific transformation to types.MountPoint. Callers must hold a Container lock.
191-
func (container *Container) GetMountPoints() []types.MountPoint {
192-
mountPoints := make([]types.MountPoint, 0, len(container.MountPoints))
190+
func (container *Container) GetMountPoints() []containertypes.MountPoint {
191+
mountPoints := make([]containertypes.MountPoint, 0, len(container.MountPoints))
193192
for _, m := range container.MountPoints {
194-
mountPoints = append(mountPoints, types.MountPoint{
193+
mountPoints = append(mountPoints, containertypes.MountPoint{
195194
Type: m.Type,
196195
Name: m.Name,
197196
Source: m.Path(),

daemon/list.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -463,15 +463,15 @@ func includeContainerInList(container *container.Snapshot, filter *listContext)
463463
}
464464

465465
if filter.filters.Contains("volume") {
466-
volumesByName := make(map[string]types.MountPoint)
466+
volumesByName := make(map[string]containertypes.MountPoint)
467467
for _, m := range container.Mounts {
468468
if m.Name != "" {
469469
volumesByName[m.Name] = m
470470
} else {
471471
volumesByName[m.Source] = m
472472
}
473473
}
474-
volumesByDestination := make(map[string]types.MountPoint)
474+
volumesByDestination := make(map[string]containertypes.MountPoint)
475475
for _, m := range container.Mounts {
476476
if m.Destination != "" {
477477
volumesByDestination[m.Destination] = m

integration-cli/docker_api_containers_test.go

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import (
1616
"testing"
1717
"time"
1818

19-
"github.com/docker/docker/api/types"
2019
"github.com/docker/docker/api/types/container"
2120
"github.com/docker/docker/api/types/mount"
2221
"github.com/docker/docker/api/types/network"
@@ -1807,7 +1806,7 @@ func (s *DockerAPISuite) TestContainersAPICreateMountsCreate(c *testing.T) {
18071806

18081807
type testCase struct {
18091808
spec mount.Mount
1810-
expected types.MountPoint
1809+
expected container.MountPoint
18111810
}
18121811

18131812
var selinuxSharedLabel string
@@ -1820,23 +1819,23 @@ func (s *DockerAPISuite) TestContainersAPICreateMountsCreate(c *testing.T) {
18201819
// Validation of the actual `Mount` struct is done in another test is not needed here
18211820
{
18221821
spec: mount.Mount{Type: "volume", Target: destPath},
1823-
expected: types.MountPoint{Driver: volume.DefaultDriverName, Type: "volume", RW: true, Destination: destPath, Mode: selinuxSharedLabel},
1822+
expected: container.MountPoint{Driver: volume.DefaultDriverName, Type: "volume", RW: true, Destination: destPath, Mode: selinuxSharedLabel},
18241823
},
18251824
{
18261825
spec: mount.Mount{Type: "volume", Target: destPath + slash},
1827-
expected: types.MountPoint{Driver: volume.DefaultDriverName, Type: "volume", RW: true, Destination: destPath, Mode: selinuxSharedLabel},
1826+
expected: container.MountPoint{Driver: volume.DefaultDriverName, Type: "volume", RW: true, Destination: destPath, Mode: selinuxSharedLabel},
18281827
},
18291828
{
18301829
spec: mount.Mount{Type: "volume", Target: destPath, Source: "test1"},
1831-
expected: types.MountPoint{Type: "volume", Name: "test1", RW: true, Destination: destPath, Mode: selinuxSharedLabel},
1830+
expected: container.MountPoint{Type: "volume", Name: "test1", RW: true, Destination: destPath, Mode: selinuxSharedLabel},
18321831
},
18331832
{
18341833
spec: mount.Mount{Type: "volume", Target: destPath, ReadOnly: true, Source: "test2"},
1835-
expected: types.MountPoint{Type: "volume", Name: "test2", RW: false, Destination: destPath, Mode: selinuxSharedLabel},
1834+
expected: container.MountPoint{Type: "volume", Name: "test2", RW: false, Destination: destPath, Mode: selinuxSharedLabel},
18361835
},
18371836
{
18381837
spec: mount.Mount{Type: "volume", Target: destPath, Source: "test3", VolumeOptions: &mount.VolumeOptions{DriverConfig: &mount.Driver{Name: volume.DefaultDriverName}}},
1839-
expected: types.MountPoint{Driver: volume.DefaultDriverName, Type: "volume", Name: "test3", RW: true, Destination: destPath, Mode: selinuxSharedLabel},
1838+
expected: container.MountPoint{Driver: volume.DefaultDriverName, Type: "volume", Name: "test3", RW: true, Destination: destPath, Mode: selinuxSharedLabel},
18401839
},
18411840
}
18421841

@@ -1852,7 +1851,7 @@ func (s *DockerAPISuite) TestContainersAPICreateMountsCreate(c *testing.T) {
18521851
Source: tmpDir1,
18531852
Target: destPath,
18541853
},
1855-
expected: types.MountPoint{
1854+
expected: container.MountPoint{
18561855
Type: "bind",
18571856
RW: true,
18581857
Destination: destPath,
@@ -1861,7 +1860,7 @@ func (s *DockerAPISuite) TestContainersAPICreateMountsCreate(c *testing.T) {
18611860
},
18621861
{
18631862
spec: mount.Mount{Type: "bind", Source: tmpDir1, Target: destPath, ReadOnly: true},
1864-
expected: types.MountPoint{Type: "bind", RW: false, Destination: destPath, Source: tmpDir1},
1863+
expected: container.MountPoint{Type: "bind", RW: false, Destination: destPath, Source: tmpDir1},
18651864
},
18661865
}...)
18671866

@@ -1875,15 +1874,15 @@ func (s *DockerAPISuite) TestContainersAPICreateMountsCreate(c *testing.T) {
18751874
cases = append(cases, []testCase{
18761875
{
18771876
spec: mount.Mount{Type: "bind", Source: tmpDir3, Target: destPath},
1878-
expected: types.MountPoint{Type: "bind", RW: true, Destination: destPath, Source: tmpDir3},
1877+
expected: container.MountPoint{Type: "bind", RW: true, Destination: destPath, Source: tmpDir3},
18791878
},
18801879
{
18811880
spec: mount.Mount{Type: "bind", Source: tmpDir3, Target: destPath, ReadOnly: true},
1882-
expected: types.MountPoint{Type: "bind", RW: false, Destination: destPath, Source: tmpDir3},
1881+
expected: container.MountPoint{Type: "bind", RW: false, Destination: destPath, Source: tmpDir3},
18831882
},
18841883
{
18851884
spec: mount.Mount{Type: "bind", Source: tmpDir3, Target: destPath, ReadOnly: true, BindOptions: &mount.BindOptions{Propagation: "shared"}},
1886-
expected: types.MountPoint{Type: "bind", RW: false, Destination: destPath, Source: tmpDir3, Propagation: "shared"},
1885+
expected: container.MountPoint{Type: "bind", RW: false, Destination: destPath, Source: tmpDir3, Propagation: "shared"},
18871886
},
18881887
}...)
18891888
}
@@ -1894,19 +1893,19 @@ func (s *DockerAPISuite) TestContainersAPICreateMountsCreate(c *testing.T) {
18941893
cases = append(cases, []testCase{
18951894
{
18961895
spec: mount.Mount{Type: "volume", Target: destPath, VolumeOptions: &mount.VolumeOptions{NoCopy: true}},
1897-
expected: types.MountPoint{Driver: volume.DefaultDriverName, Type: "volume", RW: true, Destination: destPath, Mode: selinuxSharedLabel},
1896+
expected: container.MountPoint{Driver: volume.DefaultDriverName, Type: "volume", RW: true, Destination: destPath, Mode: selinuxSharedLabel},
18981897
},
18991898
{
19001899
spec: mount.Mount{Type: "volume", Target: destPath + slash, VolumeOptions: &mount.VolumeOptions{NoCopy: true}},
1901-
expected: types.MountPoint{Driver: volume.DefaultDriverName, Type: "volume", RW: true, Destination: destPath, Mode: selinuxSharedLabel},
1900+
expected: container.MountPoint{Driver: volume.DefaultDriverName, Type: "volume", RW: true, Destination: destPath, Mode: selinuxSharedLabel},
19021901
},
19031902
{
19041903
spec: mount.Mount{Type: "volume", Target: destPath, Source: "test4", VolumeOptions: &mount.VolumeOptions{NoCopy: true}},
1905-
expected: types.MountPoint{Type: "volume", Name: "test4", RW: true, Destination: destPath, Mode: selinuxSharedLabel},
1904+
expected: container.MountPoint{Type: "volume", Name: "test4", RW: true, Destination: destPath, Mode: selinuxSharedLabel},
19061905
},
19071906
{
19081907
spec: mount.Mount{Type: "volume", Target: destPath, Source: "test5", ReadOnly: true, VolumeOptions: &mount.VolumeOptions{NoCopy: true}},
1909-
expected: types.MountPoint{Type: "volume", Name: "test5", RW: false, Destination: destPath, Mode: selinuxSharedLabel},
1908+
expected: container.MountPoint{Type: "volume", Name: "test5", RW: false, Destination: destPath, Mode: selinuxSharedLabel},
19101909
},
19111910
}...)
19121911
}

integration-cli/docker_cli_external_volume_driver_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
"testing"
1515
"time"
1616

17-
"github.com/docker/docker/api/types"
17+
"github.com/docker/docker/api/types/container"
1818
volumetypes "github.com/docker/docker/api/types/volume"
1919
"github.com/docker/docker/integration-cli/cli"
2020
"github.com/docker/docker/integration-cli/daemon"
@@ -494,7 +494,7 @@ func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverWithDaemonRestart(c
494494
s.d.Restart(c)
495495

496496
cli.DockerCmd(c, "run", "--name=test", "-v", "abc1:/foo", "busybox", "true")
497-
var mounts []types.MountPoint
497+
var mounts []container.MountPoint
498498
inspectFieldAndUnmarshall(c, "test", "Mounts", &mounts)
499499
assert.Equal(c, len(mounts), 1)
500500
assert.Equal(c, mounts[0].Driver, volumePluginName)

integration-cli/docker_cli_inspect_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ func (s *DockerCLIInspectSuite) TestInspectBindMountPoint(c *testing.T) {
194194

195195
vol := inspectFieldJSON(c, "test", "Mounts")
196196

197-
var mp []types.MountPoint
197+
var mp []container.MountPoint
198198
err := json.Unmarshal([]byte(vol), &mp)
199199
assert.NilError(c, err)
200200

@@ -218,7 +218,7 @@ func (s *DockerCLIInspectSuite) TestInspectNamedMountPoint(c *testing.T) {
218218

219219
vol := inspectFieldJSON(c, "test", "Mounts")
220220

221-
var mp []types.MountPoint
221+
var mp []container.MountPoint
222222
err := json.Unmarshal([]byte(vol), &mp)
223223
assert.NilError(c, err)
224224

integration-cli/docker_cli_service_create_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"strings"
1010
"testing"
1111

12-
"github.com/docker/docker/api/types"
12+
"github.com/docker/docker/api/types/container"
1313
"github.com/docker/docker/api/types/mount"
1414
"github.com/docker/docker/api/types/swarm"
1515
"github.com/docker/docker/integration-cli/checker"
@@ -57,7 +57,7 @@ func (s *DockerSwarmSuite) TestServiceCreateMountVolume(c *testing.T) {
5757
out, err = s.nodeCmd(c, task.NodeID, "inspect", "--format", "{{json .Mounts}}", task.Status.ContainerStatus.ContainerID)
5858
assert.NilError(c, err, out)
5959

60-
var mounts []types.MountPoint
60+
var mounts []container.MountPoint
6161
assert.Assert(c, json.Unmarshal([]byte(out), &mounts) == nil)
6262
assert.Equal(c, len(mounts), 1)
6363

@@ -407,7 +407,7 @@ func (s *DockerSwarmSuite) TestServiceCreateMountTmpfs(c *testing.T) {
407407
out, err = s.nodeCmd(c, task.NodeID, "inspect", "--format", "{{json .Mounts}}", task.Status.ContainerStatus.ContainerID)
408408
assert.NilError(c, err, out)
409409

410-
var mounts []types.MountPoint
410+
var mounts []container.MountPoint
411411
assert.Assert(c, json.Unmarshal([]byte(out), &mounts) == nil)
412412
assert.Equal(c, len(mounts), 1)
413413

0 commit comments

Comments
 (0)