grim/hgkeeper

auto reload the access model and policy if the admin repo is accessed. This does both push and pulls right now.
package serve
import (
"bitbucket.org/rw_grim/hgkeeper/access"
"bitbucket.org/rw_grim/hgkeeper/globals"
"bitbucket.org/rw_grim/hgkeeper/ssh"
)
type Command struct {
SSHAddr string `kong:"flag,name='ssh-listen-addr',env='HGK_SSH_LISTEN_ADDR',short='l',help='what address to listen on',default=':22222'"`
SSHHostKeysPath string `kong:"flag,name='ssh-host-keys-path',env='HGK_SSH_HOST_KEYS_PATH',short='H',help='the path where host keys are kept',default='host-keys'"`
}
func (c *Command) Run(g *globals.Globals) error {
if err := access.Setup(g.ReposPath, g.AdminRepo); err != nil {
return err
}
s, err := ssh.NewServer(c.SSHHostKeysPath, g.ReposPath, access.AdminRepoPath())
if err != nil {
return err
}
err = s.Listen(c.SSHAddr)
if err != nil {
return err
}
return nil
}