MCPcopy Index your code
hub / github.com/coder/coder / parseEnvFileFlag

Function parseEnvFileFlag

scripts/develop/main.go:469–482  ·  view source on GitHub ↗

parseEnvFileFlag extracts the --env-file value from os.Args and CODER_DEV_ENV_FILE before serpent runs, so that loaded variables are visible to serpent's Env-tag resolution for other options.

()

Source from the content-addressed store, hash-verified

467// CODER_DEV_ENV_FILE before serpent runs, so that loaded variables
468// are visible to serpent's Env-tag resolution for other options.
469func parseEnvFileFlag() (string, error) {
470 for i, arg := range os.Args[1:] {
471 if arg == "--env-file" {
472 if i+2 >= len(os.Args) {
473 return "", xerrors.New("--env-file requires a value")
474 }
475 return os.Args[i+2], nil
476 }
477 if v, ok := strings.CutPrefix(arg, "--env-file="); ok {
478 return v, nil
479 }
480 }
481 return os.Getenv("CODER_DEV_ENV_FILE"), nil
482}
483
484// loadEnvFile reads the file at path using godotenv and sets any variables
485// not already present in the process environment. It returns the number of

Callers 2

TestParseEnvFileFlagFunction · 0.85
mainFunction · 0.85

Calls 1

NewMethod · 0.65

Tested by 1

TestParseEnvFileFlagFunction · 0.68