Skip to content

Commit 4619e54

Browse files
committed
Add support for .yml file extension in config file
Signed-off-by: Onni Hakala <onni@flaky.build>
1 parent 5ba9cb9 commit 4619e54

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

config/config.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,20 @@ var fs fileSystem = osFS{stat: os.Stat}
3939
const (
4040
maxDepth = 100
4141
configFileName = ".sops.yaml"
42+
configFileNameAlternative = ".sops.yml"
4243
)
4344

4445
// FindConfigFile looks for a sops config file in the current working directory and on parent directories, up to the limit defined by the maxDepth constant.
4546
func FindConfigFile(start string) (string, error) {
4647
filepath := path.Dir(start)
4748
for i := 0; i < maxDepth; i++ {
48-
_, err := fs.Stat(path.Join(filepath, configFileName))
49-
if err != nil {
50-
filepath = path.Join(filepath, "..")
51-
} else {
52-
return path.Join(filepath, configFileName), nil
49+
for _, configFileName := range []string{configFileName, configFileNameAlternative} {
50+
_, err := fs.Stat(path.Join(filepath, configFileName))
51+
if err != nil {
52+
filepath = path.Join(filepath, "..")
53+
} else {
54+
return path.Join(filepath, configFileName), nil
55+
}
5356
}
5457
}
5558
return "", fmt.Errorf("Config file not found")

0 commit comments

Comments
 (0)