Chromium Code Reviews| Index: milo/appengine/buildbot/builder.go |
| diff --git a/milo/appengine/buildbot/builder.go b/milo/appengine/buildbot/builder.go |
| index 1fc67d31c626cf183ce51356fd29b3a4bd75f7d4..bf45a8bba672e46a83e9886a65f2c69aa74cb1c4 100644 |
| --- a/milo/appengine/buildbot/builder.go |
| +++ b/milo/appengine/buildbot/builder.go |
| @@ -7,6 +7,7 @@ package buildbot |
| import ( |
| "encoding/json" |
| "fmt" |
| + "net/http" |
| "os" |
| "sort" |
| "strings" |
| @@ -17,6 +18,8 @@ import ( |
| "github.com/luci/luci-go/common/clock" |
| log "github.com/luci/luci-go/common/logging" |
| "github.com/luci/luci-go/milo/api/resp" |
| + "github.com/luci/luci-go/milo/appengine/settings" |
| + "github.com/luci/luci-go/milo/common/miloerror" |
| "golang.org/x/net/context" |
| ) |
| @@ -62,7 +65,8 @@ func getBuildSummary(b *buildbotBuild) *resp.BuildSummary { |
| } |
| } |
| -// getBuilds fetches all of the recent builds from the datastore. |
| +// getBuilds fetches all of the recent builds from the datastore. Note that |
| +// getBuilds() does not perform ACL checks. |
| func getBuilds(c context.Context, masterName, builderName string, finished bool) ([]*resp.BuildSummary, error) { |
| // TODO(hinoka): Builder specific structs. |
| result := []*resp.BuildSummary{} |
| @@ -110,6 +114,11 @@ func getCurrentBuilds(c context.Context, master *buildbotMaster, builderName str |
| return results |
| } |
| +var errMasterNotFound = miloerror.Error{ |
| + Message: "Master not found", |
| + Code: http.StatusNotFound, |
| +} |
| + |
| // builderImpl is the implementation for getting a milo builder page from buildbot. |
| // This gets: |
| // * Current Builds from querying the master json from the datastore. |
| @@ -118,8 +127,15 @@ func builderImpl(c context.Context, masterName, builderName string) (*resp.Build |
| result := &resp.Builder{} |
| master, internal, t, err := getMasterJSON(c, masterName) |
| if internal { |
| - // TODO(hinoka): Implement ACL support and remove this. |
| - return nil, fmt.Errorf("Internal masters are not yet supported.") |
| + allowed, err := settings.IsAllowed(c, "buildbot-internal") |
| + if err != nil { |
| + log.WithError(err).Errorf(c, |
| + "Encountered error while checking buildbot membership, returning 404") |
| + return nil, errMasterNotFound |
|
Vadim Sh.
2016/08/23 18:53:06
same here
Ryan Tseng
2016/08/23 22:00:15
Done.
|
| + } |
| + if !allowed { |
| + return nil, errMasterNotFound |
| + } |
| } |
| if err != nil { |
| return nil, fmt.Errorf("Cannot find master %s\n%s", masterName, err.Error()) |