| OLD | NEW |
| 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" |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 entry := buildbotMasterEntry{Name: name} | 79 entry := buildbotMasterEntry{Name: name} |
| 80 err := ds.Get(c, &entry) | 80 err := ds.Get(c, &entry) |
| 81 err = checkAccess(c, err, entry.Internal) | 81 err = checkAccess(c, err, entry.Internal) |
| 82 return &entry, err | 82 return &entry, err |
| 83 } | 83 } |
| 84 | 84 |
| 85 // getMasterJSON fetches the latest known buildbot master data and returns | 85 // getMasterJSON fetches the latest known buildbot master data and returns |
| 86 // the buildbotMaster struct (if found), whether or not it is internal, | 86 // the buildbotMaster struct (if found), whether or not it is internal, |
| 87 // the last modified time, and an error if not found. | 87 // the last modified time, and an error if not found. |
| 88 func getMasterJSON(c context.Context, name string) ( | 88 func getMasterJSON(c context.Context, name string) ( |
| 89 » master *buildbotMaster, t time.Time, err error) { | 89 » master *buildbotMaster, internal bool, t time.Time, err error) { |
| 90 master = &buildbotMaster{} | 90 master = &buildbotMaster{} |
| 91 entry, err := getMasterEntry(c, name) | 91 entry, err := getMasterEntry(c, name) |
| 92 if err != nil { | 92 if err != nil { |
| 93 return | 93 return |
| 94 } | 94 } |
| 95 t = entry.Modified | 95 t = entry.Modified |
| 96 internal = entry.Internal |
| 96 err = decodeMasterEntry(c, entry, master) | 97 err = decodeMasterEntry(c, entry, master) |
| 97 return | 98 return |
| 98 } | 99 } |
| 99 | 100 |
| 100 // GetAllBuilders returns a resp.Module object containing all known masters | 101 // GetAllBuilders returns a resp.Module object containing all known masters |
| 101 // and builders. | 102 // and builders. |
| 102 func GetAllBuilders(c context.Context) (*resp.CIService, error) { | 103 func GetAllBuilders(c context.Context) (*resp.CIService, error) { |
| 103 result := &resp.CIService{Name: "Buildbot"} | 104 result := &resp.CIService{Name: "Buildbot"} |
| 104 // Fetch all Master entries from datastore | 105 // Fetch all Master entries from datastore |
| 105 q := ds.NewQuery("buildbotMasterEntry") | 106 q := ds.NewQuery("buildbotMasterEntry") |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 Label: bn, | 144 Label: bn, |
| 144 // Go templates escapes this for us, and also | 145 // Go templates escapes this for us, and also |
| 145 // slashes are not allowed in builder names. | 146 // slashes are not allowed in builder names. |
| 146 URL: fmt.Sprintf("/buildbot/%s/%s", entry.Name,
bn), | 147 URL: fmt.Sprintf("/buildbot/%s/%s", entry.Name,
bn), |
| 147 }) | 148 }) |
| 148 } | 149 } |
| 149 result.BuilderGroups = append(result.BuilderGroups, ml) | 150 result.BuilderGroups = append(result.BuilderGroups, ml) |
| 150 } | 151 } |
| 151 return result, nil | 152 return result, nil |
| 152 } | 153 } |
| OLD | NEW |