mirror of https://github.com/knative/pkg.git
conditions were being duplicated since we broke vs. continuing (#1009)
* conditions were being duplicated since we broke vs. continuing * pr feedback * butter finger
This commit is contained in:
parent
62801f1d34
commit
5ff923b836
|
@ -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 {
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue