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

Side by Side Diff: milo/appengine/buildbot/master.go

Issue 2321243002: Milo: Add current builds to buildbot builder view (Closed)
Patch Set: Rebase Created 4 years, 1 month 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 buildbot 5 package buildbot
6 6
7 import ( 7 import (
8 "bytes" 8 "bytes"
9 "compress/gzip" 9 "compress/gzip"
10 "encoding/json" 10 "encoding/json"
11 "fmt" 11 "fmt"
12 "net/http"
13 "sort" 12 "sort"
14 "time" 13 "time"
15 14
16 ds "github.com/luci/gae/service/datastore" 15 ds "github.com/luci/gae/service/datastore"
17 "github.com/luci/luci-go/common/logging" 16 "github.com/luci/luci-go/common/logging"
18 "github.com/luci/luci-go/milo/api/resp" 17 "github.com/luci/luci-go/milo/api/resp"
19 "github.com/luci/luci-go/milo/appengine/settings" 18 "github.com/luci/luci-go/milo/appengine/settings"
20 "github.com/luci/luci-go/milo/common/miloerror"
21 19
22 "golang.org/x/net/context" 20 "golang.org/x/net/context"
23 ) 21 )
24 22
25 func decodeMasterEntry( 23 func decodeMasterEntry(
26 c context.Context, entry *buildbotMasterEntry, master *buildbotMaster) e rror { 24 c context.Context, entry *buildbotMasterEntry, master *buildbotMaster) e rror {
27 25
28 reader, err := gzip.NewReader(bytes.NewReader(entry.Data)) 26 reader, err := gzip.NewReader(bytes.NewReader(entry.Data))
29 if err != nil { 27 if err != nil {
30 return err 28 return err
31 } 29 }
32 defer reader.Close() 30 defer reader.Close()
33 if err = json.NewDecoder(reader).Decode(master); err != nil { 31 if err = json.NewDecoder(reader).Decode(master); err != nil {
34 return err 32 return err
35 } 33 }
36 return nil 34 return nil
37 } 35 }
38 36
39 var errMasterNotFound = miloerror.Error{
40 Message: "Master not found",
41 Code: http.StatusNotFound,
42 }
43
44 // getMasterEntry feches the named master and does an ACL check on the 37 // getMasterEntry feches the named master and does an ACL check on the
45 // current user. 38 // current user.
46 func getMasterEntry(c context.Context, name string) (*buildbotMasterEntry, error ) { 39 func getMasterEntry(c context.Context, name string) (*buildbotMasterEntry, error ) {
47 entry := buildbotMasterEntry{Name: name} 40 entry := buildbotMasterEntry{Name: name}
48 err := ds.Get(c, &entry) 41 err := ds.Get(c, &entry)
49 switch { 42 switch {
50 case err == ds.ErrNoSuchEntity: 43 case err == ds.ErrNoSuchEntity:
51 return nil, errMasterNotFound 44 return nil, errMasterNotFound
52 case err != nil: 45 case err != nil:
53 logging.WithError(err).Errorf( 46 logging.WithError(err).Errorf(
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 Label: bn, 123 Label: bn,
131 // Go templates escapes this for us, and also 124 // Go templates escapes this for us, and also
132 // slashes are not allowed in builder names. 125 // slashes are not allowed in builder names.
133 URL: fmt.Sprintf("/buildbot/%s/%s", entry.Name, bn), 126 URL: fmt.Sprintf("/buildbot/%s/%s", entry.Name, bn),
134 }) 127 })
135 } 128 }
136 result.Masters = append(result.Masters, ml) 129 result.Masters = append(result.Masters, ml)
137 } 130 }
138 return result, nil 131 return result, nil
139 } 132 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698