ability to update a repo's public / private key via the REST API

This commit is contained in:
Brad Rydzewski 2014-09-06 12:45:27 -07:00
parent 617476784d
commit 96e660381f

View file

@ -170,6 +170,8 @@ func (h *RepoHandler) PutRepo(w http.ResponseWriter, r *http.Request) error {
Privileged *bool `json:"privileged"`
Params *string `json:"params"`
Timeout *int64 `json:"timeout"`
PublicKey *string `json:"public_key"`
PrivateKey *string `json:"private_key"`
}{}
if err := json.NewDecoder(r.Body).Decode(&in); err != nil {
return badRequest{err}
@ -197,6 +199,10 @@ func (h *RepoHandler) PutRepo(w http.ResponseWriter, r *http.Request) error {
if in.Timeout != nil && user.Admin {
repo.Timeout = *in.Timeout
}
if in.PrivateKey != nil && in.PublicKey != nil {
repo.PublicKey = *in.PublicKey
repo.PrivateKey = *in.PrivateKey
}
// update the repository
if err := h.repos.Update(repo); err != nil {