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

Unified Diff: milo/buildsource/buildbot/pubsub.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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « milo/buildsource/buildbot/master.go ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: milo/buildsource/buildbot/pubsub.go
diff --git a/milo/buildsource/buildbot/pubsub.go b/milo/buildsource/buildbot/pubsub.go
index 83870bf7ef93f21aec2ef6ae9f6ce02fc4da4073..1e83806eca97d3a50d76c039af25d88d2f297f80 100644
--- a/milo/buildsource/buildbot/pubsub.go
+++ b/milo/buildsource/buildbot/pubsub.go
@@ -68,6 +68,12 @@ type buildbotMasterEntry struct {
Modified time.Time
}
+// buildbotMasterPublic is a struct that exists for public builtbot masters, and
+// not for internal masters. It's used for ACL checks.
+type buildbotMasterPublic struct {
+ Name string `gae:"$id"`
+}
+
func putDSMasterJSON(
c context.Context, master *buildbotMaster, internal bool) error {
for _, builder := range master.Builders {
@@ -86,6 +92,17 @@ func putDSMasterJSON(
Internal: internal,
Modified: clock.Now(c).UTC(),
}
+ toPut := []interface{}{&entry}
+ publicTag := &buildbotMasterPublic{master.Name}
+ if internal {
+ // do the deletion immediately so that the 'public' bit is removed from
+ // datastore before any internal details are actually written to datastore.
+ if err := ds.Delete(c, publicTag); err != nil && err != ds.ErrNoSuchEntity {
+ return err
+ }
+ } else {
+ toPut = append(toPut, publicTag)
+ }
gzbs := bytes.Buffer{}
gsw := gzip.NewWriter(&gzbs)
cw := iotools.CountingWriter{Writer: gsw}
@@ -97,7 +114,7 @@ func putDSMasterJSON(
entry.Data = gzbs.Bytes()
logging.Debugf(c, "Length of json data: %d", cw.Count)
logging.Debugf(c, "Length of gzipped data: %d", len(entry.Data))
- return ds.Put(c, &entry)
+ return ds.Put(c, toPut)
}
// unmarshal a gzipped byte stream into a list of buildbot builds and masters.
« no previous file with comments | « milo/buildsource/buildbot/master.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698