MCPcopy Create free account
hub / github.com/docker/cli / handleClusterToMount

Function handleClusterToMount

cli/compose/convert/volume.go:195–236  ·  view source on GitHub ↗
(
	volume composetypes.ServiceVolumeConfig,
	stackVolumes volumes,
	namespace Namespace,
)

Source from the content-addressed store, hash-verified

193}
194
195func handleClusterToMount(
196 volume composetypes.ServiceVolumeConfig,
197 stackVolumes volumes,
198 namespace Namespace,
199) (mount.Mount, error) {
200 if volume.Source == "" {
201 return mount.Mount{}, errors.New("invalid cluster source, source cannot be empty")
202 }
203 if volume.Tmpfs != nil {
204 return mount.Mount{}, errors.New("tmpfs options are incompatible with type cluster")
205 }
206 if volume.Bind != nil {
207 return mount.Mount{}, errors.New("bind options are incompatible with type cluster")
208 }
209 if volume.Volume != nil {
210 return mount.Mount{}, errors.New("volume options are incompatible with type cluster")
211 }
212
213 result := createMountFromVolume(volume)
214 result.ClusterOptions = &mount.ClusterOptions{}
215
216 if !strings.HasPrefix(volume.Source, "group:") {
217 // if the volume is a cluster volume and the source is a volumegroup, we
218 // will ignore checking to see if such a volume is defined. the volume
219 // group isn't namespaced, and there's no simple way to indicate that
220 // external volumes with a given group exist.
221 stackVolume, exists := stackVolumes[volume.Source]
222 if !exists {
223 return mount.Mount{}, fmt.Errorf("undefined volume %q", volume.Source)
224 }
225
226 // if the volume is not specified with a group source, we may namespace
227 // the name, if one is not otherwise specified.
228 if stackVolume.Name != "" {
229 result.Source = stackVolume.Name
230 } else {
231 result.Source = namespace.Scope(volume.Source)
232 }
233 }
234
235 return result, nil
236}
237
238func convertVolumeToMount(
239 volume composetypes.ServiceVolumeConfig,

Callers 1

convertVolumeToMountFunction · 0.85

Calls 2

createMountFromVolumeFunction · 0.85
ScopeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…