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:
Ashutosh Narkar
2021-11-22 15:30:21 -08:00
parent 95c25b4b4e
commit ec62838bb2
3 changed files with 6 additions and 6 deletions
+1 -1
View File
@@ -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
}
}
+3 -3
View File
@@ -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"},