changed how tests are ran; updated dotenv to handle parsing fields into structs
CI / Detect changed paths (pull_request) Failing after 31m29s
CI / Infra unit tests, vet, and preview (pull_request) Has been skipped
CI / API unit tests and lint (pull_request) Failing after 34m25s
CI / Odin unit tests and build (pull_request) Failing after 34m36s

This commit is contained in:
2026-09-07 14:35:30 -06:00
parent ac2d30510c
commit ba24005bfb
6 changed files with 386 additions and 187 deletions
+12 -4
View File
@@ -1,18 +1,26 @@
package main
import "lib:dotenv"
import "core:os"
import dotenv "lib:dotenv/src"
Config :: struct {
api_url: string,
}
get_config :: proc() -> (^Config, ^Error) {
get_config :: proc(env_file: ^string = nil) -> (^Config, ^Error) {
env, _ := dotenv.parse_file(".env", context.temp_allocator)
defer dotenv.destroy(env)
c := new(Config)
c.api_url = dotenv.get_string(env, "API_URL")
if env == nil {
c.api_url = os.get_env("API_URL", context.temp_allocator)
} else if !dotenv.decode(env, c) {
err := new(Error)
err.type = .Config
err.message = "failed to decode .env into Config"
return nil, err
}
if err := validate_config(c); err != nil {
return nil, err
@@ -26,4 +34,4 @@ validate_config :: proc(c: ^Config) -> ^Error {
if c.api_url == "" do err.type = .Config; err.message = "'API_URL' is required"
return err
}
}