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

Add support for .yml files in opa bundle command #4882

Merged
merged 2 commits into from
Jul 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion bundle/bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const (
patchFile = "patch.json"
dataFile = "data.json"
yamlDataFile = "data.yaml"
ymlDataFile = "data.yml"
defaultHashingAlg = "SHA-256"
DefaultSizeLimitBytes = (1024 * 1024 * 1024) // limit bundle reads to 1GB to protect against gzip bombs
DeltaBundleType = "delta"
Expand Down Expand Up @@ -555,7 +556,7 @@ func (r *Reader) Read() (Bundle, error) {
return bundle, err
}

} else if filepath.Base(path) == yamlDataFile {
} else if filepath.Base(path) == yamlDataFile || filepath.Base(path) == ymlDataFile {
philipaconrad marked this conversation as resolved.
Show resolved Hide resolved
if r.lazyLoadingMode {
raw = append(raw, Raw{Path: path, Value: buf.Bytes()})
continue
Expand Down
2 changes: 2 additions & 0 deletions bundle/bundle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ func testReadBundle(t *testing.T, baseDir string) {
{"/a/b/c/data.json", "[1,2,3]"},
{"/a/b/d/data.json", "true"},
{"/a/b/y/data.yaml", `foo: 1`},
{"/a/b/g/data.yml", "1"},
{"/example/example.rego", `package example`},
{"/policy.wasm", `legacy-wasm-module`},
{wasmResolverPath, `wasm-module`},
Expand Down Expand Up @@ -218,6 +219,7 @@ func testReadBundle(t *testing.T, baseDir string) {
"b": map[string]interface{}{
"c": []interface{}{json.Number("1"), json.Number("2"), json.Number("3")},
"d": true,
"g": json.Number("1"),
"y": map[string]interface{}{
"foo": json.Number("1"),
},
Expand Down