From a0c7b3f7689e2fe88a7bc8e14a69db9819c58a49 Mon Sep 17 00:00:00 2001 From: Brad Rydzewski Date: Thu, 30 Apr 2015 20:59:22 -0700 Subject: [PATCH] organizing build file --- datastore/bolt/build.go | 31 +++++++++++-------------------- 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/datastore/bolt/build.go b/datastore/bolt/build.go index d2ef55d5a..0623cfd8f 100644 --- a/datastore/bolt/build.go +++ b/datastore/bolt/build.go @@ -70,6 +70,17 @@ func (db *DB) BuildLast(repo string) (*common.Build, error) { return build, err } +// BuildAgent gets the agent that is currently executing +// a build. If no agent exists ErrKeyNotFound is returned. +func (db *DB) BuildAgent(repo string, build int) (*common.Agent, error) { + key := []byte(repo + "/" + strconv.Itoa(build)) + agent := &common.Agent{} + err := db.View(func(t *bolt.Tx) error { + return get(t, bucketBuildAgent, key, agent) + }) + return agent, err +} + // SetBuild inserts or updates a build for the named // repository. The build number is incremented and // assigned to the provided build. @@ -113,17 +124,6 @@ func (db *DB) SetBuild(repo string, build *common.Build) error { }) } -// SetStatus inserts a new build status for the -// named repository and build number. If the status already -// exists an error is returned. -func (db *DB) SetStatus(repo string, build int, status *common.Status) error { - key := []byte(repo + "/" + strconv.Itoa(build) + "/" + status.Context) - - return db.Update(func(t *bolt.Tx) error { - return update(t, bucketBuildStatus, key, status) - }) -} - // Experimental func (db *DB) SetBuildState(repo string, build *common.Build) error { key := []byte(repo + "/" + strconv.Itoa(build.Number)) @@ -193,12 +193,3 @@ func (db *DB) DelBuildAgent(repo string, build int) error { return delete(t, bucketBuildAgent, key) }) } - -func (db *DB) BuildAgent(repo string, build int) (*common.Agent, error) { - key := []byte(repo + "/" + strconv.Itoa(build)) - agent := &common.Agent{} - err := db.View(func(t *bolt.Tx) error { - return get(t, bucketBuildAgent, key, agent) - }) - return agent, err -}