-
Notifications
You must be signed in to change notification settings - Fork 68
Open
Labels
questionFurther information is requestedFurther information is requestedsourcesWhat sources and in what way to monitorWhat sources and in what way to monitor
Description
If you run pgwatch with --group group1, it will monitor/connect to sources with the group1 tag, as well as sources with default or empty group tags.
Shouldn't we be strict and only monitor sources with the group1 tag?
This weird behaviour already has tests:
pgwatch/internal/reaper/reaper_test.go
Lines 74 to 88 in 4bae857
| t.Run("Test group limited sources", func(t *testing.T) { | |
| source1 := sources.Source{Name: "Source 1", IsEnabled: true, Kind: sources.SourcePostgres, Group: ""} // Empty group should not filter | |
| source2 := sources.Source{Name: "Source 2", IsEnabled: true, Kind: sources.SourcePostgres, Group: "group1"} | |
| source3 := sources.Source{Name: "Source 3", IsEnabled: true, Kind: sources.SourcePostgres, Group: "group2"} | |
| source4 := sources.Source{Name: "Source 4", IsEnabled: true, Kind: sources.SourcePostgres, Group: "default"} // Default group should not filter | |
| newReader := &testutil.MockSourcesReaderWriter{ | |
| GetSourcesFunc: func() (sources.Sources, error) { | |
| return sources.Sources{source1, source2, source3, source4}, nil | |
| }, | |
| } | |
| r := NewReaper(ctx, &cmdopts.Options{SourcesReaderWriter: newReader, Sources: sources.CmdOpts{Groups: []string{"group1", "group2"}}}) | |
| assert.NoError(t, r.LoadSources()) | |
| assert.Equal(t, 4, len(r.monitoredSources), "Expected four monitored sources after load") | |
As you can see, it limits the monitored groups to group1 and group2, but the "" and "default" groups are not filtered.
Metadata
Metadata
Assignees
Labels
questionFurther information is requestedFurther information is requestedsourcesWhat sources and in what way to monitorWhat sources and in what way to monitor