本文整理汇总了Golang中github.com/kubernetes/helm/pkg/util.LogHandlerEntry函数的典型用法代码示例。如果您正苦于以下问题:Golang LogHandlerEntry函数的具体用法?Golang LogHandlerEntry怎么用?Golang LogHandlerEntry使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了LogHandlerEntry函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: addChartRepoHandlerFunc
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
}
示例2: expanderSuccessHandler
func expanderSuccessHandler(w http.ResponseWriter, r *http.Request) {
handler := "expandybird: expand"
util.LogHandlerEntry(handler, r)
defer r.Body.Close()
body, err := ioutil.ReadAll(r.Body)
if err != nil {
status := fmt.Sprintf("cannot read request body:%s", err)
http.Error(w, status, http.StatusInternalServerError)
return
}
svcReq := &expansion.ServiceRequest{}
if err := json.Unmarshal(body, svcReq); err != nil {
status := fmt.Sprintf("cannot unmarshal request body:%s\n%s\n", err, body)
http.Error(w, status, http.StatusInternalServerError)
return
}
/*
if !reflect.DeepEqual(validRequestTestCaseData, *svcReq) {
status := fmt.Sprintf("error in http handler:\nwant:%s\nhave:%s\n",
util.ToJSONOrError(validRequestTestCaseData), util.ToJSONOrError(template))
http.Error(w, status, http.StatusInternalServerError)
return
}
*/
svcResp := getValidServiceResponse()
util.LogHandlerExitWithJSON(handler, w, svcResp, http.StatusOK)
}
示例3: listRepoChartsHandlerFunc
func listRepoChartsHandlerFunc(w http.ResponseWriter, r *http.Request, c *router.Context) error {
handler := "manager: list repository charts"
util.LogHandlerEntry(handler, r)
repoURL, err := pos(w, r, 2)
if err != nil {
return err
}
values, err := url.ParseQuery(r.URL.RawQuery)
if err != nil {
httputil.BadRequest(w, r, err)
return nil
}
var regex *regexp.Regexp
regexString := values.Get("regex")
if regexString != "" {
regex, err = regexp.Compile(regexString)
if err != nil {
httputil.BadRequest(w, r, err)
return nil
}
}
repoCharts, err := c.Manager.ListRepoCharts(repoURL, regex)
if err != nil {
return err
}
util.LogHandlerExitWithJSON(handler, w, repoCharts, http.StatusOK)
return nil
}
示例4: getConfigurationHandlerFunc
func getConfigurationHandlerFunc(w http.ResponseWriter, r *http.Request) {
handler := "resourcifier: get configuration"
util.LogHandlerEntry(handler, r)
rtype, err := getPathVariable(w, r, "type", handler)
if err != nil {
return
}
rname, err := getPathVariable(w, r, "name", handler)
if err != nil {
return
}
c := &common.Configuration{
Resources: []*common.Resource{
{Name: rname, Type: rtype},
},
}
output, err := backend.Configure(c, configurator.GetOperation)
if err != nil {
util.LogAndReturnError(handler, http.StatusBadRequest, err, w)
return
}
util.LogHandlerExit(handler, http.StatusOK, output, w)
util.WriteYAML(handler, w, []byte(output), http.StatusOK)
}
示例5: getCredential
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
}
示例6: getDeploymentRequest
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
}
示例7: listChartsHandlerFunc
// Putting Type handlers here for now because deployments.go
// currently owns its own Manager backend and doesn't like to share.
func listChartsHandlerFunc(w http.ResponseWriter, r *http.Request, c *router.Context) error {
handler := "manager: list charts"
util.LogHandlerEntry(handler, r)
types, err := c.Manager.ListCharts()
if err != nil {
httputil.BadRequest(w, r, err)
return nil
}
util.LogHandlerExitWithJSON(handler, w, types, http.StatusOK)
return nil
}
示例8: listDeploymentsHandlerFunc
func listDeploymentsHandlerFunc(w http.ResponseWriter, r *http.Request, c *router.Context) error {
handler := "manager: list deployments"
util.LogHandlerEntry(handler, r)
l, err := c.Manager.ListDeployments()
if err != nil {
util.LogAndReturnError(handler, http.StatusInternalServerError, err, w)
return nil
}
var names []string
for _, d := range l {
names = append(names, d.Name)
}
util.LogHandlerExitWithJSON(handler, w, names, http.StatusOK)
return nil
}
示例9: NewService
// NewService encapsulates code to open an HTTP server on the given address:port that serves the
// expansion API using the given Expander backend to do the actual expansion. After calling
// NewService, call ListenAndServe to start the returned service.
func NewService(address string, port int, backend Expander) *Service {
restful.EnableTracing(true)
webService := new(restful.WebService)
webService.Consumes(restful.MIME_JSON)
webService.Produces(restful.MIME_JSON)
handler := func(req *restful.Request, resp *restful.Response) {
util.LogHandlerEntry("expansion service", req.Request)
request := &ServiceRequest{}
if err := req.ReadEntity(&request); err != nil {
badRequest(resp, err.Error())
return
}
reqMsg := fmt.Sprintf("\nhandling request:\n%s\n", util.ToYAMLOrError(request))
util.LogHandlerText("expansion service", reqMsg)
response, err := backend.ExpandChart(request)
if err != nil {
badRequest(resp, fmt.Sprintf("error expanding chart: %s", err))
return
}
util.LogHandlerExit("expansion service", http.StatusOK, "OK", resp.ResponseWriter)
respMsg := fmt.Sprintf("\nreturning response:\n%s\n", util.ToYAMLOrError(response.Resources))
util.LogHandlerText("expansion service", respMsg)
resp.WriteEntity(response)
}
webService.Route(
webService.POST("/expand").
To(handler).
Doc("Expand a chart.").
Reads(&ServiceRequest{}).
Writes(&ServiceResponse{}))
container := restful.DefaultContainer
container.Add(webService)
server := &http.Server{
Addr: fmt.Sprintf("%s:%d", address, port),
Handler: container,
}
return &Service{
webService: webService,
server: server,
container: container,
}
}
示例10: deleteDeploymentHandlerFunc
func deleteDeploymentHandlerFunc(w http.ResponseWriter, r *http.Request, c *router.Context) error {
handler := "manager: delete deployment"
util.LogHandlerEntry(handler, r)
defer r.Body.Close()
name, err := pos(w, r, 2)
if err != nil {
return err
}
d, err := c.Manager.DeleteDeployment(name, true)
if err != nil {
return err
}
util.LogHandlerExitWithJSON(handler, w, d, http.StatusOK)
return nil
}
示例11: getDeploymentHandlerFunc
func getDeploymentHandlerFunc(w http.ResponseWriter, r *http.Request, c *router.Context) error {
handler := "manager: get deployment"
util.LogHandlerEntry(handler, r)
name, err := pos(w, r, 2)
if err != nil {
return nil
}
d, err := c.Manager.GetDeployment(name)
if err != nil {
util.LogAndReturnError(handler, http.StatusBadRequest, err, w)
return nil
}
util.LogHandlerExitWithJSON(handler, w, d, http.StatusOK)
return nil
}
示例12: expandHandlerFunc
func expandHandlerFunc(w http.ResponseWriter, r *http.Request, c *router.Context) error {
handler := "manager: expand config"
util.LogHandlerEntry(handler, r)
defer r.Body.Close()
depReq := getDeploymentRequest(w, r, handler)
if depReq != nil {
c, err := c.Manager.Expand(depReq)
if err != nil {
httputil.BadRequest(w, r, err)
return nil
}
util.LogHandlerExitWithJSON(handler, w, c, http.StatusCreated)
}
return nil
}
示例13: getCredentialHandlerFunc
func getCredentialHandlerFunc(w http.ResponseWriter, r *http.Request, c *router.Context) error {
handler := "manager: get credential"
util.LogHandlerEntry(handler, r)
credentialName, err := pos(w, r, 2)
if err != nil {
return err
}
cr, err := c.Manager.GetCredential(credentialName)
if err != nil {
httputil.BadRequest(w, r, err)
return nil
}
util.LogHandlerExitWithJSON(handler, w, cr, http.StatusOK)
return nil
}
示例14: getMetadataForChartHandlerFunc
func getMetadataForChartHandlerFunc(w http.ResponseWriter, r *http.Request, c *router.Context) error {
handler := "manager: get chart metadata"
util.LogHandlerEntry(handler, r)
chartName, err := pos(w, r, 2)
if err != nil {
return err
}
metadata, err := c.Manager.GetMetadataForChart(chartName)
if err != nil {
httputil.BadRequest(w, r, err)
return nil
}
util.LogHandlerExitWithJSON(handler, w, metadata, http.StatusOK)
return nil
}
示例15: listChartInstancesHandlerFunc
func listChartInstancesHandlerFunc(w http.ResponseWriter, r *http.Request, c *router.Context) error {
handler := "manager: list chart instances"
util.LogHandlerEntry(handler, r)
chartName, err := pos(w, r, 2)
if err != nil {
return err
}
instances, err := c.Manager.ListChartInstances(chartName)
if err != nil {
httputil.BadRequest(w, r, err)
return nil
}
util.LogHandlerExitWithJSON(handler, w, instances, http.StatusOK)
return nil
}