Update with stdlib errors
This commit is contained in:
		| @@ -17,6 +17,7 @@ limitations under the License. | |||||||
| package cel | package cel | ||||||
|  |  | ||||||
| import ( | import ( | ||||||
|  | 	"errors" | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 	"strings" | 	"strings" | ||||||
| 	"time" | 	"time" | ||||||
| @@ -24,7 +25,6 @@ import ( | |||||||
| 	"github.com/google/cel-go/cel" | 	"github.com/google/cel-go/cel" | ||||||
| 	"github.com/google/cel-go/checker" | 	"github.com/google/cel-go/checker" | ||||||
| 	"github.com/google/cel-go/common/types" | 	"github.com/google/cel-go/common/types" | ||||||
| 	"github.com/pkg/errors" |  | ||||||
|  |  | ||||||
| 	apiextensions "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" | 	apiextensions "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" | ||||||
| 	"k8s.io/apiextensions-apiserver/pkg/apiserver/schema" | 	"k8s.io/apiextensions-apiserver/pkg/apiserver/schema" | ||||||
| @@ -127,7 +127,7 @@ func Compile(s *schema.Structural, declType *apiservercel.DeclType, perCallLimit | |||||||
| 		return nil, nil | 		return nil, nil | ||||||
| 	} | 	} | ||||||
| 	if declType == nil { | 	if declType == nil { | ||||||
| 		return nil, errors.New("Failed to convert to declType for CEL validation rules") | 		return nil, errors.New("failed to convert to declType for CEL validation rules") | ||||||
| 	} | 	} | ||||||
| 	celRules := s.XValidations | 	celRules := s.XValidations | ||||||
|  |  | ||||||
|   | |||||||
| @@ -718,8 +718,8 @@ func TestCustomResourceValidatorsWithSchemaConversion(t *testing.T) { | |||||||
| 	} | 	} | ||||||
| 	oldCR.Object["metadata"].(map[string]interface{})["labels"] = map[string]interface{}{"key": "value"} | 	oldCR.Object["metadata"].(map[string]interface{})["labels"] = map[string]interface{}{"key": "value"} | ||||||
| 	_, err = crClient.Update(context.TODO(), oldCR, metav1.UpdateOptions{}) | 	_, err = crClient.Update(context.TODO(), oldCR, metav1.UpdateOptions{}) | ||||||
| 	if err == nil || !strings.Contains(err.Error(), "rule compiler initialization error: Failed to convert to declType for CEL validation rules") { | 	if err == nil || !strings.Contains(err.Error(), "rule compiler initialization error: failed to convert to declType for CEL validation rules") { | ||||||
| 		t.Fatalf("expect error to contain \rule compiler initialization error: Failed to convert to declType for CEL validation rules\" but get: %v", err) | 		t.Fatalf("expect error to contain \rule compiler initialization error: failed to convert to declType for CEL validation rules\" but get: %v", err) | ||||||
| 	} | 	} | ||||||
| 	// Create another CR instance with an array and be rejected | 	// Create another CR instance with an array and be rejected | ||||||
| 	name2 := names.SimpleNameGenerator.GenerateName("cr-2") | 	name2 := names.SimpleNameGenerator.GenerateName("cr-2") | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 cici37
					cici37