Example #1
0
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
}
Example #2
0
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
}
Example #3
0
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
}