Skip to content

Commit 8a8e3d2

Browse files
authored
[nodetreemodel] Add missing 'provided' source in AllSettingsBySource function (#41921)
### What does this PR do? Add missing 'provided' source in `AllSettingsBySource` function. This fixes the inventoryagent test when running with nodetreemodel. ### Describe how you validated your changes Running CI is enough. ### Additional Notes
1 parent 75bc012 commit 8a8e3d2

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

pkg/config/nodetreemodel/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -900,6 +900,7 @@ func (c *ntmConfig) AllSettingsBySource() map[model.Source]interface{} {
900900
model.SourceLocalConfigProcess: c.localConfigProcess.DumpSettings(func(model.Source) bool { return true }),
901901
model.SourceRC: c.remoteConfig.DumpSettings(func(model.Source) bool { return true }),
902902
model.SourceCLI: c.cli.DumpSettings(func(model.Source) bool { return true }),
903+
model.SourceProvided: c.root.DumpSettings(func(src model.Source) bool { return src != model.SourceDefault }),
903904
}
904905
}
905906

pkg/config/nodetreemodel/config_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,7 @@ func TestAllSettingsBySource(t *testing.T) {
315315
cfg.SetDefault("a", 0)
316316
cfg.SetDefault("b.c", 0)
317317
cfg.SetDefault("b.d", 0)
318+
cfg.SetDefault("x", 123)
318319
cfg.BuildSchema()
319320

320321
cfg.ReadConfig(strings.NewReader("a: 987"))
@@ -327,6 +328,7 @@ func TestAllSettingsBySource(t *testing.T) {
327328
"c": 0,
328329
"d": 0,
329330
},
331+
"x": 123,
330332
},
331333
model.SourceUnknown: map[string]interface{}{},
332334
model.SourceFile: map[string]interface{}{
@@ -342,6 +344,12 @@ func TestAllSettingsBySource(t *testing.T) {
342344
model.SourceLocalConfigProcess: map[string]interface{}{},
343345
model.SourceRC: map[string]interface{}{},
344346
model.SourceCLI: map[string]interface{}{},
347+
model.SourceProvided: map[string]interface{}{
348+
"a": 987,
349+
"b": map[string]interface{}{
350+
"c": 123,
351+
},
352+
},
345353
}
346354
assert.Equal(t, expected, cfg.AllSettingsBySource())
347355
}

0 commit comments

Comments
 (0)