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

Unified Diff: milo/appengine/buildbot/builder.go

Issue 2271453002: Milo: Internal buildbot masters support (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-go@master
Patch Set: More places 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 side-by-side diff with in-line comments
Download patch
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())

Powered by Google App Engine
This is Rietveld 408576698