()
| 186 | } |
| 187 | |
| 188 | func (c *Config) ReadEnvironmentVariables() error { |
| 189 | var err error |
| 190 | |
| 191 | if username := os.Getenv("KITE_USERNAME"); username != "" { |
| 192 | c.Username = username |
| 193 | } |
| 194 | |
| 195 | if environment := os.Getenv("KITE_ENVIRONMENT"); environment != "" { |
| 196 | c.Environment = environment |
| 197 | } |
| 198 | |
| 199 | if region := os.Getenv("KITE_REGION"); region != "" { |
| 200 | c.Region = region |
| 201 | } |
| 202 | |
| 203 | if ip := os.Getenv("KITE_IP"); ip != "" { |
| 204 | c.IP = ip |
| 205 | } |
| 206 | |
| 207 | if port := os.Getenv("KITE_PORT"); port != "" { |
| 208 | c.Port, err = strconv.Atoi(port) |
| 209 | if err != nil { |
| 210 | return err |
| 211 | } |
| 212 | } |
| 213 | |
| 214 | if kontrolURL := os.Getenv("KITE_KONTROL_URL"); kontrolURL != "" { |
| 215 | c.KontrolURL = kontrolURL |
| 216 | } |
| 217 | |
| 218 | if transportName := os.Getenv("KITE_TRANSPORT"); transportName != "" { |
| 219 | transport, ok := Transports[transportName] |
| 220 | if !ok { |
| 221 | return fmt.Errorf("transport '%s' doesn't exists", transportName) |
| 222 | } |
| 223 | |
| 224 | c.Transport = transport |
| 225 | } |
| 226 | |
| 227 | if ttl, err := time.ParseDuration(os.Getenv("KITE_VERIFY_TTL")); err == nil { |
| 228 | c.VerifyTTL = ttl |
| 229 | } |
| 230 | |
| 231 | if timeout, err := time.ParseDuration(os.Getenv("KITE_TIMEOUT")); err == nil { |
| 232 | c.Timeout = timeout |
| 233 | c.Client.Timeout = timeout |
| 234 | } |
| 235 | |
| 236 | if timeout, err := time.ParseDuration(os.Getenv("KITE_HANDSHAKE_TIMEOUT")); err == nil { |
| 237 | c.Websocket.HandshakeTimeout = timeout |
| 238 | } |
| 239 | |
| 240 | return nil |
| 241 | } |
| 242 | |
| 243 | // ReadKiteKey parsed the user's kite key and returns a new Config. |
| 244 | func (c *Config) ReadKiteKey() error { |
no outgoing calls