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

Unified Diff: milo/buildsource/buildbot/build.go

Issue 2977863002: [milo] Refactor all html knowledge out of backends. (Closed)
Patch Set: now with case insensitivity 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 | « no previous file | milo/buildsource/buildbot/build_test.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: milo/buildsource/buildbot/build.go
diff --git a/milo/buildsource/buildbot/build.go b/milo/buildsource/buildbot/build.go
index 6d5bb8e5eaff82d08f6c4f3b672af498790f12b1..63dfb6741e7f3765f04eca5480e4fca801657343 100644
--- a/milo/buildsource/buildbot/build.go
+++ b/milo/buildsource/buildbot/build.go
@@ -16,7 +16,6 @@ package buildbot
import (
"encoding/json"
- "errors"
"fmt"
"io/ioutil"
"math"
@@ -31,13 +30,13 @@ import (
"github.com/luci/gae/service/datastore"
"github.com/luci/luci-go/common/data/stringset"
+ "github.com/luci/luci-go/common/errors"
"github.com/luci/luci-go/common/logging"
"github.com/luci/luci-go/milo/api/resp"
+ "github.com/luci/luci-go/milo/common"
"github.com/luci/luci-go/milo/common/model"
)
-var errBuildNotFound = errors.New("Build not found")
-
// getBuild fetches a buildbot build from the datastore and checks ACLs.
// The return code matches the master responses.
func getBuild(c context.Context, master, builder string, buildNum int) (*buildbotBuild, error) {
@@ -53,7 +52,7 @@ func getBuild(c context.Context, master, builder string, buildNum int) (*buildbo
err := datastore.Get(c, result)
if err == datastore.ErrNoSuchEntity {
- err = errBuildNotFound
+ err = errors.New("build not found", common.CodeNotFound)
}
return result, err
@@ -672,3 +671,35 @@ func promoteLogDogLinks(s *buildbotStep, isInitialStep bool, linkMap map[string]
}
s.Aliases = newAliases
}
+
+// BuildID is buildbots's notion of a Build. See buildsource.ID.
+type BuildID struct {
+ Master string
+ BuilderName string
+ BuildNumber string
+}
+
+// GetLog implements buildsource.ID.
+func (b *BuildID) GetLog(context.Context, string) (string, bool, error) { panic("not implemented") }
+
+// Get implements buildsource.ID.
+func (b *BuildID) Get(c context.Context) (*resp.MiloBuild, error) {
+ num, err := strconv.ParseInt(b.BuildNumber, 10, 0)
+ if err != nil {
+ return nil, errors.Annotate(err, "BuildNumber is not a number").
+ Tag(common.CodeParameterError).
+ Err()
+ }
+ if num <= 0 {
+ return nil, errors.New("BuildNumber must be > 0", common.CodeParameterError)
+ }
+
+ if b.Master == "" {
+ return nil, errors.New("Master name is required", common.CodeParameterError)
+ }
+ if b.BuilderName == "" {
+ return nil, errors.New("BuilderName name is required", common.CodeParameterError)
+ }
+
+ return Build(c, b.Master, b.BuilderName, int(num))
+}
« no previous file with comments | « no previous file | milo/buildsource/buildbot/build_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698