diff --git a/internal/util/config/config.go b/internal/util/config/config.go index 408b134add..5e0e77b127 100644 --- a/internal/util/config/config.go +++ b/internal/util/config/config.go @@ -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 { diff --git a/internal/util/config/config_test.go b/internal/util/config/config_test.go index bbd97ec759..b4b236b6dc 100644 --- a/internal/util/config/config_test.go +++ b/internal/util/config/config_test.go @@ -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)) @@ -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"),