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

Side by Side Diff: milo/buildsource/buildbot/build.go

Issue 2974263002: [milo] better ACL system for masters. (Closed)
Patch Set: fix tests Created 3 years, 5 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 buildbot 5 package buildbot
6 6
7 import ( 7 import (
8 "encoding/json" 8 "encoding/json"
9 "errors" 9 "errors"
10 "fmt" 10 "fmt"
(...skipping 13 matching lines...) Expand all
24 "github.com/luci/luci-go/common/logging" 24 "github.com/luci/luci-go/common/logging"
25 "github.com/luci/luci-go/milo/api/resp" 25 "github.com/luci/luci-go/milo/api/resp"
26 "github.com/luci/luci-go/milo/common/model" 26 "github.com/luci/luci-go/milo/common/model"
27 ) 27 )
28 28
29 var errBuildNotFound = errors.New("Build not found") 29 var errBuildNotFound = errors.New("Build not found")
30 30
31 // getBuild fetches a buildbot build from the datastore and checks ACLs. 31 // getBuild fetches a buildbot build from the datastore and checks ACLs.
32 // The return code matches the master responses. 32 // The return code matches the master responses.
33 func getBuild(c context.Context, master, builder string, buildNum int) (*buildbo tBuild, error) { 33 func getBuild(c context.Context, master, builder string, buildNum int) (*buildbo tBuild, error) {
34 if err := canAccessMaster(c, master); err != nil {
35 return nil, err
36 }
37
34 result := &buildbotBuild{ 38 result := &buildbotBuild{
35 Master: master, 39 Master: master,
36 Buildername: builder, 40 Buildername: builder,
37 Number: buildNum, 41 Number: buildNum,
38 } 42 }
39 43
40 err := datastore.Get(c, result) 44 err := datastore.Get(c, result)
41 » err = checkAccess(c, err, result.Internal) 45 » if err == datastore.ErrNoSuchEntity {
42 » if err == errMasterNotFound {
43 err = errBuildNotFound 46 err = errBuildNotFound
44 } 47 }
45 48
46 return result, err 49 return result, err
47 } 50 }
48 51
49 // result2Status translates a buildbot result integer into a model.Status. 52 // result2Status translates a buildbot result integer into a model.Status.
50 func result2Status(s *int) (status model.Status) { 53 func result2Status(s *int) (status model.Status) {
51 if s == nil { 54 if s == nil {
52 return model.Running 55 return model.Running
(...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after
652 var newAliases map[string][]*buildbotLinkAlias 655 var newAliases map[string][]*buildbotLinkAlias
653 if l := remainingAliases.Len(); l > 0 { 656 if l := remainingAliases.Len(); l > 0 {
654 newAliases = make(map[string][]*buildbotLinkAlias, l) 657 newAliases = make(map[string][]*buildbotLinkAlias, l)
655 remainingAliases.Iter(func(v string) bool { 658 remainingAliases.Iter(func(v string) bool {
656 newAliases[v] = s.Aliases[v] 659 newAliases[v] = s.Aliases[v]
657 return true 660 return true
658 }) 661 })
659 } 662 }
660 s.Aliases = newAliases 663 s.Aliases = newAliases
661 } 664 }
OLDNEW
« no previous file with comments | « no previous file | milo/buildsource/buildbot/buildinfo_test.go » ('j') | milo/buildsource/buildbot/pubsub.go » ('J')

Powered by Google App Engine
This is Rietveld 408576698