parseBoolValue returns the boolean value represented by the string. It returns true if no value is set. It is similar to [strconv.ParseBool], but only accepts 1, true, 0, false. Any other value returns an error.
(key string, val string, hasValue bool)
| 73 | // It is similar to [strconv.ParseBool], but only accepts 1, true, 0, false. |
| 74 | // Any other value returns an error. |
| 75 | func parseBoolValue(key string, val string, hasValue bool) (bool, error) { |
| 76 | if !hasValue { |
| 77 | return true, nil |
| 78 | } |
| 79 | switch val { |
| 80 | case "1", "true": |
| 81 | return true, nil |
| 82 | case "0", "false": |
| 83 | return false, nil |
| 84 | default: |
| 85 | return false, fmt.Errorf(`invalid value for '%s': invalid boolean value (%q): must be one of "true", "1", "false", or "0" (default "true")`, key, val) |
| 86 | } |
| 87 | } |
| 88 | |
| 89 | func ensureVolumeOptions(m *mount.Mount) *mount.VolumeOptions { |
| 90 | if m.VolumeOptions == nil { |
no outgoing calls
no test coverage detected
searching dependent graphs…