| OLD | NEW |
| 1 // Copyright 2015 The LUCI Authors. | 1 // Copyright 2015 The LUCI Authors. |
| 2 // | 2 // |
| 3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
| 5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
| 6 // | 6 // |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 // | 8 // |
| 9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
| 10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 | 22 |
| 23 "github.com/luci/luci-go/common/errors" | 23 "github.com/luci/luci-go/common/errors" |
| 24 "github.com/luci/luci-go/common/logging" | 24 "github.com/luci/luci-go/common/logging" |
| 25 "github.com/luci/luci-go/milo/common" | 25 "github.com/luci/luci-go/milo/common" |
| 26 "github.com/luci/luci-go/server/router" | 26 "github.com/luci/luci-go/server/router" |
| 27 "github.com/luci/luci-go/server/templates" | 27 "github.com/luci/luci-go/server/templates" |
| 28 ) | 28 ) |
| 29 | 29 |
| 30 // ConfigsHandler renders the page showing the currently loaded set of luci-conf
igs. | 30 // ConfigsHandler renders the page showing the currently loaded set of luci-conf
igs. |
| 31 func ConfigsHandler(c *router.Context) { | 31 func ConfigsHandler(c *router.Context) { |
| 32 » projects, err := common.GetAllProjects(c.Context) | 32 » consoles, err := common.GetAllConsoles(c.Context, "") |
| 33 if err != nil { | 33 if err != nil { |
| 34 ErrorHandler(c, errors.Annotate(err, "Error while getting projec
ts").Err()) | 34 ErrorHandler(c, errors.Annotate(err, "Error while getting projec
ts").Err()) |
| 35 return | 35 return |
| 36 } | 36 } |
| 37 sc, err := common.GetCurrentServiceConfig(c.Context) | 37 sc, err := common.GetCurrentServiceConfig(c.Context) |
| 38 if err != nil && err != datastore.ErrNoSuchEntity { | 38 if err != nil && err != datastore.ErrNoSuchEntity { |
| 39 ErrorHandler(c, errors.Annotate(err, "Error while getting servic
e config").Err()) | 39 ErrorHandler(c, errors.Annotate(err, "Error while getting servic
e config").Err()) |
| 40 return | 40 return |
| 41 } | 41 } |
| 42 | 42 |
| 43 templates.MustRender(c.Context, c.Writer, "pages/configs.html", template
s.Args{ | 43 templates.MustRender(c.Context, c.Writer, "pages/configs.html", template
s.Args{ |
| 44 » » "Projects": projects, | 44 » » "Consoles": consoles, |
| 45 "ServiceConfig": sc, | 45 "ServiceConfig": sc, |
| 46 }) | 46 }) |
| 47 } | 47 } |
| 48 | 48 |
| 49 // UpdateHandler is an HTTP handler that handles configuration update requests. | 49 // UpdateHandler is an HTTP handler that handles configuration update requests. |
| 50 func UpdateConfigHandler(ctx *router.Context) { | 50 func UpdateConfigHandler(ctx *router.Context) { |
| 51 c, h := ctx.Context, ctx.Writer | 51 c, h := ctx.Context, ctx.Writer |
| 52 // Needed to access the PubSub API | 52 // Needed to access the PubSub API |
| 53 c = appengine.WithContext(c, ctx.Request) | 53 c = appengine.WithContext(c, ctx.Request) |
| 54 » projErr := common.UpdateProjectConfigs(c) | 54 » projErr := common.UpdateConsoles(c) |
| 55 if projErr != nil { | 55 if projErr != nil { |
| 56 logging.WithError(projErr).Errorf(c, "project update handler enc
ountered error") | 56 logging.WithError(projErr).Errorf(c, "project update handler enc
ountered error") |
| 57 } | 57 } |
| 58 settings, servErr := common.UpdateServiceConfig(c) | 58 settings, servErr := common.UpdateServiceConfig(c) |
| 59 if servErr != nil { | 59 if servErr != nil { |
| 60 logging.WithError(servErr).Errorf(c, "service update handler enc
ountered error") | 60 logging.WithError(servErr).Errorf(c, "service update handler enc
ountered error") |
| 61 } else { | 61 } else { |
| 62 servErr = common.EnsurePubSubSubscribed(c, settings) | 62 servErr = common.EnsurePubSubSubscribed(c, settings) |
| 63 if servErr != nil { | 63 if servErr != nil { |
| 64 logging.WithError(servErr).Errorf( | 64 logging.WithError(servErr).Errorf( |
| 65 c, "pubsub subscriber handler encountered error"
) | 65 c, "pubsub subscriber handler encountered error"
) |
| 66 } | 66 } |
| 67 } | 67 } |
| 68 if projErr != nil || servErr != nil { | 68 if projErr != nil || servErr != nil { |
| 69 h.WriteHeader(http.StatusInternalServerError) | 69 h.WriteHeader(http.StatusInternalServerError) |
| 70 return | 70 return |
| 71 } | 71 } |
| 72 h.WriteHeader(http.StatusOK) | 72 h.WriteHeader(http.StatusOK) |
| 73 } | 73 } |
| OLD | NEW |