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:
+2
-2
@@ -51,7 +51,7 @@ func TestDoInspect(t *testing.T) {
|
||||
res := `{
|
||||
"manifest": {"revision": "rev", "roots": ["foo", "bar", "fuz", "baz", "a", "x"]},
|
||||
"signatures_config": {},
|
||||
"namespaces": {"": ["/data.json"], "data.foo": ["/example/foo.rego"]}
|
||||
"namespaces": {"data": ["/data.json"], "data.foo": ["/example/foo.rego"]}
|
||||
}`
|
||||
|
||||
exp := util.MustUnmarshalJSON([]byte(res))
|
||||
@@ -131,7 +131,7 @@ NAMESPACES:
|
||||
+-----------------------------+----------------------------------------------------+
|
||||
| NAMESPACE | FILE |
|
||||
+-----------------------------+----------------------------------------------------+
|
||||
| | /data.json |
|
||||
| data | /data.json |
|
||||
| data.a.b.y | /a/b/y/foo.rego |
|
||||
| | /a/...xxxxxxxxxxxxxx/yyyyyyyyyyyyyyyyyyyy/foo.rego |
|
||||
| data.foo | /example/foo.rego |
|
||||
|
||||
@@ -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