()
| 306 | } |
| 307 | |
| 308 | func parseConfiguration() (err error) { |
| 309 | // get admin users |
| 310 | if ADMIN_USERS != "" { |
| 311 | for _, name := range strings.Split(ADMIN_USERS, ",") { |
| 312 | AdminUsers = append(AdminUsers, strings.TrimSpace(name)) |
| 313 | } |
| 314 | } |
| 315 | |
| 316 | // parse OAuth settings if used |
| 317 | if AUTH_OAUTH_URL_STR != "" && AUTH_OAUTH_BEARER_STR != "" { |
| 318 | ou := strings.Split(AUTH_OAUTH_URL_STR, ",") |
| 319 | ob := strings.Split(AUTH_OAUTH_BEARER_STR, ",") |
| 320 | if len(ou) != len(ob) { |
| 321 | return errors.New("number of items in oauth_urls and oauth_bearers are not the same") |
| 322 | } |
| 323 | for i := range ob { |
| 324 | AUTH_OAUTH[ob[i]] = ou[i] |
| 325 | } |
| 326 | OAUTH_DEFAULT = ou[0] // first url is default for "oauth" bearer token |
| 327 | } |
| 328 | |
| 329 | // validate LOG_OUTPUT |
| 330 | vaildLogout := false |
| 331 | for _, logout := range LOG_OUTPUTS { |
| 332 | if LOG_OUTPUT == logout { |
| 333 | vaildLogout = true |
| 334 | } |
| 335 | } |
| 336 | if !vaildLogout { |
| 337 | return errors.New("invalid option for logoutput, use one of: file, console, both") |
| 338 | } |
| 339 | |
| 340 | // clean paths |
| 341 | PATH_SITE = cleanPath(PATH_SITE) |
| 342 | PATH_DATA = cleanPath(PATH_DATA) |
| 343 | PATH_LOGS = cleanPath(PATH_LOGS) |
| 344 | PATH_LOCAL = cleanPath(PATH_LOCAL) |
| 345 | PATH_PIDFILE = cleanPath(PATH_PIDFILE) |
| 346 | |
| 347 | return |
| 348 | } |
| 349 | |
| 350 | func cleanPath(p string) string { |
| 351 | if p != "" { |
no test coverage detected