Skip to content

Commit 86263bb

Browse files
authored
Merge pull request #984 from fluxcd/watch-configs-empty-everything
runtime/controller: Fix watch configs for empty label selector
2 parents 7a82092 + 7c029ae commit 86263bb

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

oci/tests/integration/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ require (
2222
github.com/fluxcd/pkg/cache v0.10.0
2323
github.com/fluxcd/pkg/git v0.34.0
2424
github.com/fluxcd/pkg/git/gogit v0.37.0
25-
github.com/fluxcd/pkg/runtime v0.70.0
25+
github.com/fluxcd/pkg/runtime v0.71.0
2626
github.com/fluxcd/test-infra/tftestenv v0.0.0-20250626232827-e0ca9c3f8d7b
2727
github.com/go-git/go-git/v5 v5.16.2
2828
github.com/google/go-containerregistry v0.20.6

runtime/controller/watch.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ func GetWatchSelector(opts WatchOptions) (labels.Selector, error) {
8888
// GetWatchConfigsPredicate parses the label selector option from WatchOptions
8989
// and returns the controller-runtime predicate ready for setting up the watch.
9090
func GetWatchConfigsPredicate(opts WatchOptions) (predicate.Predicate, error) {
91-
selector := labels.Nothing()
91+
selector := labels.Everything()
9292

9393
if opts.ConfigsLabelSelector != "" {
9494
var err error

runtime/controller/watch_test.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,24 +149,28 @@ func TestGetWatchConfigsPredicate(t *testing.T) {
149149
arguments []string
150150
shouldMatchDefault bool
151151
shouldMatchCustom bool
152+
shouldMatchEmpty bool
152153
}{
153154
{
154155
name: "default selector",
155156
arguments: []string{},
156157
shouldMatchDefault: true,
157158
shouldMatchCustom: false,
159+
shouldMatchEmpty: false,
158160
},
159161
{
160162
name: "custom selector",
161163
arguments: []string{"--watch-configs-label-selector=app=my-app"},
162164
shouldMatchDefault: false,
163165
shouldMatchCustom: true,
166+
shouldMatchEmpty: false,
164167
},
165168
{
166169
name: "empty selector",
167170
arguments: []string{"--watch-configs-label-selector="},
168-
shouldMatchDefault: false,
169-
shouldMatchCustom: false,
171+
shouldMatchDefault: true,
172+
shouldMatchCustom: true,
173+
shouldMatchEmpty: true,
170174
},
171175
} {
172176
t.Run(tt.name, func(t *testing.T) {
@@ -203,7 +207,7 @@ func TestGetWatchConfigsPredicate(t *testing.T) {
203207
// Test empty labels.
204208
ev.Object.SetLabels(map[string]string{})
205209
ok = pred.Create(ev)
206-
g.Expect(ok).To(BeFalse())
210+
g.Expect(ok).To(Equal(tt.shouldMatchEmpty))
207211
})
208212
}
209213
}

0 commit comments

Comments
 (0)