Skip to content

Commit

Permalink
bundle: Add support for .yml files in opa bundle command (#4882)
Browse files Browse the repository at this point in the history
This commit adds support for .yml files.

Fixes #4859.

Signed-off-by: Joffref <mariusjoffre@gmail.com>
  • Loading branch information
Joffref committed Jul 13, 2022
1 parent 0d69458 commit aa487ed
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 2 additions & 1 deletion bundle/bundle.go
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 {
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
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

0 comments on commit aa487ed

Please sign in to comment.