mirror of
https://github.com/open-policy-agent/opa.git
synced 2026-08-12 19:32:48 -06:00
cmd/inspect: Add namespace for data file at root
Earlier we used an empty namespace for data file located at bundle root. This change now uses "data" as the namespace for a data file at root. Fixes: #4022 Signed-off-by: Ashutosh Narkar <anarkar4387@gmail.com>
This commit is contained in:
@@ -126,7 +126,7 @@ func (bi *Info) getBundleDataWasmAndSignatures(name string) error {
|
||||
path := fmt.Sprintf("%v.%v", ast.DefaultRootDocument, strings.Join(key, "."))
|
||||
bi.Namespaces[path] = append(bi.Namespaces[path], value)
|
||||
} else {
|
||||
bi.Namespaces[""] = append(bi.Namespaces[""], value) // data file at bundle root
|
||||
bi.Namespaces[ast.DefaultRootDocument.String()] = append(bi.Namespaces[ast.DefaultRootDocument.String()], value) // data file at bundle root
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ func TestGenerateBundleInfoWithFileDir(t *testing.T) {
|
||||
}
|
||||
|
||||
expectedNamespaces := map[string][]string{
|
||||
"": {filepath.Join(rootDir, "data.json")},
|
||||
"data": {filepath.Join(rootDir, "data.json")},
|
||||
"data.bar": {filepath.Join(rootDir, "base.rego")},
|
||||
"data.foo": {filepath.Join(rootDir, "baz/authz.rego"), filepath.Join(rootDir, "foo/policy.rego")},
|
||||
"data.fuz": {filepath.Join(rootDir, "fuz/fuz.rego"), filepath.Join(rootDir, "fuz/data.json")},
|
||||
@@ -114,7 +114,7 @@ func TestGenerateBundleInfoWithFile(t *testing.T) {
|
||||
}
|
||||
|
||||
expectedNamespaces := map[string][]string{
|
||||
"": {"/data.json"},
|
||||
"data": {"/data.json"},
|
||||
"data.b.c": {"/policy.rego"},
|
||||
}
|
||||
|
||||
@@ -181,7 +181,7 @@ func TestGenerateBundleInfoWithBundleTarGz(t *testing.T) {
|
||||
|
||||
expectedNamespaces := map[string][]string{
|
||||
"data.example": {"/example/example.rego"},
|
||||
"": {"/data.json"},
|
||||
"data": {"/data.json"},
|
||||
"data.a.b.c": {"/a/b/c/data.json"},
|
||||
"data.a.b.d": {"/a/b/d/data.json"},
|
||||
"data.a.b.y": {"/a/b/y/foo.rego", "/a/b/y/data.yaml"},
|
||||
|
||||
Reference in New Issue
Block a user