grim/hgkeeper

Parents 6837cd82348c
Children 383331e5a4fb
Rework the way we setup the access code a little bit so it's easier to refresh
--- a/access/access.go Thu Sep 12 00:14:32 2019 -0500
+++ b/access/access.go Thu Sep 12 02:31:11 2019 -0500
@@ -10,13 +10,20 @@
)
var (
- accessLock sync.Mutex
+ accessLock sync.Mutex
+ adminRepoPath string
)
+func Setup(adminRepo string) error {
+ adminRepoPath = adminRepo
+
+ return Refresh()
+}
+
// Refresh will try to reload the casbin model and policies followed by SSH
// keys. If there is an error it's possible that the casbin model and polcies
// could have been updated but the ssh keys were not.
-func Refresh(adminRepoPath string) error {
+func Refresh() error {
accessLock.Lock()
defer accessLock.Unlock()
--- a/serve/command.go Thu Sep 12 00:14:32 2019 -0500
+++ b/serve/command.go Thu Sep 12 02:31:11 2019 -0500
@@ -15,7 +15,7 @@
func (c *Command) Run(g *globals.Globals) error {
adminRepoPath := filepath.Join(g.ReposPath, g.AdminRepo)
- if err := access.Refresh(adminRepoPath); err != nil {
+ if err := access.Setup(adminRepoPath); err != nil {
return err
}