diff options
| -rw-r--r-- | cmd/main.go | 30 | ||||
| -rw-r--r-- | gitserver.yaml | 1 | ||||
| -rw-r--r-- | internal/admin/middleware.go | 4 | ||||
| -rw-r--r-- | internal/admin/model.go | 4 | ||||
| -rw-r--r-- | internal/admin/service.go | 1 |
5 files changed, 24 insertions, 16 deletions
diff --git a/cmd/main.go b/cmd/main.go index a0f007b..38c3724 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -13,20 +13,19 @@ import ( ) var ( - reposDir = *flag.String("r", "./repos", "Directory containing git repositories") - mgmtRepo = *flag.Bool("a", true, "mgmt repo used for configuration") - backendCommand = *flag.String("c", "git http-backend", "CGI binary to execute") - addr = *flag.String("l", ":8080", "Address/port to listen on") - modelPath = *flag.String("m", "./auth_model.ini", "Authentication model") - policyPath = *flag.String("p", "./policy.csv", "auth policy") - serverConfigPath = *flag.String("s", "/gitserver.yaml", "serverconfig path") - newToken = *flag.Bool("t", false, "make a new token") - // TODO what was my intent here? - // updatePolicies = flag.Bool("u", false, "update policies") + reposDir string + mgmtRepo bool + backendCommand string + addr string + modelPath string + policyPath string + serverConfigPath string + newToken bool ) func main() { flag.Parse() + print(reposDir) if newToken { token, hash, err := authz.GenerateNewToken() if err != nil { @@ -55,3 +54,14 @@ func main() { } log.Fatal(server.ListenAndServe()) } + +func init() { + flag.StringVar(&backendCommand, "c", "git http-backend", "CGI binary to execute") + flag.StringVar(&addr, "l", ":8080", "Address/port to listen on") + flag.StringVar(&modelPath, "m", "./auth_model.ini", "Authentication model") + flag.StringVar(&policyPath, "p", "./policy.csv", "auth policy") + flag.StringVar(&serverConfigPath, "s", "/gitserver.yaml", "serverconfig path") + flag.StringVar(&reposDir, "r", "./repos", "Directory containing git repositories") + flag.BoolVar(&mgmtRepo, "a", false, "mgmt repo used for configuration") + flag.BoolVar(&newToken, "t", false, "make a new token") +} diff --git a/gitserver.yaml b/gitserver.yaml index 2a2c828..5640200 100644 --- a/gitserver.yaml +++ b/gitserver.yaml @@ -1,7 +1,6 @@ --- name: "go-git-server" version: "v1alpha1" -basepath: ./repos repos: - name: mgmt public: false diff --git a/internal/admin/middleware.go b/internal/admin/middleware.go index 60274ad..8b88c83 100644 --- a/internal/admin/middleware.go +++ b/internal/admin/middleware.go @@ -1,15 +1,13 @@ package admin import ( - "log" "net/http" ) // Hooks middleware to handle requests to the admin repo. func Hooks(adminSvc *Servicer, next http.Handler) http.Handler { return http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) { - log.Printf("stuffs about to reload %s", "now") - next.ServeHTTP(rw, req) go adminSvc.Reload() + next.ServeHTTP(rw, req) }) } diff --git a/internal/admin/model.go b/internal/admin/model.go index 2841e0a..bf97b0f 100644 --- a/internal/admin/model.go +++ b/internal/admin/model.go @@ -66,7 +66,7 @@ type ServerRepos struct { Name string `json:"name"` Version string `json:"version"` Repos []*GitRepo `json:"repos"` - BasePath string `json:"basepath"` + basePath string } func loadFromGit(gitURL, filePath string) ([]byte, error) { @@ -146,7 +146,7 @@ func (s *ServerRepos) ServerPolicies() [][]string { // ConfigureRepos run reconciler for all repos func (s *ServerRepos) ConfigureRepos() { for _, repo := range s.Repos { - repo.ReconcileRepo(s.BasePath) + repo.ReconcileRepo(s.basePath) } } diff --git a/internal/admin/service.go b/internal/admin/service.go index 1b5662d..498215b 100644 --- a/internal/admin/service.go +++ b/internal/admin/service.go @@ -69,6 +69,7 @@ func NewService(modelPath, policyPath, serverConfigPath, reposDir string, mgmtRe // log.error log.Fatalf("Coudln't load server config %s", err) } + conf.basePath = reposDir svc := &Servicer{ enf, conf, |