grim/hgkeeper
Clone
Summary
Browse
Changes
Graph
Add support for specifying which mercurial executable to use
14 months ago, Gary Kramlich
8275959b76f0
Add support for specifying which mercurial executable to use
package
access
import
(
"path/filepath"
"sync"
"github.com/casbin/casbin/v2"
log
"github.com/sirupsen/logrus"
)
var
(
enforcer
*
casbin
.
Enforcer
enforcerLock
sync
.
Mutex
)
func
refreshEnforcer
()
error
{
enforcerLock
.
Lock
()
defer
enforcerLock
.
Unlock
()
modelFile
:=
filepath
.
Join
(
AdminRepoPath
(),
modelFilename
)
policyFile
:=
filepath
.
Join
(
AdminRepoPath
(),
policyFilename
)
log
.
Debugf
(
"reading model from %q"
,
modelFile
)
log
.
Debugf
(
"reading policy from %q"
,
policyFile
)
e
,
err
:=
casbin
.
NewEnforcer
(
modelFile
,
policyFile
)
if
err
!=
nil
{
log
.
Errorf
(
"failed to create new enforcer: %v"
,
err
)
return
err
}
enforcer
=
e
return
nil
}