package infra

import (
	"fmt"
	"os"
)

// EnvRequire returns the value of the environment variable named key.
// If the variable is unset or empty it returns an error with a descriptive message.
func EnvRequire(key string) (string, error) {
	val := os.Getenv(key)
	if val == "" {
		return "", fmt.Errorf("env_require: environment variable %q is not set or empty", key)
	}
	return val, nil
}
