diff --git a/internal/check/env.go b/internal/check/env.go index 932eb9b..000b033 100644 --- a/internal/check/env.go +++ b/internal/check/env.go @@ -52,6 +52,22 @@ func (c *EnvCheck) Run(_ context.Context) Result { } } + var empty []string + for k, v := range actualKeys { + if v == "" { + empty = append(empty, k) + } + } + + if len(empty) > 0 { + return Result{ + Name: c.Name(), + Status: StatusWarn, + Message: fmt.Sprintf("empty values for keys: %s", strings.Join(empty, ", ")), + Fix: "fill in the values for the empty keys in your .env file", + } + } + return Result{ Name: c.Name(), Status: StatusPass, @@ -59,24 +75,25 @@ func (c *EnvCheck) Run(_ context.Context) Result { } } -func parseEnvKeys(path string) (map[string]struct{}, error) { +func parseEnvKeys(path string) (map[string]string, error) { f, err := os.Open(path) if err != nil { return nil, err } defer f.Close() - keys := make(map[string]struct{}) + keys := make(map[string]string) scanner := bufio.NewScanner(f) for scanner.Scan() { line := strings.TrimSpace(scanner.Text()) if line == "" || strings.HasPrefix(line, "#") { continue } - key, _, _ := strings.Cut(line, "=") + key, val, _ := strings.Cut(line, "=") key = strings.TrimSpace(key) + val = strings.TrimSpace(val) if key != "" { - keys[key] = struct{}{} + keys[key] = val } } return keys, scanner.Err()