envValInt searches for a key in a list of environment variables and parses it to an int. If the key is not found or cannot be parsed, returns 0 and false.
(key string)
| 120 | // envValInt searches for a key in a list of environment variables and parses it to an int. |
| 121 | // If the key is not found or cannot be parsed, returns 0 and false. |
| 122 | func envValInt(key string) (int, bool) { |
| 123 | val, ok := os.LookupEnv(key) |
| 124 | if !ok { |
| 125 | return 0, false |
| 126 | } |
| 127 | |
| 128 | i, err := strconv.Atoi(val) |
| 129 | if err != nil { |
| 130 | return 0, false |
| 131 | } |
| 132 | return i, true |
| 133 | } |
| 134 | |
| 135 | // The following are flags used by the agent-exec command. We use flags instead of |
| 136 | // environment variables to avoid having to deal with a caller overriding the |