Skip to content
Snippets Groups Projects
Commit a60dcd25 authored by Yordan Kinkov's avatar Yordan Kinkov
Browse files

#32 add proper filename during sync

parent f80a6be7
No related branches found
No related tags found
1 merge request!33Add proper filename during sync
Pipeline #52770 passed with stages
in 1 minute and 49 seconds
......@@ -161,10 +161,9 @@ func createPolicy(p string, d os.DirEntry) (*Policy, error) {
return nil, fmt.Errorf("failed to get policy filename, name, version and group out of policy path: %s", p)
}
filename := ss[len(ss)-1] // last element in the array is filename
version := ss[len(ss)-2] // second last element is the version
name := ss[len(ss)-3] // third last element is the policy name
group := ss[len(ss)-4] // fourth last element is the policy group
version := ss[len(ss)-2] // second last element is the version
name := ss[len(ss)-3] // third last element is the policy name
group := ss[len(ss)-4] // fourth last element is the policy group
bytes, err := os.ReadFile(p)
if err != nil {
return nil, err
......@@ -178,8 +177,11 @@ func createPolicy(p string, d os.DirEntry) (*Policy, error) {
}
data := string(dataBytes)
// generate filename for DB from pattern {group}/{name}/{version}/policy.rego
dbFilename := group + "/" + name + "/" + version + "/" + policyFilename
return &Policy{
Filename: filename,
Filename: dbFilename,
Name: name,
Group: group,
Version: version,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment