MCPcopy Index your code
hub / github.com/docker/cli / validateExclusiveOptions

Function validateExclusiveOptions

opts/mount_utils.go:47–68  ·  view source on GitHub ↗

validateExclusiveOptions checks if the given mount config only contains options for the given mount-type. This is the client-side equivalent of [mounts.validateExclusiveOptions] in the daemon, but with error-messages matching client-side flags / options. [mounts.validateExclusiveOptions]: https://

(m *mount.Mount)

Source from the content-addressed store, hash-verified

45//
46// [mounts.validateExclusiveOptions]: https://github.com/moby/moby/blob/v2.0.0-beta.6/daemon/volume/mounts/validate.go#L31-L50
47func validateExclusiveOptions(m *mount.Mount) error {
48 if m.Type == "" {
49 return errors.New("type is required")
50 }
51
52 if m.Type != mount.TypeBind && m.BindOptions != nil {
53 return fmt.Errorf("cannot mix 'bind-*' options with mount type '%s'", m.Type)
54 }
55 if m.Type != mount.TypeVolume && m.VolumeOptions != nil {
56 return fmt.Errorf("cannot mix 'volume-*' options with mount type '%s'", m.Type)
57 }
58 if m.Type != mount.TypeImage && m.ImageOptions != nil {
59 return fmt.Errorf("cannot mix 'image-*' options with mount type '%s'", m.Type)
60 }
61 if m.Type != mount.TypeTmpfs && m.TmpfsOptions != nil {
62 return fmt.Errorf("cannot mix 'tmpfs-*' options with mount type '%s'", m.Type)
63 }
64 if m.Type != mount.TypeCluster && m.ClusterOptions != nil {
65 return fmt.Errorf("cannot mix 'cluster-*' options with mount type '%s'", m.Type)
66 }
67 return nil
68}
69
70// parseBoolValue returns the boolean value represented by the string. It returns
71// true if no value is set.

Callers 1

validateMountOptionsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…