feat: replace io fs finder with afero finder

Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
This commit is contained in:
Mark Sagi-Kazar 2023-09-11 04:55:19 +02:00 committed by Márk Sági-Kazár
parent cfa8fd9b4f
commit abbfd91119
3 changed files with 9 additions and 10 deletions

2
go.mod
View File

@ -9,7 +9,7 @@ require (
github.com/mitchellh/mapstructure v1.5.0
github.com/pelletier/go-toml/v2 v2.1.0
github.com/sagikazarmark/crypt v0.14.0
github.com/sagikazarmark/go-finder v0.1.0
github.com/sagikazarmark/locafero v0.1.0
github.com/sagikazarmark/slog-shim v0.1.0
github.com/spf13/afero v1.9.5
github.com/spf13/cast v1.5.1

4
go.sum
View File

@ -330,8 +330,8 @@ github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZV
github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
github.com/sagikazarmark/crypt v0.14.0 h1:+QD5vjd6aZd6moHuIRVL+uJO7fkhiRjMz3ldbZQY5go=
github.com/sagikazarmark/crypt v0.14.0/go.mod h1:JuxBJUNXrVOAywrtQNTZpOeTgcL1Az5qM7jKVDOifig=
github.com/sagikazarmark/go-finder v0.1.0 h1:5f1zyaYxU8FBMyPW7XnFOH6xZ6O9hm+m65CNjQ5snCM=
github.com/sagikazarmark/go-finder v0.1.0/go.mod h1:kS8MkoGpA6O0X1ddmi8O5g9YXwbVd9grjG8XCVehFEY=
github.com/sagikazarmark/locafero v0.1.0 h1:Am9aZ48Z6hbPm2MEPT2tYaruWPhPgjFJcGn8RmT1ask=
github.com/sagikazarmark/locafero v0.1.0/go.mod h1:w+v7UsPNFwzF1cHuOajOOzoq4U7v/ig1mpRjqV+Bu1U=
github.com/sagikazarmark/slog-shim v0.1.0 h1:diDBnUNK9N/354PgrxMywXnAwEr1QZcOr6gto+ugjYE=
github.com/sagikazarmark/slog-shim v0.1.0/go.mod h1:SrcSrq8aKtyuqEI1uvTDTK1arOWRIczQRv+GVI1AkeQ=
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529 h1:nn5Wsu0esKSJiIVhscUtVbo7ada43DJhG55ua/hjS5I=

View File

@ -6,8 +6,7 @@ package viper
import (
"fmt"
"github.com/sagikazarmark/go-finder"
"github.com/spf13/afero"
"github.com/sagikazarmark/locafero"
)
// Search all configPaths for any config file.
@ -16,18 +15,18 @@ func (v *Viper) findConfigFile() (string, error) {
var names []string
if v.configType != "" {
names = finder.NameWithOptionalExtensions(v.configName, SupportedExts...)
names = locafero.NameWithOptionalExtensions(v.configName, SupportedExts...)
} else {
names = finder.NameWithExtensions(v.configName, SupportedExts...)
names = locafero.NameWithExtensions(v.configName, SupportedExts...)
}
finder := finder.Finder{
finder := locafero.Finder{
Paths: v.configPaths,
Names: names,
Type: finder.FileTypeFile,
Type: locafero.FileTypeFile,
}
results, err := finder.Find(afero.NewIOFS(v.fs))
results, err := locafero.Find(v.fs)
if err != nil {
return "", err
}