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

Bundle does not "bundle" data if file extension is .yml #4859

Closed
rdrgmnzs opened this issue Jul 7, 2022 · 6 comments
Closed

Bundle does not "bundle" data if file extension is .yml #4859

rdrgmnzs opened this issue Jul 7, 2022 · 6 comments

Comments

@rdrgmnzs
Copy link

rdrgmnzs commented Jul 7, 2022

Short description

When using opa bundle to bundle a rego and data, if the data file has a .yml extension the data is not packaged into the bundle, the generated bundle containing a data.json file with content {}. However if I rename the file to have a .yaml extension instead and run the same bundle command, the generated bundle has a data.json file with the correct data.

OPA version:

Version: 0.41.0
Build Commit: 0d6a109
Build Timestamp: 2022-06-02T17:46:28Z
Build Hostname: Mac-1654191418209.local
Go Version: go1.18.2
Platform: darwin/amd64
WebAssembly: available

Steps To Reproduce


Produces empty data.json

  1. Utilizing the command:
    opa build --debug --bundle rbac --output ~/bundle.tar
  2. With folder structure & file extension of yml.
rbac
├── data
│   └── data.yml
└── policy
    ├── my.rego
    └── my_test.rego

Produces data.json with the desired data

  1. Utilizing the command:
    opa build --debug --bundle rbac --output ~/bundle.tar
  2. With folder structure & file extension of yaml.
rbac
├── data
│   └── data.yaml
└── policy
    ├── my.rego
    └── my_test.rego

Expected behavior

That both .yaml and .yml files with the same content would generate the same data.json file in the bundle .

@rdrgmnzs rdrgmnzs added the bug label Jul 7, 2022
@srenatus
Copy link
Contributor

srenatus commented Jul 7, 2022

Reasonable request. Would be up to giving this a try? Figuring out where the extension is taken into account and what needs to be changed for that?

@levenleven
Copy link

Which one would take precedence if there're both data.yaml and data.yml?

@rdrgmnzs
Copy link
Author

@levenleven I'd imagine .yaml would take precedence to not break backward compatibility and potentially affect someone that is unaware of the change.

@srenatus
Copy link
Contributor

@rdrgmnzs @levenleven 👍 that sounds reasonable. I'd be surprised if anyone had both data.yaml and data.yml right now, but still, let's play it safe.

@anderseknert
Copy link
Member

Hmm, while it's a rather academic issue really, I would not expect there to be a precedence for one over the other - you can have a data.json and a data.yaml in the same directory already, and both will be merged. If there are conflicting attributes those will fail the build anyway, so I'd just merge a data.yml file as any of the other two.

@srenatus
Copy link
Contributor

have a data.json and a data.yaml in the same directory already, and both will be merged

Oh! I had assumed that it would be an error or some precedence rule. But if they're merged, let's merge yaml and yml, too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants