go.mondoo.com/cnquery@v0.0.0-20231005093811-59568235f6ea/explorer/executor/mustcompile.go (about) 1 // Copyright (c) Mondoo, Inc. 2 // SPDX-License-Identifier: BUSL-1.1 3 4 package executor 5 6 import ( 7 "go.mondoo.com/cnquery" 8 "go.mondoo.com/cnquery/llx" 9 "go.mondoo.com/cnquery/mqlc" 10 "go.mondoo.com/cnquery/providers" 11 ) 12 13 func MustCompile(code string) *llx.CodeBundle { 14 codeBundle, err := mqlc.Compile(code, nil, 15 mqlc.NewConfig(providers.DefaultRuntime().Schema(), cnquery.DefaultFeatures)) 16 if err != nil { 17 panic(err) 18 } 19 return codeBundle 20 } 21 22 func MustGetOneDatapoint(codeBundle *llx.CodeBundle) string { 23 if len(codeBundle.CodeV2.Entrypoints()) != 1 { 24 panic("code bundle has more than 1 entrypoint") 25 } 26 27 entrypoint := codeBundle.CodeV2.Entrypoints()[0] 28 checksum, ok := codeBundle.CodeV2.Checksums[entrypoint] 29 if !ok { 30 panic("could not find the data point for the entrypoint") 31 } 32 33 return checksum 34 }