Skip to content

Commit

Permalink
feat: update v1alpha1 CEL syntax protos to include extension tags fro…
Browse files Browse the repository at this point in the history
…m cel-spec

docs: automated formatting fixes

PiperOrigin-RevId: 603439044
  • Loading branch information
Google APIs authored and Copybara-Service committed Feb 1, 2024
1 parent 207beee commit 5e6eb76
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 13 deletions.
2 changes: 1 addition & 1 deletion google/api/expr/v1alpha1/checked.proto
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2022 Google LLC
// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion google/api/expr/v1alpha1/eval.proto
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2022 Google LLC
// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion google/api/expr/v1alpha1/explain.proto
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2022 Google LLC
// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
75 changes: 66 additions & 9 deletions google/api/expr/v1alpha1/syntax.proto
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2022 Google LLC
// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -44,21 +44,24 @@ message ParsedExpr {
// operators with the exception of the '.' operator are modelled as function
// calls. This makes it easy to represent new operators into the existing AST.
//
// All references within expressions must resolve to a [Decl][google.api.expr.v1alpha1.Decl] provided at
// type-check for an expression to be valid. A reference may either be a bare
// identifier `name` or a qualified identifier `google.api.name`. References
// may either refer to a value or a function declaration.
// All references within expressions must resolve to a
// [Decl][google.api.expr.v1alpha1.Decl] provided at type-check for an
// expression to be valid. A reference may either be a bare identifier `name` or
// a qualified identifier `google.api.name`. References may either refer to a
// value or a function declaration.
//
// For example, the expression `google.api.name.startsWith('expr')` references
// the declaration `google.api.name` within a [Expr.Select][google.api.expr.v1alpha1.Expr.Select] expression, and
// the function declaration `startsWith`.
// the declaration `google.api.name` within a
// [Expr.Select][google.api.expr.v1alpha1.Expr.Select] expression, and the
// function declaration `startsWith`.
message Expr {
// An identifier expression. e.g. `request`.
message Ident {
// Required. Holds a single, unqualified identifier, possibly preceded by a
// '.'.
//
// Qualified names are represented by the [Expr.Select][google.api.expr.v1alpha1.Expr.Select] expression.
// Qualified names are represented by the
// [Expr.Select][google.api.expr.v1alpha1.Expr.Select] expression.
string name = 1;
}

Expand Down Expand Up @@ -250,7 +253,8 @@ message Expr {
// primitives.
//
// Lists and structs are not included as constants as these aggregate types may
// contain [Expr][google.api.expr.v1alpha1.Expr] elements which require evaluation and are thus not constant.
// contain [Expr][google.api.expr.v1alpha1.Expr] elements which require
// evaluation and are thus not constant.
//
// Examples of literals include: `"hello"`, `b'bytes'`, `1u`, `4.2`, `-2`,
// `true`, `null`.
Expand Down Expand Up @@ -292,6 +296,50 @@ message Constant {

// Source information collected at parse time.
message SourceInfo {
// An extension that was requested for the source expression.
message Extension {
// Version
message Version {
// Major version changes indicate different required support level from
// the required components.
int64 major = 1;

// Minor version changes must not change the observed behavior from
// existing implementations, but may be provided informationally.
int64 minor = 2;
}

// CEL component specifier.
enum Component {
// Unspecified, default.
COMPONENT_UNSPECIFIED = 0;

// Parser. Converts a CEL string to an AST.
COMPONENT_PARSER = 1;

// Type checker. Checks that references in an AST are defined and types
// agree.
COMPONENT_TYPE_CHECKER = 2;

// Runtime. Evaluates a parsed and optionally checked CEL AST against a
// context.
COMPONENT_RUNTIME = 3;
}

// Identifier for the extension. Example: constant_folding
string id = 1;

// If set, the listed components must understand the extension for the
// expression to evaluate correctly.
//
// This field has set semantics, repeated values should be deduplicated.
repeated Component affected_components = 2;

// Version info. May be skipped if it isn't meaningful for the extension.
// (for example constant_folding might always be v0.0).
Version version = 3;
}

// The syntax version of the source, e.g. `cel1`.
string syntax_version = 1;

Expand Down Expand Up @@ -323,6 +371,15 @@ message SourceInfo {
// in the map corresponds to the expression id of the expanded macro, and the
// value is the call `Expr` that was replaced.
map<int64, Expr> macro_calls = 5;

// A list of tags for extensions that were used while parsing or type checking
// the source expression. For example, optimizations that require special
// runtime support may be specified.
//
// These are used to check feature support between components in separate
// implementations. This can be used to either skip redundant work or
// report an error if the extension is unsupported.
repeated Extension extensions = 6;
}

// A specific position in source.
Expand Down
2 changes: 1 addition & 1 deletion google/api/expr/v1alpha1/value.proto
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2022 Google LLC
// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down

0 comments on commit 5e6eb76

Please sign in to comment.