added logging to page when adding / removing repos
This commit is contained in:
parent
3642c903c5
commit
27557988f8
1 changed files with 5 additions and 5 deletions
|
@ -91,7 +91,7 @@ func PostRepo(c web.C, w http.ResponseWriter, r *http.Request) {
|
||||||
if len(repo.PublicKey) == 0 || len(repo.PrivateKey) == 0 {
|
if len(repo.PublicKey) == 0 || len(repo.PrivateKey) == 0 {
|
||||||
key, err := sshutil.GeneratePrivateKey()
|
key, err := sshutil.GeneratePrivateKey()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
repo.PublicKey = sshutil.MarshalPublicKey(&key.PublicKey)
|
repo.PublicKey = sshutil.MarshalPublicKey(&key.PublicKey)
|
||||||
|
@ -108,12 +108,12 @@ func PostRepo(c web.C, w http.ResponseWriter, r *http.Request) {
|
||||||
// if necessary, register the public key
|
// if necessary, register the public key
|
||||||
var hook = fmt.Sprintf("%s/api/hook/%s/%s", httputil.GetURL(r), repo.Remote, repo.Token)
|
var hook = fmt.Sprintf("%s/api/hook/%s/%s", httputil.GetURL(r), repo.Remote, repo.Token)
|
||||||
if err := remote.Activate(user, repo, hook); err != nil {
|
if err := remote.Activate(user, repo, hook); err != nil {
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := datastore.PutRepo(ctx, repo); err != nil {
|
if err := datastore.PutRepo(ctx, repo); err != nil {
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
w.WriteHeader(http.StatusCreated)
|
w.WriteHeader(http.StatusCreated)
|
||||||
|
@ -143,7 +143,7 @@ func PutRepo(c web.C, w http.ResponseWriter, r *http.Request) {
|
||||||
PrivateKey *string `json:"private_key"`
|
PrivateKey *string `json:"private_key"`
|
||||||
}{}
|
}{}
|
||||||
if err := json.NewDecoder(r.Body).Decode(&in); err != nil {
|
if err := json.NewDecoder(r.Body).Decode(&in); err != nil {
|
||||||
w.WriteHeader(http.StatusBadRequest)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -167,7 +167,7 @@ func PutRepo(c web.C, w http.ResponseWriter, r *http.Request) {
|
||||||
repo.PrivateKey = *in.PrivateKey
|
repo.PrivateKey = *in.PrivateKey
|
||||||
}
|
}
|
||||||
if err := datastore.PutRepo(ctx, repo); err != nil {
|
if err := datastore.PutRepo(ctx, repo); err != nil {
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
json.NewEncoder(w).Encode(repo)
|
json.NewEncoder(w).Encode(repo)
|
||||||
|
|
Loading…
Reference in a new issue