Path returns the path to a file relative to the config dir
(p ...string)
| 98 | |
| 99 | // Path returns the path to a file relative to the config dir |
| 100 | func Path(p ...string) (string, error) { |
| 101 | path := filepath.Join(append([]string{Dir()}, p...)...) |
| 102 | if !strings.HasPrefix(path, Dir()+string(filepath.Separator)) { |
| 103 | return "", fmt.Errorf("path %q is outside of root config directory %q", path, Dir()) |
| 104 | } |
| 105 | return path, nil |
| 106 | } |
| 107 | |
| 108 | // LoadFromReader is a convenience function that creates a ConfigFile object from |
| 109 | // a reader. It returns an error if configData is malformed. |
searching dependent graphs…