Skip to content

Commit

Permalink
Fix config detection when path is invalid. (#1377)
Browse files Browse the repository at this point in the history
  • Loading branch information
jefchien authored Oct 7, 2024
1 parent f18077b commit 01b5366
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion internal/util/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func GetOTELConfigArgs(dir string) []string {
func getSortedYAMLs(dir string) []string {
var configs []string
_ = filepath.WalkDir(dir, func(path string, d fs.DirEntry, err error) error {
if d.IsDir() {
if d == nil || d.IsDir() {
return nil
}
if filepath.Ext(path) == constants.FileSuffixYAML {
Expand Down
8 changes: 7 additions & 1 deletion internal/util/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ import (
)

func TestGetOTELConfigArgs(t *testing.T) {
got := GetOTELConfigArgs("/not/valid/path")
assert.Len(t, got, 2)
assert.Equal(t, []string{
"-otelconfig", paths.YamlConfigPath,
}, got)

dir := t.TempDir()
// skipped
require.NoError(t, os.Mkdir(filepath.Join(dir, "bunchofyaml"), 0644))
Expand All @@ -32,7 +38,7 @@ func TestGetOTELConfigArgs(t *testing.T) {
require.NoError(t, err)
require.NoError(t, f.Close())
}
got := GetOTELConfigArgs(dir)
got = GetOTELConfigArgs(dir)
assert.Len(t, got, 14)
assert.Equal(t, []string{
"-otelconfig", filepath.Join(dir, "1.yaml"),
Expand Down

0 comments on commit 01b5366

Please sign in to comment.