Skip to content

Commit

Permalink
✨ easier configuration for the compiler
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-rock committed Oct 17, 2022
1 parent c900fbd commit a5ee736
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ require (
github.com/spf13/pflag v1.0.6-0.20201009195203-85dd5c8bc61c
github.com/spf13/viper v1.13.0
github.com/stretchr/testify v1.8.0
go.mondoo.com/cnquery v0.0.0-20221016203430-4b6d2815157f
go.mondoo.com/cnquery v0.0.0-20221017082813-a5bce55f0560
go.mondoo.com/ranger-rpc v0.5.1-0.20220923135836-9e7732899d34
go.opentelemetry.io/otel v1.11.0
golang.org/x/sync v0.0.0-20220923202941-7f9b1623fab7
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1566,8 +1566,8 @@ go.etcd.io/etcd v0.0.0-20200513171258-e048e166ab9c/go.mod h1:xCI7ZzBfRuGgBXyXO6y
go.etcd.io/etcd/api/v3 v3.5.0/go.mod h1:cbVKeC6lCfl7j/8jBhAK6aIYO9XOjdptoxU/nLQcPvs=
go.etcd.io/etcd/client/pkg/v3 v3.5.0/go.mod h1:IJHfcCEKxYu1Os13ZdwCwIUTUVGYTSAM3YSwc9/Ac1g=
go.etcd.io/etcd/client/v2 v2.305.0/go.mod h1:h9puh54ZTgAKtEbut2oe9P4L/oqKCVB6xsXlzd7alYQ=
go.mondoo.com/cnquery v0.0.0-20221016203430-4b6d2815157f h1:1ZIFCJcWuc0w2h/d5n4Gym04PjjD3cp2f9QNBTUi76Q=
go.mondoo.com/cnquery v0.0.0-20221016203430-4b6d2815157f/go.mod h1:E7+94D2X1SMG2Gc7HL5P6FONssPF9i0cXlK9Vr5e+G4=
go.mondoo.com/cnquery v0.0.0-20221017082813-a5bce55f0560 h1:3x5ybu3N0OIJSgjLEfXgo4+dtdH5huRATpZBDFnHJr8=
go.mondoo.com/cnquery v0.0.0-20221017082813-a5bce55f0560/go.mod h1:E7+94D2X1SMG2Gc7HL5P6FONssPF9i0cXlK9Vr5e+G4=
go.mondoo.com/ranger-rpc v0.5.1-0.20220923135836-9e7732899d34 h1:mtPZ1J+nRI/ivV+n41bjIwY6Rfxb2Jf49svZSQMGHIA=
go.mondoo.com/ranger-rpc v0.5.1-0.20220923135836-9e7732899d34/go.mod h1:3YKcqFrlPgaB4FZ4EoLgdmRtwMQdO7RoAkZYFn+F1eY=
go.mozilla.org/mozlog v0.0.0-20170222151521-4bb13139d403/go.mod h1:jHoPAGnDrCy6kaI2tAze5Prf0Nr0w/oNkROt2lw3n3o=
Expand Down
2 changes: 1 addition & 1 deletion policy/executor/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ func (e *Executor) AreAllResultsCollected() bool {

// Compile a given code with the default schema
func (e *Executor) Compile(code string, props map[string]*llx.Primitive) (*llx.CodeBundle, error) {
return mqlc.Compile(code, e.schema, cnquery.Features{byte(cnquery.PiperCode)}, props)
return mqlc.Compile(code, props, mqlc.NewConfig(e.schema, cnquery.DefaultFeatures))
}

func (e *Executor) AddCode(code string, props map[string]*llx.Primitive) (*llx.CodeBundle, error) {
Expand Down
2 changes: 1 addition & 1 deletion policy/executor/graph.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func ExecuteFilterQueries(schema *resources.Schema, runtime *resources.Runtime,

builder := internal.NewBuilder()
for _, m := range queries {
codeBundle, err := mqlc.Compile(m.Query, schema, cnquery.Features{}, nil)
codeBundle, err := mqlc.Compile(m.Query, nil, mqlc.NewConfig(schema, cnquery.DefaultFeatures))
if err != nil {
errs = append(errs, err)
continue
Expand Down
2 changes: 1 addition & 1 deletion policy/executor/mustcompile.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
)

func MustCompile(code string) *llx.CodeBundle {
codeBundle, err := mqlc.Compile(code, info.Registry.Schema(), cnquery.DefaultFeatures, nil)
codeBundle, err := mqlc.Compile(code, nil, mqlc.NewConfig(info.Registry.Schema(), cnquery.DefaultFeatures))
if err != nil {
panic(err)
}
Expand Down
3 changes: 1 addition & 2 deletions policy/mquery.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ func (m *Mquery) Compile(props map[string]*llx.Primitive) (*llx.CodeBundle, erro

schema := info.Registry.Schema()

v2Code, err := mqlc.Compile(m.Query, schema,
cnquery.Features{byte(cnquery.PiperCode)}, props)
v2Code, err := mqlc.Compile(m.Query, props, mqlc.NewConfig(schema, cnquery.DefaultFeatures))
if err != nil {
return nil, err
}
Expand Down

0 comments on commit a5ee736

Please sign in to comment.