Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(182)

Side by Side Diff: milo/appengine/settings/config.go

Issue 2275123002: Milo: pRPC endpoint for getting Buildbot master data (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-go@master
Patch Set: Update config tests Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The LUCI Authors. All rights reserved. 1 // Copyright 2016 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 settings 5 package settings
6 6
7 import ( 7 import (
8 "fmt" 8 "fmt"
9 "strings" 9 "strings"
10 10
(...skipping 12 matching lines...) Expand all
23 // name. 23 // name.
24 ID string `gae:"$id"` 24 ID string `gae:"$id"`
25 // The luci-cfg name of the project. 25 // The luci-cfg name of the project.
26 Name string 26 Name string
27 // The Project data in protobuf binary format. 27 // The Project data in protobuf binary format.
28 Data []byte `gae:",noindex"` 28 Data []byte `gae:",noindex"`
29 } 29 }
30 30
31 func UpdateHandler(ctx *router.Context) { 31 func UpdateHandler(ctx *router.Context) {
32 c, h := ctx.Context, ctx.Writer 32 c, h := ctx.Context, ctx.Writer
33 » err := update(c) 33 » err := Update(c)
34 if err != nil { 34 if err != nil {
35 logging.WithError(err).Errorf(c, "Update Handler encountered err or") 35 logging.WithError(err).Errorf(c, "Update Handler encountered err or")
36 h.WriteHeader(500) 36 h.WriteHeader(500)
37 } 37 }
38 logging.Infof(c, "Successfully completed") 38 logging.Infof(c, "Successfully completed")
39 h.WriteHeader(200) 39 h.WriteHeader(200)
40 } 40 }
41 41
42 // Update internal configuration based off luci-cfg. 42 // Update internal configuration based off luci-cfg.
43 // update updates Milo's configuration based off luci config. This includes 43 // update updates Milo's configuration based off luci config. This includes
44 // scanning through all project and extract all console configs. 44 // scanning through all project and extract all console configs.
45 func update(c context.Context) error { 45 func Update(c context.Context) error {
46 cfgName := info.Get(c).AppID() + ".cfg" 46 cfgName := info.Get(c).AppID() + ".cfg"
47 cfgs, err := config.GetProjectConfigs(c, cfgName, false) 47 cfgs, err := config.GetProjectConfigs(c, cfgName, false)
48 if err != nil { 48 if err != nil {
49 return err 49 return err
50 } 50 }
51 // A map of project ID to project. 51 // A map of project ID to project.
52 projects := map[string]*Project{} 52 projects := map[string]*Project{}
53 for _, cfg := range cfgs { 53 for _, cfg := range cfgs {
54 pathParts := strings.SplitN(cfg.ConfigSet, "/", 2) 54 pathParts := strings.SplitN(cfg.ConfigSet, "/", 2)
55 if len(pathParts) != 2 { 55 if len(pathParts) != 2 {
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 if err != nil { 122 if err != nil {
123 return nil, err 123 return nil, err
124 } 124 }
125 for _, cs := range p.Consoles { 125 for _, cs := range p.Consoles {
126 if cs.Name == consoleName { 126 if cs.Name == consoleName {
127 return cs, nil 127 return cs, nil
128 } 128 }
129 } 129 }
130 return nil, fmt.Errorf("Console %s not found in project %s", consoleName , projName) 130 return nil, fmt.Errorf("Console %s not found in project %s", consoleName , projName)
131 } 131 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698