Commit 23753bbc authored by Tulir Asokan's avatar Tulir Asokan 🐈

Move copying ssh keys to after logging create request

parent 75516d14
Pipeline #56 passed with stages
in 1 minute and 12 seconds
......@@ -77,30 +77,32 @@ func createMirror(w http.ResponseWriter, r *http.Request) {
} else if err = json.Unmarshal(data, &req); err != nil {
respondErr(w, r, err, http.StatusBadRequest)
return
} else if req.Repo.PushKey, err = writeKey(req.PushKey, req.Repo.PushKey, req.Name); err != nil {
respondErr(w, r, err, http.StatusInternalServerError)
return
} else if req.Repo.PullKey, err = writeKey(req.PullKey, req.Repo.PullKey, req.Name); err != nil {
respondErr(w, r, err, http.StatusInternalServerError)
return
}
log.Debugln("Create mirror request from %s: %s to %s", readUserIP(r), req.Name, req.Repo.Target)
repo := &req.Repo
repo.Name = req.Name
repo.Log = log.Sub(repo.Name)
log.Debugln("Create mirror request from %s: %s to %s", readUserIP(r), repo.Name, repo.Target)
log.Infoln("Adding", repo.Name, "with push target", repo.Target, "to repos")
config.Repositories[req.Name] = repo
config.Repositories[repo.Name] = repo
var err error
if req.GitHubToken != "" {
var err error
repo.Secret, err = CreateWebhook(req.GitHubToken, req.Name, repo.Secret)
repo.Secret, err = CreateWebhook(req.GitHubToken, repo.Name, repo.Secret)
if err != nil {
respondErr(w, r, err, http.StatusInternalServerError)
return
}
}
if repo.PushKey, err = writeKey(req.PushKey, repo.PushKey, repo.Name); err != nil {
respondErr(w, r, err, http.StatusInternalServerError)
return
} else if repo.PullKey, err = writeKey(req.PullKey, repo.PullKey, repo.Name); err != nil {
respondErr(w, r, err, http.StatusInternalServerError)
return
}
log.Debugln("Saving config...")
saveConfig()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment