| OLD | NEW |
| (Empty) |
| 1 // Copyright 2015 The LUCI Authors. All rights reserved. | |
| 2 // Use of this source code is governed under the Apache License, Version 2.0 | |
| 3 // that can be found in the LICENSE file. | |
| 4 | |
| 5 package frontend | |
| 6 | |
| 7 import ( | |
| 8 "net/http" | |
| 9 | |
| 10 "cloud.google.com/go/datastore" | |
| 11 | |
| 12 "github.com/luci/luci-go/common/logging" | |
| 13 "github.com/luci/luci-go/milo/appengine/common" | |
| 14 "github.com/luci/luci-go/server/router" | |
| 15 "github.com/luci/luci-go/server/templates" | |
| 16 ) | |
| 17 | |
| 18 // ConfigsHandler renders the page showing the currently loaded set of luci-conf
igs. | |
| 19 func ConfigsHandler(c *router.Context) { | |
| 20 projects, err := common.GetAllProjects(c.Context) | |
| 21 if err != nil { | |
| 22 common.ErrorPage( | |
| 23 c, http.StatusInternalServerError, | |
| 24 "Error while getting projects: "+err.Error()) | |
| 25 return | |
| 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 } | |
| 34 | |
| 35 templates.MustRender(c.Context, c.Writer, "pages/configs.html", template
s.Args{ | |
| 36 "Projects": projects, | |
| 37 "ServiceConfig": sc, | |
| 38 }) | |
| 39 } | |
| 40 | |
| 41 // UpdateHandler is an HTTP handler that handles configuration update requests. | |
| 42 func UpdateConfigHandler(ctx *router.Context) { | |
| 43 c, h := ctx.Context, ctx.Writer | |
| 44 projErr := common.UpdateProjectConfigs(c) | |
| 45 if projErr != nil { | |
| 46 logging.WithError(projErr).Errorf(c, "project update handler enc
ountered error") | |
| 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) | |
| 54 return | |
| 55 } | |
| 56 h.WriteHeader(http.StatusOK) | |
| 57 } | |
| OLD | NEW |