( volume composetypes.ServiceVolumeConfig, stackVolumes volumes, namespace Namespace, )
| 35 | } |
| 36 | |
| 37 | func handleVolumeToMount( |
| 38 | volume composetypes.ServiceVolumeConfig, |
| 39 | stackVolumes volumes, |
| 40 | namespace Namespace, |
| 41 | ) (mount.Mount, error) { |
| 42 | result := createMountFromVolume(volume) |
| 43 | |
| 44 | if volume.Image != nil { |
| 45 | return mount.Mount{}, errors.New("images options are incompatible with type volume") |
| 46 | } |
| 47 | if volume.Tmpfs != nil { |
| 48 | return mount.Mount{}, errors.New("tmpfs options are incompatible with type volume") |
| 49 | } |
| 50 | if volume.Bind != nil { |
| 51 | return mount.Mount{}, errors.New("bind options are incompatible with type volume") |
| 52 | } |
| 53 | if volume.Cluster != nil { |
| 54 | return mount.Mount{}, errors.New("cluster options are incompatible with type volume") |
| 55 | } |
| 56 | // Anonymous volumes |
| 57 | if volume.Source == "" { |
| 58 | return result, nil |
| 59 | } |
| 60 | |
| 61 | stackVolume, exists := stackVolumes[volume.Source] |
| 62 | if !exists { |
| 63 | return mount.Mount{}, fmt.Errorf("undefined volume %q", volume.Source) |
| 64 | } |
| 65 | |
| 66 | result.Source = namespace.Scope(volume.Source) |
| 67 | result.VolumeOptions = &mount.VolumeOptions{} |
| 68 | |
| 69 | if volume.Volume != nil { |
| 70 | result.VolumeOptions.NoCopy = volume.Volume.NoCopy |
| 71 | result.VolumeOptions.Subpath = volume.Volume.Subpath |
| 72 | } |
| 73 | |
| 74 | if stackVolume.Name != "" { |
| 75 | result.Source = stackVolume.Name |
| 76 | } |
| 77 | |
| 78 | // External named volumes |
| 79 | if stackVolume.External.External { |
| 80 | return result, nil |
| 81 | } |
| 82 | |
| 83 | result.VolumeOptions.Labels = addStackLabel(namespace, stackVolume.Labels) |
| 84 | if stackVolume.Driver != "" || stackVolume.DriverOpts != nil { |
| 85 | result.VolumeOptions.DriverConfig = &mount.Driver{ |
| 86 | Name: stackVolume.Driver, |
| 87 | Options: stackVolume.DriverOpts, |
| 88 | } |
| 89 | } |
| 90 | |
| 91 | return result, nil |
| 92 | } |
| 93 | |
| 94 | func handleImageToMount(volume composetypes.ServiceVolumeConfig) (mount.Mount, error) { |
no test coverage detected
searching dependent graphs…