Merge pull request #117593 from jpbetz/test-join
Fix bug where CEL listOfString.join() results in unexpected error Kubernetes-commit: 8ae8e7756075088b7178246457efc6859f192fc4
This commit is contained in:
commit
bd86839aba
4
go.mod
4
go.mod
|
|
@ -43,7 +43,7 @@ require (
|
||||||
gopkg.in/square/go-jose.v2 v2.6.0
|
gopkg.in/square/go-jose.v2 v2.6.0
|
||||||
k8s.io/api v0.0.0-20230425174508-34a8caec8792
|
k8s.io/api v0.0.0-20230425174508-34a8caec8792
|
||||||
k8s.io/apimachinery v0.0.0-20230425174017-478f0974b2e7
|
k8s.io/apimachinery v0.0.0-20230425174017-478f0974b2e7
|
||||||
k8s.io/client-go v0.0.0-20230425180616-6c514ab3ffc5
|
k8s.io/client-go v0.0.0-20230426214258-68394bf4659a
|
||||||
k8s.io/component-base v0.0.0-20230425180508-25833dc857cd
|
k8s.io/component-base v0.0.0-20230425180508-25833dc857cd
|
||||||
k8s.io/klog/v2 v2.90.1
|
k8s.io/klog/v2 v2.90.1
|
||||||
k8s.io/kms v0.0.0-20230425181524-5ea13ac087e1
|
k8s.io/kms v0.0.0-20230425181524-5ea13ac087e1
|
||||||
|
|
@ -126,7 +126,7 @@ require (
|
||||||
replace (
|
replace (
|
||||||
k8s.io/api => k8s.io/api v0.0.0-20230425174508-34a8caec8792
|
k8s.io/api => k8s.io/api v0.0.0-20230425174508-34a8caec8792
|
||||||
k8s.io/apimachinery => k8s.io/apimachinery v0.0.0-20230425174017-478f0974b2e7
|
k8s.io/apimachinery => k8s.io/apimachinery v0.0.0-20230425174017-478f0974b2e7
|
||||||
k8s.io/client-go => k8s.io/client-go v0.0.0-20230425180616-6c514ab3ffc5
|
k8s.io/client-go => k8s.io/client-go v0.0.0-20230426214258-68394bf4659a
|
||||||
k8s.io/component-base => k8s.io/component-base v0.0.0-20230425180508-25833dc857cd
|
k8s.io/component-base => k8s.io/component-base v0.0.0-20230425180508-25833dc857cd
|
||||||
k8s.io/kms => k8s.io/kms v0.0.0-20230425181524-5ea13ac087e1
|
k8s.io/kms => k8s.io/kms v0.0.0-20230425181524-5ea13ac087e1
|
||||||
)
|
)
|
||||||
|
|
|
||||||
4
go.sum
4
go.sum
|
|
@ -883,8 +883,8 @@ k8s.io/api v0.0.0-20230425174508-34a8caec8792 h1:mGcfWRFyPLifZx7CBntz6LxPBBE6Gtq
|
||||||
k8s.io/api v0.0.0-20230425174508-34a8caec8792/go.mod h1:LQhP+jUK/yp/Z1OG2fUqsYRc/AKbQQVkgXyiJ44Q+qo=
|
k8s.io/api v0.0.0-20230425174508-34a8caec8792/go.mod h1:LQhP+jUK/yp/Z1OG2fUqsYRc/AKbQQVkgXyiJ44Q+qo=
|
||||||
k8s.io/apimachinery v0.0.0-20230425174017-478f0974b2e7 h1:kc4xpkjTIwj4xzt2kaydYoy7CVavI8fnN3TxrsBh2/s=
|
k8s.io/apimachinery v0.0.0-20230425174017-478f0974b2e7 h1:kc4xpkjTIwj4xzt2kaydYoy7CVavI8fnN3TxrsBh2/s=
|
||||||
k8s.io/apimachinery v0.0.0-20230425174017-478f0974b2e7/go.mod h1:8pvYyRbWovK8tOF+ubfyUBX6aGREZx9m61vDDA9aDTU=
|
k8s.io/apimachinery v0.0.0-20230425174017-478f0974b2e7/go.mod h1:8pvYyRbWovK8tOF+ubfyUBX6aGREZx9m61vDDA9aDTU=
|
||||||
k8s.io/client-go v0.0.0-20230425180616-6c514ab3ffc5 h1:tbzR21/s+ZwDPnhanVzRFEhfCkxQGNPP2vDrQJWCRdM=
|
k8s.io/client-go v0.0.0-20230426214258-68394bf4659a h1:DJK/gsrfYrbzazQyWJDLxjeOWO7z+yT+wAndLomlfro=
|
||||||
k8s.io/client-go v0.0.0-20230425180616-6c514ab3ffc5/go.mod h1:mOtwcrxgBPCkq+D7sTFzZU6AtYLwM5e3yb7ZOL8Jo4A=
|
k8s.io/client-go v0.0.0-20230426214258-68394bf4659a/go.mod h1:mOtwcrxgBPCkq+D7sTFzZU6AtYLwM5e3yb7ZOL8Jo4A=
|
||||||
k8s.io/component-base v0.0.0-20230425180508-25833dc857cd h1:B08ilgekcDw06evInMZEb3QBb3P56QwiiZ+0GgY42nY=
|
k8s.io/component-base v0.0.0-20230425180508-25833dc857cd h1:B08ilgekcDw06evInMZEb3QBb3P56QwiiZ+0GgY42nY=
|
||||||
k8s.io/component-base v0.0.0-20230425180508-25833dc857cd/go.mod h1:/xqjhhBDsK5gm+edxsyMtzFn22ruDQedvXFBEH3IfmA=
|
k8s.io/component-base v0.0.0-20230425180508-25833dc857cd/go.mod h1:/xqjhhBDsK5gm+edxsyMtzFn22ruDQedvXFBEH3IfmA=
|
||||||
k8s.io/klog/v2 v2.90.1 h1:m4bYOKall2MmOiRaR1J+We67Do7vm9KiQVlT96lnHUw=
|
k8s.io/klog/v2 v2.90.1 h1:m4bYOKall2MmOiRaR1J+We67Do7vm9KiQVlT96lnHUw=
|
||||||
|
|
|
||||||
|
|
@ -26,9 +26,10 @@ import (
|
||||||
"github.com/google/cel-go/common/types/ref"
|
"github.com/google/cel-go/common/types/ref"
|
||||||
"github.com/google/cel-go/common/types/traits"
|
"github.com/google/cel-go/common/types/traits"
|
||||||
|
|
||||||
|
"k8s.io/kube-openapi/pkg/validation/strfmt"
|
||||||
|
|
||||||
"k8s.io/apimachinery/pkg/api/equality"
|
"k8s.io/apimachinery/pkg/api/equality"
|
||||||
"k8s.io/apiserver/pkg/cel"
|
"k8s.io/apiserver/pkg/cel"
|
||||||
"k8s.io/kube-openapi/pkg/validation/strfmt"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// UnstructuredToVal converts a Kubernetes unstructured data element to a CEL Val.
|
// UnstructuredToVal converts a Kubernetes unstructured data element to a CEL Val.
|
||||||
|
|
@ -425,7 +426,22 @@ var _ = traits.Lister(&unstructuredList{})
|
||||||
func (t *unstructuredList) ConvertToNative(typeDesc reflect.Type) (interface{}, error) {
|
func (t *unstructuredList) ConvertToNative(typeDesc reflect.Type) (interface{}, error) {
|
||||||
switch typeDesc.Kind() {
|
switch typeDesc.Kind() {
|
||||||
case reflect.Slice:
|
case reflect.Slice:
|
||||||
return t.elements, nil
|
switch t.itemsSchema.Type() {
|
||||||
|
// Workaround for https://github.com/kubernetes/kubernetes/issues/117590 until we
|
||||||
|
// resolve the desired behavior in cel-go via https://github.com/google/cel-go/issues/688
|
||||||
|
case "string":
|
||||||
|
var result []string
|
||||||
|
for _, e := range t.elements {
|
||||||
|
s, ok := e.(string)
|
||||||
|
if !ok {
|
||||||
|
return nil, fmt.Errorf("expected all elements to be of type string, but got %T", e)
|
||||||
|
}
|
||||||
|
result = append(result, s)
|
||||||
|
}
|
||||||
|
return result, nil
|
||||||
|
default:
|
||||||
|
return t.elements, nil
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return nil, fmt.Errorf("type conversion error from '%s' to '%s'", t.Type(), typeDesc)
|
return nil, fmt.Errorf("type conversion error from '%s' to '%s'", t.Type(), typeDesc)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue