Skip to content

Commit

Permalink
Merge pull request #2 from runwayml/comments
Browse files Browse the repository at this point in the history
Add #comment support to input files
  • Loading branch information
brannondorsey authored Jul 4, 2020
2 parents 4783807 + 0420943 commit ade570a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ source .env
Input files are in the following format:

```bash
# lines beginning with "#" are ignored as a comment
ENV_VAR_NAME=secret-name/secret-key
ENV_VAR_NAME_2=secret-name/secret-key-2
ENV_VAR_NAME_3=other-secret-name/other-key
Expand Down
6 changes: 6 additions & 0 deletions pkg/parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ func ParseInput(input string) (EnvKeyToSecretPath, error) {
}
for i, line := range lines {
line = strings.TrimSpace(line)
if strings.HasPrefix(line, "#") {
continue
}
if !strings.Contains(line, "=") {
return nil, fmt.Errorf("parse input error: line %d missing required \"=\" separated env pair", i+1)
}
Expand All @@ -42,6 +45,9 @@ func ParseInput(input string) (EnvKeyToSecretPath, error) {
Key: secretParts[len(secretParts)-1],
}
}
if len(output) < 1 {
return nil, fmt.Errorf("parse input error: no secrets defined in input file")
}

return output, nil
}

0 comments on commit ade570a

Please sign in to comment.