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

Function parseBoolValue

opts/mount_utils.go:75–87  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

73// It is similar to [strconv.ParseBool], but only accepts 1, true, 0, false.
74// Any other value returns an error.
75func 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
89func ensureVolumeOptions(m *mount.Mount) *mount.VolumeOptions {
90 if m.VolumeOptions == nil {

Callers 1

SetMethod · 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…