func addChartRepoHandlerFunc(w http.ResponseWriter, r *http.Request, c *router.Context) error { handler := "manager: add chart repository" util.LogHandlerEntry(handler, r) defer r.Body.Close() cr := &repo.Repo{} if err := httputil.Decode(w, r, cr); err != nil { httputil.BadRequest(w, r, err) return nil } if string(cr.Format) == "" { cr.Format = repo.GCSRepoFormat } if string(cr.Type) == "" { cr.Type = repo.GCSRepoType } if err := c.Manager.AddRepo(cr); err != nil { httputil.BadRequest(w, r, err) return nil } msg, _ := json.Marshal(cr.Name + " has been added to the list of chart repositories.") util.LogHandlerExitWithJSON(handler, w, msg, http.StatusCreated) return nil }
func getCredential(w http.ResponseWriter, r *http.Request, handler string) *repo.Credential { util.LogHandlerEntry(handler, r) t := &repo.Credential{} if err := httputil.Decode(w, r, t); err != nil { httputil.BadRequest(w, r, err) return nil } return t }
func getDeploymentRequest(w http.ResponseWriter, r *http.Request, handler string) *common.DeploymentRequest { util.LogHandlerEntry(handler, r) depReq := &common.DeploymentRequest{} if err := httputil.Decode(w, r, depReq); err != nil { httputil.BadRequest(w, r, err) return nil } return depReq }