NewServer configures a new gitdir server and attempts to load the config from the admin repo.
(fs billy.Filesystem)
| 30 | // NewServer configures a new gitdir server and attempts to load the config |
| 31 | // from the admin repo. |
| 32 | func NewServer(fs billy.Filesystem) (*Server, error) { |
| 33 | serv := &Server{ |
| 34 | lock: &sync.RWMutex{}, |
| 35 | log: log.Logger, |
| 36 | fs: fs, |
| 37 | } |
| 38 | |
| 39 | serv.ssh = &ssh.Server{ |
| 40 | Handler: serv.handleSession, |
| 41 | PublicKeyHandler: serv.handlePublicKey, |
| 42 | } |
| 43 | |
| 44 | // This will set serv.settings |
| 45 | if err := serv.Reload(); err != nil { |
| 46 | return nil, err |
| 47 | } |
| 48 | |
| 49 | return serv, nil |
| 50 | } |
| 51 | |
| 52 | func (serv *Server) EnsureAdminUser(username string, pubKey *models.PublicKey) error { |
| 53 | serv.lock.Lock() |