Skip to content

Commit

Permalink
The [opa eval] command is unable to access Rego policies located on o…
Browse files Browse the repository at this point in the history
…ther drives in Windows. For more details, see open-policy-agent#6910 and open-policy-agent/conftest#979.

OPA should be capable of accessing Rego policies from specified paths including drives (e.g., c:\a\b\c.rego).

The code has been updated to allow OPA to load Rego policies from paths with drives. Now, OPA can load Rego policies from paths, URLs, and drives.

Fixes open-policy-agent#6910

Signed-off-by: pckvcode <[email protected]>
  • Loading branch information
pckvcode committed Aug 12, 2024
1 parent 71faf61 commit 3a9a702
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion loader/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ func SplitPrefix(path string) ([]string, string) {
return nil, path
}
parts := strings.SplitN(path, ":", 2)
if len(parts) == 2 && len(parts[0]) > 0 {
if len(parts) == 2 && len(parts[0]) > 1 {
return strings.Split(parts[0], "."), parts[1]
}
return nil, path
Expand Down
4 changes: 4 additions & 0 deletions loader/loader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -823,6 +823,10 @@ func TestSplitPrefix(t *testing.T) {
wantParts: []string{"x", "y"},
wantPath: "file:///c:/a/b/c",
},
{
input: "c:/a/b/c",
wantPath: "c:/a/b/c",
},
}

for _, tc := range tests {
Expand Down

0 comments on commit 3a9a702

Please sign in to comment.