Skip to content

Commit

Permalink
Only mount policies root is path exists (#430)
Browse files Browse the repository at this point in the history
  • Loading branch information
carabasdaniel committed Jul 23, 2024
1 parent 13fa62f commit ac92246
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 5 additions & 2 deletions pkg/cli/cmd/topaz/startrun.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,11 @@ func getVolumes(cfg *config.Loader) ([]string, error) {
})

volumes := []string{
fmt.Sprintf("%s:/config:ro", cc.GetTopazCfgDir()), // manually attach the configuration folder
fmt.Sprintf("%s:/root/.policy:ro", dockerx.PolicyRoot()), // manually attache policy store
fmt.Sprintf("%s:/config:ro", cc.GetTopazCfgDir()), // manually attach the configuration folder
}

if cfg.Configuration.OPA.LocalBundles.LocalPolicyImage != "" && dockerx.PolicyRoot() != "" {
volumes = append(volumes, fmt.Sprintf("%s:/root/.policy:ro", dockerx.PolicyRoot())) // manually attach policy store
}

for _, v := range volumeMap {
Expand Down
7 changes: 5 additions & 2 deletions pkg/cli/dockerx/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,12 @@ func PolicyRoot() string {
return ""
}

return path.Join(home, defaultPolicyRoot)
policyRoot = path.Join(home, defaultPolicyRoot)
}
return policyRoot
if fi, err := os.Stat(policyRoot); err == nil && fi.IsDir() {
return policyRoot
}
return ""
}

type DockerClient struct {
Expand Down

0 comments on commit ac92246

Please sign in to comment.