| OLD | NEW |
| 1 // Copyright 2015 The LUCI Authors. All rights reserved. | 1 // Copyright 2015 The LUCI Authors. All rights reserved. |
| 2 // Use of this source code is governed under the Apache License, Version 2.0 | 2 // Use of this source code is governed under the Apache License, Version 2.0 |
| 3 // that can be found in the LICENSE file. | 3 // that can be found in the LICENSE file. |
| 4 | 4 |
| 5 package frontend | 5 package frontend |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "net/http" | 8 "net/http" |
| 9 | 9 |
| 10 "cloud.google.com/go/datastore" |
| 11 |
| 10 "github.com/luci/luci-go/common/logging" | 12 "github.com/luci/luci-go/common/logging" |
| 11 "github.com/luci/luci-go/milo/appengine/common" | 13 "github.com/luci/luci-go/milo/appengine/common" |
| 12 "github.com/luci/luci-go/server/router" | 14 "github.com/luci/luci-go/server/router" |
| 13 "github.com/luci/luci-go/server/templates" | 15 "github.com/luci/luci-go/server/templates" |
| 14 ) | 16 ) |
| 15 | 17 |
| 16 // ConfigsHandler renders the page showing the currently loaded set of luci-conf
igs. | 18 // ConfigsHandler renders the page showing the currently loaded set of luci-conf
igs. |
| 17 func ConfigsHandler(c *router.Context) { | 19 func ConfigsHandler(c *router.Context) { |
| 18 projects, err := common.GetAllProjects(c.Context) | 20 projects, err := common.GetAllProjects(c.Context) |
| 19 if err != nil { | 21 if err != nil { |
| 20 common.ErrorPage( | 22 common.ErrorPage( |
| 21 c, http.StatusInternalServerError, | 23 c, http.StatusInternalServerError, |
| 22 "Error while getting projects: "+err.Error()) | 24 "Error while getting projects: "+err.Error()) |
| 23 return | 25 return |
| 24 } | 26 } |
| 27 sc, err := common.GetCurrentServiceConfig(c.Context) |
| 28 if err != nil && err != datastore.ErrNoSuchEntity { |
| 29 common.ErrorPage( |
| 30 c, http.StatusInternalServerError, |
| 31 "Error while getting service config: "+err.Error()) |
| 32 return |
| 33 } |
| 25 | 34 |
| 26 » templates.MustRender(c.Context, c.Writer, "pages/config.html", templates
.Args{ | 35 » templates.MustRender(c.Context, c.Writer, "pages/configs.html", template
s.Args{ |
| 27 » » "Projects": projects, | 36 » » "Projects": projects, |
| 37 » » "ServiceConfig": sc, |
| 28 }) | 38 }) |
| 29 } | 39 } |
| 30 | 40 |
| 31 // UpdateHandler is an HTTP handler that handles configuration update requests. | 41 // UpdateHandler is an HTTP handler that handles configuration update requests. |
| 32 // TODO(hinoka): Migrate to cfgclient and remove this. | |
| 33 func UpdateConfigHandler(ctx *router.Context) { | 42 func UpdateConfigHandler(ctx *router.Context) { |
| 34 c, h := ctx.Context, ctx.Writer | 43 c, h := ctx.Context, ctx.Writer |
| 35 » err := common.UpdateProjectConfigs(c) | 44 » projErr := common.UpdateProjectConfigs(c) |
| 36 » if err != nil { | 45 » if projErr != nil { |
| 37 » » logging.WithError(err).Errorf(c, "Update Handler encountered err
or") | 46 » » logging.WithError(projErr).Errorf(c, "project update handler enc
ountered error") |
| 38 » » h.WriteHeader(500) | 47 » } |
| 48 » servErr := common.UpdateServiceConfig(c) |
| 49 » if servErr != nil { |
| 50 » » logging.WithError(servErr).Errorf(c, "service update handler enc
ountered error") |
| 51 » } |
| 52 » if projErr != nil || servErr != nil { |
| 53 » » h.WriteHeader(http.StatusInternalServerError) |
| 39 return | 54 return |
| 40 } | 55 } |
| 41 » logging.Infof(c, "Successfully completed") | 56 » h.WriteHeader(http.StatusOK) |
| 42 » h.WriteHeader(200) | |
| 43 } | 57 } |
| OLD | NEW |