@@ -264,8 +264,10 @@ func runQuery(stdout, stderr io.Writer, args []string) error {
264264 if configErr != nil {
265265 return configErr
266266 }
267- if len (externalDirs ) == 0 {
268- externalDirs = configOptions .ExternalDirs
267+ cliExternalDirs := externalDirs
268+ discoveryExternalDirs := externalDirs
269+ if len (discoveryExternalDirs ) == 0 {
270+ discoveryExternalDirs = configOptions .ExternalDirs
269271 }
270272 if configOptions .NoExternalFacts {
271273 * noExternalFacts = true
@@ -276,16 +278,21 @@ func runQuery(stdout, stderr io.Writer, args []string) error {
276278 if configOptions .Verbose {
277279 * verbose = true
278280 }
279- if * noExternalFacts && hasNonEmpty (externalDirs ) {
281+ if * noExternalFacts && hasNonEmpty (discoveryExternalDirs ) {
280282 return optionError (stdout , errors .New ("--no-external-facts and --external-dir options conflict: please specify only one" ))
281283 }
282284 if ! * noExternalFacts {
283- externalDirs = effectiveExternalDirs (externalDirs )
285+ discoveryExternalDirs = effectiveExternalDirs (discoveryExternalDirs )
286+ }
287+ blockedFactsForFastPath := map [string ]bool {}
288+ var blockedFacts map [string ]bool
289+ if * noBlock {
290+ blockedFacts = map [string ]bool {}
284291 }
285- blockedFacts := map [string ]bool {}
286292 if ! * noBlock {
287- blockedFacts = engine .BlocklistedFactsForFiltering (configOptions .Blocklist , configOptions .FactGroups )
293+ blockedFactsForFastPath = engine .BlocklistedFactsForFiltering (configOptions .Blocklist , configOptions .FactGroups )
288294 }
295+ mergeDottedFacts := configOptions .ForceDotResolution || * forceDotResolution
289296 logLevel := firstNonEmpty (flags .Lookup ("log-level" ).Value .String (), flags .Lookup ("l" ).Value .String (), configOptions .LogLevel )
290297 if logLevel != "" && ! cli .SupportedLogLevel (logLevel ) {
291298 return optionError (stdout , fmt .Errorf ("unsupported log level %s" , logLevel ))
@@ -304,17 +311,25 @@ func runQuery(stdout, stderr io.Writer, args []string) error {
304311 writeInfo (stderr , "executed with command line: " + strings .Join (args , " " ), colorDiagnostics )
305312 writeInfo (stderr , "resolving facts" , colorDiagnostics )
306313 }
307- if canUseVersionQueryFastPath (flags .Args (), externalDirs , blockedFacts , * noExternalFacts , * timing || * timingShort ) {
314+ if canUseVersionQueryFastPath (flags .Args (), discoveryExternalDirs , blockedFactsForFastPath , * noExternalFacts , * timing || * timingShort ) {
308315 return writeVersionQuery (stdout , * jsonOutput || * jsonOutputShort , * yamlOutput || * yamlOutputShort , * hoconOutput )
309316 }
310317 resolutionStart := time .Now ()
311318
312319 eng , err := engine .NewEngine (engine.EngineConfig {
313- CLICompat : true ,
314- ExternalDirs : externalDirs ,
315- NoExternalFacts : * noExternalFacts ,
316- BlockedFacts : blockedFacts ,
317- Logger : logger ,
320+ CLICompat : true ,
321+ SystemDefaults : true ,
322+ ConfigFile : configFile ,
323+ ConfigLoaded : true ,
324+ Config : configOptions ,
325+ ExternalDirs : cliExternalDirs ,
326+ UseCache : ! * noCache ,
327+ NoExternalFacts : * noExternalFacts ,
328+ BlockedFacts : blockedFacts ,
329+ DefaultExternalDirsSet : true ,
330+ DefaultExternalDirs : defaultExternalFactDirs (),
331+ IncludeTypedDotted : mergeDottedFacts ,
332+ Logger : logger ,
318333 })
319334 if err != nil {
320335 return err
@@ -324,17 +339,6 @@ func runQuery(stdout, stderr io.Writer, args []string) error {
324339 return err
325340 }
326341 facts := snapshot .Facts ()
327- mergeDottedFacts := configOptions .ForceDotResolution || * forceDotResolution
328- projection := engine .NewProjection (facts , mergeDottedFacts )
329- facts = projection .Select (flags .Args ())
330- if ! * noCache {
331- cache := engine .NewFactCache (engine .DefaultCachePath (), configOptions .TTLs , configOptions .FactGroups , logger )
332- remaining , cached := cache .ResolveFacts (facts )
333- if err := cache .CacheFacts (remaining ); err != nil {
334- return err
335- }
336- facts = append (remaining , cached ... )
337- }
338342 resolutionDuration := time .Since (resolutionStart ).Seconds ()
339343 out , err := engine .BuildFormatter (engine.FormatOptions {
340344 JSON : * jsonOutput || * jsonOutputShort ,
0 commit comments