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

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

Issue 2977863002: [milo] Refactor all html knowledge out of backends. (Closed)
Patch Set: seems to work :) 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') | milo/buildsource/buildbot/builder.go » ('J')
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..726c2db8d65259b292ed8419494c0852a241e886 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,45 @@ func promoteLogDogLinks(s *buildbotStep, isInitialStep bool, linkMap map[string]
}
s.Aliases = newAliases
}
+
+// BuildID is buildbots's notion of a Build. See buildsource.ID.
Ryan Tseng 2017/07/13 22:00:46 Make a note of why there is an error in here. (Bec
iannucci 2017/07/14 19:00:22 Done.
+type BuildID struct {
+ Master string
+ BuilderName string
+ BuildNumber int
+
+ err error
+}
+
+// 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(ctx context.Context) (*resp.MiloBuild, error) {
+ if b.err != nil {
+ return nil, b.err
+ }
+ 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)
+ }
+ if b.BuildNumber <= 0 {
+ return nil, errors.New("BuildNumber must be > 0", common.CodeParameterError)
+ }
+
+ return Build(ctx, b.Master, b.BuilderName, b.BuildNumber)
+}
+
+// NewBuildID generates a new BuildID.
+func NewBuildID(master, builder, build string) *BuildID {
+ num, err := strconv.ParseInt(build, 10, 0)
+ if err != nil {
+ return &BuildID{err: errors.
+ Annotate(err, "BuildNumber is not a number").
+ Tag(common.CodeParameterError).
+ Err()}
+ }
+ return &BuildID{master, builder, int(num), nil}
+}
« no previous file with comments | « no previous file | milo/buildsource/buildbot/build_test.go » ('j') | milo/buildsource/buildbot/builder.go » ('J')

Powered by Google App Engine
This is Rietveld 408576698