MCPcopy Index your code
hub / github.com/linuxkit/linuxkit / getIntValue

Function getIntValue

src/cmd/linuxkit/util.go:49–72  ·  view source on GitHub ↗
(envKey string, flagVal int, defaultVal int)

Source from the content-addressed store, hash-verified

47}
48
49func getIntValue(envKey string, flagVal int, defaultVal int) int {
50 var res int
51
52 // If defined, take the env variable
53 if _, ok := os.LookupEnv(envKey); ok {
54 var err error
55 res, err = strconv.Atoi(os.Getenv(envKey))
56 if err != nil {
57 res = 0
58 }
59 }
60
61 // If a flag is specified, this value takes precedence
62 // Ignore cases where the flag carries the default value
63 if flagVal > 0 {
64 res = flagVal
65 }
66
67 // if we still don't have a value, use the default
68 if res == 0 {
69 res = defaultVal
70 }
71 return res
72}
73
74func getBoolValue(envKey string, flagVal bool) bool {
75 var res bool

Callers 3

pushAWSCmdFunction · 0.85
runAWSCmdFunction · 0.85
pushScalewayCmdFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected