Skip to content

cmd: add --data flag to opa inspect for data file inspection#8608

Open
madmecodes wants to merge 1 commit into
open-policy-agent:mainfrom
madmecodes:feat/inspect-data-flag
Open

cmd: add --data flag to opa inspect for data file inspection#8608
madmecodes wants to merge 1 commit into
open-policy-agent:mainfrom
madmecodes:feat/inspect-data-flag

Conversation

@madmecodes
Copy link
Copy Markdown

Summary

Fixes #6879

Changes

  • cmd/inspect.go: Added dataPaths field to params, wired up --data flag, updated validation to support either positional args or --data (not both), updated command help text
  • internal/bundle/inspect/inspect.go: Added DataFileInfo() function that validates and inspects JSON/YAML data files, mapping them to the data namespace
  • cmd/inspect_test.go: Added tests for JSON inspection, YAML inspection, invalid JSON handling, non-data file rejection, and mutual exclusivity of --data with positional args

Usage

# Inspect a single JSON data file
opa inspect --data data.json

# Inspect a YAML data file
opa inspect --data config.yaml

# Inspect multiple data files
opa inspect --data data.json --data config.yaml

Test plan

  • All 81 existing inspect tests pass
  • All 4 existing inspect package tests pass
  • 5 new tests added and passing
  • CI validation

Fixes open-policy-agent#6879

Signed-off-by: madmecodes <ayushguptadev1@gmail.com>
@madmecodes madmecodes force-pushed the feat/inspect-data-flag branch from 4e6b0d3 to 0c803ee Compare May 8, 2026 08:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow opa inspect to inspect single data files

1 participant