mirror of
https://github.com/amir20/dozzle.git
synced 2026-08-07 08:54:45 +00:00
bd4651fb0b
Deploy VitePress site to Pages / build (push) Has been cancelled
Deploy VitePress site to Pages / Deploy (push) Has been cancelled
Push container / Push branches and PRs (push) Has been cancelled
Test / Typecheck (push) Has been cancelled
Test / JavaScript Tests (push) Has been cancelled
Test / Go Tests (push) Has been cancelled
Test / Go Staticcheck (push) Has been cancelled
Test / Integration Tests (push) Has been cancelled
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
32 lines
649 B
Go
32 lines
649 B
Go
package cli
|
|
|
|
import (
|
|
"os"
|
|
"reflect"
|
|
"strings"
|
|
|
|
"github.com/rs/zerolog/log"
|
|
)
|
|
|
|
func ValidateEnvVars(types ...any) {
|
|
expectedEnvs := make(map[string]bool)
|
|
for _, t := range types {
|
|
typ := reflect.TypeOf(t)
|
|
|
|
for field := range typ.Fields() {
|
|
for tag := range strings.SplitSeq(field.Tag.Get("arg"), ",") {
|
|
if after, ok := strings.CutPrefix(tag, "env:"); ok {
|
|
expectedEnvs[after] = true
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
for _, env := range os.Environ() {
|
|
actual := strings.Split(env, "=")[0]
|
|
if strings.HasPrefix(actual, "DOZZLE_") && !expectedEnvs[actual] {
|
|
log.Warn().Str("env", actual).Msg("Unexpected environment variable")
|
|
}
|
|
}
|
|
}
|