From a031814bc46f8163fbdb510aa989327e0e17bfe2 Mon Sep 17 00:00:00 2001 From: Vincent Batts Date: Tue, 11 Mar 2014 16:22:58 -0400 Subject: [PATCH] --env-file: simple line-delimited match dock functionality, and not try to achieve shell-sourcing compatibility Docker-DCO-1.1-Signed-off-by: Vincent Batts (github: vbatts) --- opts/envfile.go | 37 ------------------------------------- 1 file changed, 37 deletions(-) delete mode 100644 opts/envfile.go diff --git a/opts/envfile.go b/opts/envfile.go deleted file mode 100644 index d9afdd9..0000000 --- a/opts/envfile.go +++ /dev/null @@ -1,37 +0,0 @@ -package opts - -import ( - "bufio" - "fmt" - "os" - "strconv" - "strings" -) - -/* -Read in a line delimited file with environment variables enumerated -*/ -func ParseEnvFile(filename string) ([]string, error) { - fh, err := os.Open(filename) - if err != nil { - return []string{}, err - } - defer fh.Close() - - lines := []string{} - scanner := bufio.NewScanner(fh) - for scanner.Scan() { - line := scanner.Text() - // line is not empty, and not starting with '#' - if len(line) > 0 && !strings.HasPrefix(line, "#") && strings.Contains(line, "=") { - data := strings.SplitN(line, "=", 2) - key := data[0] - val := data[1] - if str, err := strconv.Unquote(data[1]); err == nil { - val = str - } - lines = append(lines, fmt.Sprintf("%s=%s", key, val)) - } - } - return lines, nil -}