@@ -283,9 +283,6 @@ This group of commands allows the management of polices to be verified against b
283283 if policyPath == "" && ownerID == "" {
284284 return fmt .Errorf ("either [policy_file_or_dir_path] or --owner-id is required" )
285285 }
286- if ! noCompile && ownerID == "" {
287- return fmt .Errorf ("--owner-id is required for compiling config (use --no-compile to evaluate policy against source config only)" )
288- }
289286
290287 metadata , err := readMetadata (meta , metaFile )
291288 if err != nil {
@@ -297,7 +294,7 @@ This group of commands allows the management of polices to be verified against b
297294 return fmt .Errorf ("failed to read input file: %w" , err )
298295 }
299296
300- if ! noCompile {
297+ if ! noCompile && context == "config" {
301298 compiler := config .New (globalConfig )
302299 input , err = mergeCompiledConfig (compiler , config.ProcessConfigOpts {
303300 ConfigPath : inputPath ,
@@ -356,6 +353,7 @@ This group of commands allows the management of polices to be verified against b
356353 inputPath string
357354 meta string
358355 metaFile string
356+ context string
359357 ownerID string
360358 query string
361359 noCompile bool
@@ -367,10 +365,6 @@ This group of commands allows the management of polices to be verified against b
367365 RunE : func (cmd * cobra.Command , args []string ) error {
368366 policyPath := args [0 ]
369367
370- if ! noCompile && ownerID == "" {
371- return fmt .Errorf ("--owner-id is required for compiling config (use --no-compile to evaluate policy against source config only)" )
372- }
373-
374368 metadata , err := readMetadata (meta , metaFile )
375369 if err != nil {
376370 return fmt .Errorf ("failed to read metadata: %w" , err )
@@ -381,7 +375,7 @@ This group of commands allows the management of polices to be verified against b
381375 return fmt .Errorf ("failed to read input file: %w" , err )
382376 }
383377
384- if ! noCompile {
378+ if ! noCompile && context == "config" {
385379 compiler := config .New (globalConfig )
386380 input , err = mergeCompiledConfig (compiler , config.ProcessConfigOpts {
387381 ConfigPath : inputPath ,
@@ -410,6 +404,7 @@ This group of commands allows the management of polices to be verified against b
410404
411405 cmd .Flags ().StringVar (& ownerID , "owner-id" , "" , "the id of the policy's owner" )
412406 cmd .Flags ().StringVar (& inputPath , "input" , "" , "path to input file" )
407+ cmd .Flags ().StringVar (& context , "context" , "config" , "policy context for decision" )
413408 cmd .Flags ().StringVar (& meta , "meta" , "" , "decision metadata (json string)" )
414409 cmd .Flags ().StringVar (& metaFile , "metafile" , "" , "decision metadata file" )
415410 cmd .Flags ().StringVar (& query , "query" , "data" , "policy decision query" )
0 commit comments