diff --git a/repl/BUILD.bazel b/repl/BUILD.bazel index d19160a6..7bdf263a 100644 --- a/repl/BUILD.bazel +++ b/repl/BUILD.bazel @@ -37,7 +37,12 @@ go_library( "//interpreter:go_default_library", "//repl/parser:go_default_library", "@com_github_antlr4_go_antlr_v4//:go_default_library", + "@com_google_cel_spec//proto/test/v1/proto2:test_all_types_go_proto", + "@com_google_cel_spec//proto/test/v1/proto3:test_all_types_go_proto", + "@org_golang_google_protobuf//reflect/protoreflect:go_default_library", + "@org_golang_google_protobuf//reflect/protodesc:go_default_library", "@org_golang_google_genproto_googleapis_api//expr/v1alpha1:go_default_library", + "@org_golang_google_genproto_googleapis_rpc//context/attribute_context:go_default_library", "@org_golang_google_protobuf//encoding/prototext:go_default_library", "@org_golang_google_protobuf//proto:go_default_library", "@org_golang_google_protobuf//types/descriptorpb:go_default_library", diff --git a/repl/appengine/go.mod b/repl/appengine/go.mod index 466beb43..6bdb87f3 100644 --- a/repl/appengine/go.mod +++ b/repl/appengine/go.mod @@ -7,6 +7,7 @@ require github.com/google/cel-go/repl v0.0.0-20230406155237-b081aea03865 require ( github.com/antlr4-go/antlr/v4 v4.13.0 // indirect github.com/google/cel-go v0.18.1 // indirect + github.com/google/cel-spec v0.13.0 // indirect github.com/stoewer/go-strcase v1.3.0 // indirect golang.org/x/exp v0.0.0-20230515195305-f3d0a9c9a5cc // indirect golang.org/x/text v0.9.0 // indirect diff --git a/repl/appengine/go.sum b/repl/appengine/go.sum index 9dbd5d0c..9431c181 100644 --- a/repl/appengine/go.sum +++ b/repl/appengine/go.sum @@ -4,6 +4,10 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= +github.com/google/cel-go v0.18.1 h1:V/lAXKq4C3BYLDy/ARzMtpkEEYfHQpZzVyzy69nEUjs= +github.com/google/cel-go v0.18.1/go.mod h1:PVAybmSnWkNMUZR/tEWFUiJ1Np4Hz0MHsZJcgC4zln4= +github.com/google/cel-spec v0.13.0 h1:5nfThDaiEQjx9cv+uB9DpDyWsP9j1gsSGWubZRHc4rg= +github.com/google/cel-spec v0.13.0/go.mod h1:kml2o4+MolVRtnyfTn6uTN+694OYIxnyIX1ARTkAYzM= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= diff --git a/repl/appengine/web/package-lock.json b/repl/appengine/web/package-lock.json index 4a170317..ec3855c8 100644 --- a/repl/appengine/web/package-lock.json +++ b/repl/appengine/web/package-lock.json @@ -635,9 +635,9 @@ } }, "node_modules/@angular/compiler-cli/node_modules/@babel/core/node_modules/semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", "dev": true, "bin": { "semver": "bin/semver.js" @@ -865,9 +865,9 @@ } }, "node_modules/@babel/core/node_modules/semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", "dev": true, "bin": { "semver": "bin/semver.js" @@ -946,9 +946,9 @@ } }, "node_modules/@babel/helper-compilation-targets/node_modules/semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", "dev": true, "bin": { "semver": "bin/semver.js" @@ -1010,9 +1010,9 @@ } }, "node_modules/@babel/helper-define-polyfill-provider/node_modules/semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", "dev": true, "bin": { "semver": "bin/semver.js" @@ -2189,9 +2189,9 @@ } }, "node_modules/@babel/plugin-transform-runtime/node_modules/semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", "dev": true, "bin": { "semver": "bin/semver.js" @@ -2394,9 +2394,9 @@ } }, "node_modules/@babel/preset-env/node_modules/semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", "dev": true, "bin": { "semver": "bin/semver.js" @@ -5140,9 +5140,9 @@ } }, "node_modules/babel-plugin-polyfill-corejs2/node_modules/semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", "dev": true, "bin": { "semver": "bin/semver.js" @@ -8455,9 +8455,9 @@ } }, "node_modules/istanbul-lib-instrument/node_modules/semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", "dev": true, "bin": { "semver": "bin/semver.js" @@ -8955,9 +8955,9 @@ } }, "node_modules/less/node_modules/semver": { - "version": "5.7.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", - "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", + "version": "5.7.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.2.tgz", + "integrity": "sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==", "dev": true, "optional": true, "bin": { @@ -9197,9 +9197,9 @@ } }, "node_modules/make-dir/node_modules/semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", "dev": true, "bin": { "semver": "bin/semver.js" diff --git a/repl/appengine/web/src/app/reference_panel/reference-panel-component.html b/repl/appengine/web/src/app/reference_panel/reference-panel-component.html index 19bd7a42..d035cf9e 100644 --- a/repl/appengine/web/src/app/reference_panel/reference-panel-component.html +++ b/repl/appengine/web/src/app/reference_panel/reference-panel-component.html @@ -48,6 +48,7 @@

References

+

Canonical Extensions

diff --git a/repl/appengine/web/src/app/reference_panel/reference-panel-component.ts b/repl/appengine/web/src/app/reference_panel/reference-panel-component.ts index 14458ecf..6925aa0b 100644 --- a/repl/appengine/web/src/app/reference_panel/reference-panel-component.ts +++ b/repl/appengine/web/src/app/reference_panel/reference-panel-component.ts @@ -79,6 +79,23 @@ const examples = new Map([ ] } }], + ["structs", { + "request": { + commands: [ + `%load_descriptors --pkg 'google-rpc'`, + `%option --container "google.rpc.context"`, + `%let now = timestamp("2001-01-01T00:00:01Z")`, + `%let sa_user = "example-service"`, + `AttributeContext.Request{ + auth: AttributeContext.Auth{ + principal: sa_user, + audiences: ['my-project'], + }, + time: now + }` + ] + } + }], ["macros", { "request": { commands: [ diff --git a/repl/commands.go b/repl/commands.go index f708bd4d..1eb144a7 100644 --- a/repl/commands.go +++ b/repl/commands.go @@ -47,6 +47,12 @@ optional language features. %option --container 'google.protobuf' %option --extension 'all'` + loadDescriptorsUsage = `LoadDescriptors loads a protobuf descriptor file (google.protobuf.FileDescriptorSet) +from disk or from a predefined package. Supported packages are "cel-spec-test-types" +(TestAllTypes) and "google-rpc" (AttributeContext). +%load_descriptors 'path/to/descriptor_set.binarypb' +%load_descriptors --pkg 'cel-spec-test-types'` + exitUsage = `Exit terminates the REPL. %exit` @@ -184,6 +190,7 @@ func Parse(line string) (Cmder, error) { deleteUsage, letUsage, optionUsage, + loadDescriptorsUsage, helpUsage, exitUsage, }, "\n\n")) diff --git a/repl/commands_test.go b/repl/commands_test.go index 57a322b3..ff135fb1 100644 --- a/repl/commands_test.go +++ b/repl/commands_test.go @@ -178,6 +178,12 @@ func TestParse(t *testing.T) { optional language features. %option --container 'google.protobuf' %option --extension 'all' + + LoadDescriptors loads a protobuf descriptor file (google.protobuf.FileDescriptorSet) + from disk or from a predefined package. Supported packages are "cel-spec-test-types" + (TestAllTypes) and "google-rpc" (AttributeContext). + %load_descriptors 'path/to/descriptor_set.binarypb' + %load_descriptors --pkg 'cel-spec-test-types' Help prints usage information for the commands supported by the REPL. %help diff --git a/repl/evaluator.go b/repl/evaluator.go index 02b74061..d811aebe 100644 --- a/repl/evaluator.go +++ b/repl/evaluator.go @@ -31,8 +31,13 @@ import ( "google.golang.org/protobuf/encoding/prototext" "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/reflect/protodesc" + "google.golang.org/protobuf/reflect/protoreflect" + test2pb "github.com/google/cel-spec/proto/test/v1/proto2/test_all_types" + test3pb "github.com/google/cel-spec/proto/test/v1/proto3/test_all_types" exprpb "google.golang.org/genproto/googleapis/api/expr/v1alpha1" + attrpb "google.golang.org/genproto/googleapis/rpc/context/attribute_context" descpb "google.golang.org/protobuf/types/descriptorpb" ) @@ -656,12 +661,17 @@ func (e *Evaluator) applyContext() (*cel.Env, interpreter.Activation, error) { // typeOption implements optioner for loading a set of types defined by a protobuf file descriptor set. type typeOption struct { - path string - fds *descpb.FileDescriptorSet + path string + fds *descpb.FileDescriptorSet + isPkg bool } func (o *typeOption) String() string { - return fmt.Sprintf("%%load_descriptors '%s'", o.path) + flags := "" + if o.isPkg { + flags = "--pkg" + } + return fmt.Sprintf("%%load_descriptors %s '%s'", flags, o.path) } func (o *typeOption) Option() cel.EnvOption { @@ -826,22 +836,50 @@ func loadFileDescriptorSet(path string, textfmt bool) (*descpb.FileDescriptorSet return &fds, nil } -func (e *Evaluator) loadDescriptors(args []string) error { - if len(args) < 1 { - return errors.New("expected path for load descriptors") +func deps(d protoreflect.FileDescriptor) []*descpb.FileDescriptorProto { + var descriptorProtos []*descpb.FileDescriptorProto + + for i := 0; i < d.Imports().Len(); i++ { + descriptorProtos = append(descriptorProtos, + protodesc.ToFileDescriptorProto(d.Imports().Get(i))) } - textfmt := true + return descriptorProtos +} - flags := args[:len(args)-1] +func (e *Evaluator) loadDescriptorFromPackage(pkg string) error { + if pkg == "cel-spec-test-types" { + fdp := (&test2pb.TestAllTypes{}).ProtoReflect().Type().Descriptor().ParentFile() + fdp2 := (&test3pb.TestAllTypes{}).ProtoReflect().Type().Descriptor().ParentFile() - for _, flag := range flags { - if flag == "--binarypb" { - textfmt = false + descriptorProtos := deps(fdp) + + descriptorProtos = append(descriptorProtos, + protodesc.ToFileDescriptorProto(fdp), + protodesc.ToFileDescriptorProto(fdp2)) + + fds := descpb.FileDescriptorSet{ + File: descriptorProtos, } + + return e.AddOption(&typeOption{pkg, &fds, true}) + } else if pkg == "google-rpc" { + fdp := (&attrpb.AttributeContext{}).ProtoReflect().Type().Descriptor().ParentFile() + + descriptorProtos := append(deps(fdp), + protodesc.ToFileDescriptorProto(fdp)) + + fds := descpb.FileDescriptorSet{ + File: descriptorProtos, + } + + return e.AddOption(&typeOption{pkg, &fds, true}) } - p := args[len(args)-1] + return fmt.Errorf("unknown type package: '%s'", pkg) +} + +func (e *Evaluator) loadDescriptorFromFile(p string, textfmt bool) error { fds, err := loadFileDescriptorSet(p, textfmt) if err != nil { return fmt.Errorf("error loading file: %v", err) @@ -850,6 +888,55 @@ func (e *Evaluator) loadDescriptors(args []string) error { return e.AddOption(&typeOption{path: p, fds: fds}) } +func (e *Evaluator) loadDescriptors(args []string) error { + if len(args) < 1 { + return errors.New("expected args for load descriptors") + } + + textfmt := true + + var paths []string + var pkgs []string + nextIsPkg := false + for _, flag := range args { + switch flag { + case "--binarypb": + { + textfmt = false + } + case "--pkg": + { + nextIsPkg = true + } + default: + { + if nextIsPkg { + pkgs = append(pkgs, flag) + nextIsPkg = false + } else { + paths = append(paths, flag) + } + } + } + } + + for _, p := range paths { + err := e.loadDescriptorFromFile(p, textfmt) + if err != nil { + return err + } + } + + for _, p := range pkgs { + err := e.loadDescriptorFromPackage(p) + if err != nil { + return err + } + } + + return nil +} + // Process processes the command provided. func (e *Evaluator) Process(cmd Cmder) (string, bool, error) { switch cmd := cmd.(type) { diff --git a/repl/evaluator_test.go b/repl/evaluator_test.go index e279850b..4d58536c 100644 --- a/repl/evaluator_test.go +++ b/repl/evaluator_test.go @@ -755,6 +755,71 @@ func TestProcess(t *testing.T) { wantExit: false, wantError: false, }, + { + name: "LoadDescriptorsPackageSpec", + commands: []Cmder{ + &simpleCmd{ + cmd: "load_descriptors", + args: []string{ + "--pkg", + "cel-spec-test-types", + }, + }, + &simpleCmd{ + cmd: "option", + args: []string{ + "--container", + "google.api.expr.test.v1", + }, + }, + &evalCmd{ + expr: "proto2.TestAllTypes{single_int64: 42}.single_int64 == proto3.TestAllTypes{single_int64: 42}.single_int64", + }, + }, + wantText: `true : bool`, + wantExit: false, + wantError: false, + }, + { + name: "LoadDescriptorsPackageRpc", + commands: []Cmder{ + &simpleCmd{ + cmd: "load_descriptors", + args: []string{ + "--pkg", + "google-rpc", + }, + }, + &simpleCmd{ + cmd: "option", + args: []string{ + "--container", + "google.rpc.context", + }, + }, + &evalCmd{ + expr: "AttributeContext{source: AttributeContext.Peer{ip: '192.168.0.1'}}.source.ip == '192.168.0.1'", + }, + }, + wantText: `true : bool`, + wantExit: false, + wantError: false, + }, + { + name: "LoadDescriptorsPackageUnknown", + commands: []Cmder{ + &simpleCmd{ + cmd: "load_descriptors", + args: []string{ + "--pkg", + "'unknown'", + }, + }, + }, + wantText: "", + wantExit: false, + wantError: true, + }, { name: "Status", commands: []Cmder{ diff --git a/repl/go.mod b/repl/go.mod index 2e9dc115..7e78f467 100644 --- a/repl/go.mod +++ b/repl/go.mod @@ -6,7 +6,9 @@ require ( github.com/antlr4-go/antlr/v4 v4.13.0 github.com/chzyer/readline v1.5.1 github.com/google/cel-go v0.18.1 + github.com/google/cel-spec v0.13.0 google.golang.org/genproto/googleapis/api v0.0.0-20230803162519-f966b187b2e5 + google.golang.org/genproto/googleapis/rpc v0.0.0-20230803162519-f966b187b2e5 google.golang.org/protobuf v1.31.0 ) @@ -15,7 +17,6 @@ require ( golang.org/x/exp v0.0.0-20230515195305-f3d0a9c9a5cc // indirect golang.org/x/sys v0.8.0 // indirect golang.org/x/text v0.9.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20230803162519-f966b187b2e5 // indirect ) replace github.com/google/cel-go => ../. diff --git a/repl/go.sum b/repl/go.sum index 0656f227..403c50a1 100644 --- a/repl/go.sum +++ b/repl/go.sum @@ -1,3 +1,5 @@ +github.com/antlr/antlr4/runtime/Go/antlr/v4 v4.0.0-20230321174746-8dcc6526cfb1 h1:X8MJ0fnN5FPdcGF5Ij2/OW+HgiJrRg3AfHAx1PJtIzM= +github.com/antlr/antlr4/runtime/Go/antlr/v4 v4.0.0-20230321174746-8dcc6526cfb1/go.mod h1:pSwJ0fSY5KhvocuWSx4fz3BA8OrA1bQn+K1Eli3BRwM= github.com/antlr4-go/antlr/v4 v4.13.0 h1:lxCg3LAv+EUK6t1i0y1V6/SLeUi0eKEKdhQAlS8TVTI= github.com/antlr4-go/antlr/v4 v4.13.0/go.mod h1:pfChB/xh/Unjila75QW7+VU4TSnWnnk9UTnmpPaOR2g= github.com/chzyer/logex v1.2.1 h1:XHDu3E6q+gdHgsdTPH6ImJMIp436vR6MPtH8gP05QzM= @@ -10,6 +12,8 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= +github.com/google/cel-spec v0.13.0 h1:5nfThDaiEQjx9cv+uB9DpDyWsP9j1gsSGWubZRHc4rg= +github.com/google/cel-spec v0.13.0/go.mod h1:kml2o4+MolVRtnyfTn6uTN+694OYIxnyIX1ARTkAYzM= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= diff --git a/repl/main/README.md b/repl/main/README.md index d743dede..8063e2f4 100644 --- a/repl/main/README.md +++ b/repl/main/README.md @@ -133,17 +133,24 @@ definition. #### load_descriptors -`%load_descriptors` loads a file descriptor set from file into the context. -Message types from the file are available for use in later expressions as -CEL structs. +`%load_descriptors` loads a file descriptor set from file into the context (a +google.protobuf.FileDescriptorSet message). Message types from the file are +available for use in later expressions as CEL structs. -Accepts an argument for the filedescriptor file format: `--textproto` or -`--binarypb`. +`--textproto` expect the file format as protobuf text format. + +`--binarypb` expect the file format as serialized protobuf. + +`--pkg ` Alternatively, a few well known types are included in the +binary and can be added with the `--pkg` flag. Available packages: `google-rpc`, +`cel-spec-test-types`. example: `%load_descriptors --textproto "./testdata/attribute_context_fds.textproto"` +`%load_descriptors --pkg "google-rpc"` + #### option `%option` sets an environment option. Options are specified with flags that