Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Respect inlined schemas annotations even if --schema flag isn't used #5506

Closed
johanfylling opened this issue Dec 23, 2022 · 0 comments · Fixed by #5689
Closed

Respect inlined schemas annotations even if --schema flag isn't used #5506

johanfylling opened this issue Dec 23, 2022 · 0 comments · Fixed by #5689

Comments

@johanfylling
Copy link
Contributor

The schemas annotation supports inlined schema definitions (undocumented).

# METADATA
# scope: package
# schemas:
#   - input: {"type": "boolean"}
package main

Currently, the schemas annotation only affect type checking if the --schema flag is passed to the eval- and check commands. Considering the --schema requires you to supply a file or directory, its use is redundant and confusing when only inlined schemas are used.

Currently, annotation parsing is only triggered when the --schema flag is used, or if a rego.metadata.* function is called within the policy. Consider introducing a new flag for enabling use of inlined schemas, to make it possible to opt-out of unwanted annotation parsing.

Note: This functionality has limited use while inlined schemas remain undocumented.

@srenatus srenatus changed the title Respect inlinet schemas annotations even if --shema flag isn't used Respect inlined schemas annotations even if --schema flag isn't used Jan 2, 2023
@ashutosh-narkar ashutosh-narkar added this to Backlog in Open Policy Agent via automation Jan 11, 2023
@ashutosh-narkar ashutosh-narkar moved this from Backlog to Planned - v0.49 in Open Policy Agent Jan 11, 2023
@johanfylling johanfylling moved this from Planned - v0.50 to In Progress in Open Policy Agent Feb 16, 2023
johanfylling added a commit to johanfylling/opa that referenced this issue Feb 23, 2023
Always parse annotations.
Always use `schemas` annotations with inlined schemas for type checking.
Ignore `schemas` annotations with schema refs if no `--schema` flag was provided.

Enabled for commands:
* eval
* check
* test

Fixes: open-policy-agent#5506

Signed-off-by: Johan Fylling <johan.dev@fylling.se>
johanfylling added a commit to johanfylling/opa that referenced this issue Feb 24, 2023
Always parse annotations.
Always use `schemas` annotations with inlined schemas for type checking.
Ignore `schemas` annotations with schema refs if no `--schema` flag was provided.

Enabled for commands:
* eval
* check
* test

Fixes: open-policy-agent#5506

Signed-off-by: Johan Fylling <johan.dev@fylling.se>
Open Policy Agent automation moved this from In Progress to Done Feb 28, 2023
johanfylling added a commit that referenced this issue Feb 28, 2023
* ast: Enforce inlined schemas without --schemas flag

Enabled for commands:
* eval
* check
* test

Always parse annotations.
Always use `schemas` annotations with inlined schemas for type checking.
Ignore `schemas` annotations with schema refs if no `--schema` flag was provided.

Fixes: #5506

Signed-off-by: Johan Fylling <johan.dev@fylling.se>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging a pull request may close this issue.

1 participant