@@ -40,6 +40,9 @@ func handleVolumeToMount(
40
40
) (mount.Mount , error ) {
41
41
result := createMountFromVolume (volume )
42
42
43
+ if volume .Image != nil {
44
+ return mount.Mount {}, errors .New ("images options are incompatible with type volume" )
45
+ }
43
46
if volume .Tmpfs != nil {
44
47
return mount.Mount {}, errors .New ("tmpfs options are incompatible with type volume" )
45
48
}
@@ -86,6 +89,32 @@ func handleVolumeToMount(
86
89
return result , nil
87
90
}
88
91
92
+ func handleImageToMount (volume composetypes.ServiceVolumeConfig ) (mount.Mount , error ) {
93
+ result := createMountFromVolume (volume )
94
+
95
+ if volume .Source == "" {
96
+ return mount.Mount {}, errors .New ("invalid image source, source cannot be empty" )
97
+ }
98
+ if volume .Volume != nil {
99
+ return mount.Mount {}, errors .New ("volume options are incompatible with type image" )
100
+ }
101
+ if volume .Bind != nil {
102
+ return mount.Mount {}, errors .New ("bind options are incompatible with type image" )
103
+ }
104
+ if volume .Tmpfs != nil {
105
+ return mount.Mount {}, errors .New ("tmpfs options are incompatible with type image" )
106
+ }
107
+ if volume .Cluster != nil {
108
+ return mount.Mount {}, errors .New ("cluster options are incompatible with type image" )
109
+ }
110
+ if volume .Bind != nil {
111
+ result .BindOptions = & mount.BindOptions {
112
+ Propagation : mount .Propagation (volume .Bind .Propagation ),
113
+ }
114
+ }
115
+ return result , nil
116
+ }
117
+
89
118
func handleBindToMount (volume composetypes.ServiceVolumeConfig ) (mount.Mount , error ) {
90
119
result := createMountFromVolume (volume )
91
120
@@ -95,6 +124,9 @@ func handleBindToMount(volume composetypes.ServiceVolumeConfig) (mount.Mount, er
95
124
if volume .Volume != nil {
96
125
return mount.Mount {}, errors .New ("volume options are incompatible with type bind" )
97
126
}
127
+ if volume .Image != nil {
128
+ return mount.Mount {}, errors .New ("image options are incompatible with type bind" )
129
+ }
98
130
if volume .Tmpfs != nil {
99
131
return mount.Mount {}, errors .New ("tmpfs options are incompatible with type bind" )
100
132
}
@@ -121,6 +153,9 @@ func handleTmpfsToMount(volume composetypes.ServiceVolumeConfig) (mount.Mount, e
121
153
if volume .Volume != nil {
122
154
return mount.Mount {}, errors .New ("volume options are incompatible with type tmpfs" )
123
155
}
156
+ if volume .Image != nil {
157
+ return mount.Mount {}, errors .New ("image options are incompatible with type tmpfs" )
158
+ }
124
159
if volume .Cluster != nil {
125
160
return mount.Mount {}, errors .New ("cluster options are incompatible with type tmpfs" )
126
161
}
@@ -141,6 +176,9 @@ func handleNpipeToMount(volume composetypes.ServiceVolumeConfig) (mount.Mount, e
141
176
if volume .Volume != nil {
142
177
return mount.Mount {}, errors .New ("volume options are incompatible with type npipe" )
143
178
}
179
+ if volume .Image != nil {
180
+ return mount.Mount {}, errors .New ("image options are incompatible with type npipe" )
181
+ }
144
182
if volume .Tmpfs != nil {
145
183
return mount.Mount {}, errors .New ("tmpfs options are incompatible with type npipe" )
146
184
}
@@ -203,6 +241,8 @@ func convertVolumeToMount(
203
241
switch volume .Type {
204
242
case "volume" , "" :
205
243
return handleVolumeToMount (volume , stackVolumes , namespace )
244
+ case "image" :
245
+ return handleImageToMount (volume )
206
246
case "bind" :
207
247
return handleBindToMount (volume )
208
248
case "tmpfs" :
0 commit comments