9 mounttypes "github.com/docker/docker/api/types/mount"
12 // ConvertTmpfsOptions converts *mounttypes.TmpfsOptions to the raw option string
14 func ConvertTmpfsOptions(opt *mounttypes.TmpfsOptions, readOnly bool) (string, error) {
17 rawOpts = append(rawOpts, "ro")
20 if opt != nil && opt.Mode != 0 {
21 rawOpts = append(rawOpts, fmt.Sprintf("mode=%o", opt.Mode))
24 if opt != nil && opt.SizeBytes != 0 {
25 // calculate suffix here, making this linux specific, but that is
26 // okay, since API is that way anyways.
28 // we do this by finding the suffix that divides evenly into the
29 // value, returing the value itself, with no suffix, if it fails.
31 // For the most part, we don't enforce any semantic to this values.
32 // The operating system will usually align this and enforce minimum
38 for _, r := range []struct {
46 if size%r.divisor == 0 {
47 size = size / r.divisor
53 rawOpts = append(rawOpts, fmt.Sprintf("size=%d%s", size, suffix))
55 return strings.Join(rawOpts, ","), nil