diff --git a/apis/duck/v1/status_types.go b/apis/duck/v1/status_types.go index 6ea8f9e2e..2165e7838 100644 --- a/apis/duck/v1/status_types.go +++ b/apis/duck/v1/status_types.go @@ -108,12 +108,12 @@ func (source *Status) ConvertTo(ctx context.Context, sink *Status, predicates .. conditions := make(apis.Conditions, 0, len(source.Conditions)) for _, c := range source.Conditions { - switch c.Type { + // Copy over the "happy" condition, which is the only condition that // we can reliably transfer. - case apis.ConditionReady, apis.ConditionSucceeded: + if c.Type == apis.ConditionReady || c.Type == apis.ConditionSucceeded { conditions = append(conditions, c) - break + continue } for _, predicate := range predicates { diff --git a/apis/duck/v1/status_types_test.go b/apis/duck/v1/status_types_test.go index 1b781aa21..c99697658 100644 --- a/apis/duck/v1/status_types_test.go +++ b/apis/duck/v1/status_types_test.go @@ -137,13 +137,24 @@ func TestConditionSet(t *testing.T) { } s2 = &Status{} - s.ConvertTo(context.Background(), s2, func(cond apis.ConditionType) bool { - return cond == "Foo" - }) + s.ConvertTo(context.Background(), s2, + func(cond apis.ConditionType) bool { + return cond == "Foo" + }, + func(cond apis.ConditionType) bool { + return cond == "Ready" + }, + func(cond apis.ConditionType) bool { + return cond == "Foo" + }, + ) if !condSet.Manage(s2).IsHappy() { t.Error("s2.IsHappy() = false, wanted true") } + if got, want := len(s2.Conditions), 2; got != want { + t.Errorf("len(s2.Conditions) = %d, wanted %d", got, want) + } for _, c := range []apis.ConditionType{apis.ConditionReady, "Foo"} { if cond := mgr.GetCondition(c); cond == nil { t.Errorf("GetCondition(%q) = nil, wanted non-nil", c)