diff --git a/staging/src/k8s.io/apiextensions-apiserver/pkg/apiserver/schema/cel/library/lists.go b/staging/src/k8s.io/apiextensions-apiserver/pkg/apiserver/schema/cel/library/lists.go index db29bedafb5..c0bdb0871ae 100644 --- a/staging/src/k8s.io/apiextensions-apiserver/pkg/apiserver/schema/cel/library/lists.go +++ b/staging/src/k8s.io/apiextensions-apiserver/pkg/apiserver/schema/cel/library/lists.go @@ -182,38 +182,6 @@ func isSorted(val ref.Val) ref.Val { return types.True } -func dynSum() functions.UnaryOp { - return func(val ref.Val) ref.Val { - iterable, ok := val.(traits.Iterable) - if !ok { - return types.MaybeNoSuchOverloadErr(val) - } - it := iterable.Iterator() - var initval ref.Val - if it.HasNext() == types.True { - first := it.Next() - switch first.Type() { - case types.IntType: - initval = types.Int(0) - case types.UintType: - initval = types.Uint(0) - case types.DoubleType: - initval = types.Double(0.0) - case types.DurationType: - initval = types.Duration{Duration: 0} - default: - return types.MaybeNoSuchOverloadErr(first) - } - } else { - initval = types.Int(0) - } - initFn := func() ref.Val { - return initval - } - return sum(initFn)(val) - } -} - func sum(init func() ref.Val) functions.UnaryOp { return func(val ref.Val) ref.Val { i := init() diff --git a/staging/src/k8s.io/apiextensions-apiserver/pkg/apiserver/schema/cel/validation_test.go b/staging/src/k8s.io/apiextensions-apiserver/pkg/apiserver/schema/cel/validation_test.go index 1207ca9afed..06f52a7350c 100644 --- a/staging/src/k8s.io/apiextensions-apiserver/pkg/apiserver/schema/cel/validation_test.go +++ b/staging/src/k8s.io/apiextensions-apiserver/pkg/apiserver/schema/cel/validation_test.go @@ -1605,8 +1605,7 @@ func TestValidationExpressions(t *testing.T) { "dyn([1, 2]).sum() == 3", "dyn([1.0, 2.0]).sum() == 3.0", - // TODO: enable once type system fix it made to CEL - //"[].sum() == 0", // An empty list returns an 0 int + "[].sum() == 0", // An empty list returns an 0 int }, errors: map[string]string{ // return an error for min/max on empty list