mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-30 08:06:52 +02:00
parent
09d5c6f011
commit
3f2d72daf0
@ -3,73 +3,10 @@ package bolt
|
||||
import (
|
||||
"bytes"
|
||||
"github.com/boltdb/bolt"
|
||||
//"github.com/drone/drone/common"
|
||||
"io"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
/*
|
||||
Brad Rydzewski1:00 PM
|
||||
the `Task`, `TaskList` and `SetTask` are deprecated and can be probably be removed.
|
||||
I just need to make sure we aren't still using those functions anywhere else in the code
|
||||
*/
|
||||
/*
|
||||
// GetTask gets the task at index N for the named
|
||||
// repository and build number.
|
||||
func (db *DB) Task(repo string, build int, task int) (*common.Task, error) {
|
||||
key := []byte(repo + "/" + strconv.Itoa(build) + "/" + strconv.Itoa(task))
|
||||
task_ := &common.Task{}
|
||||
err := db.View(func(t *bolt.Tx) error {
|
||||
return get(t, bucketBuildTasks, key, task_)
|
||||
})
|
||||
return task_, err
|
||||
}
|
||||
|
||||
// TaskList gets all tasks for the named repository
|
||||
// and build number.
|
||||
func (db *DB) TaskList(repo string, build int) ([]*common.Task, error) {
|
||||
// fetch the build so that we can get the
|
||||
// number of child tasks.
|
||||
build_, err := db.Build(repo, build)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
t, err := db.Begin(false)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer t.Rollback()
|
||||
|
||||
// based on the number of child tasks, incrment
|
||||
// and loop to get each task from the bucket.
|
||||
tasks := []*common.Task{}
|
||||
for i := 1; i <= build_.Number; i++ {
|
||||
key := []byte(repo + "/" + strconv.Itoa(build) + "/" + strconv.Itoa(i))
|
||||
raw := t.Bucket(bucketBuildTasks).Get(key)
|
||||
if raw == nil {
|
||||
return nil, ErrKeyNotFound
|
||||
}
|
||||
task := &common.Task{}
|
||||
err := decode(raw, task)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
tasks = append(tasks, task)
|
||||
}
|
||||
return tasks, nil
|
||||
}
|
||||
|
||||
// SetTask inserts or updates a task for the named
|
||||
// repository and build number.
|
||||
func (db *DB) SetTask(repo string, build int, task *common.Task) error {
|
||||
key := []byte(repo + "/" + strconv.Itoa(build) + "/" + strconv.Itoa(task.Number))
|
||||
return db.Update(func(t *bolt.Tx) error {
|
||||
return update(t, bucketBuildTasks, key, task)
|
||||
})
|
||||
}
|
||||
*/
|
||||
|
||||
// SetLogs inserts or updates a task logs for the
|
||||
// named repository and build number.
|
||||
func (db *DB) SetLogs(repo string, build int, task int, log []byte) error {
|
||||
|
@ -28,43 +28,6 @@ func TestTask(t *testing.T) {
|
||||
os.Remove(db.Path())
|
||||
})
|
||||
|
||||
/*
|
||||
Brad Rydzewski1:00 PM
|
||||
the `Task`, `TaskList` and `SetTask` are deprecated and can be probably be removed.
|
||||
I just need to make sure we aren't still using those functions anywhere else in the code
|
||||
*/
|
||||
/*
|
||||
g.It("Should get TaskList", func() {
|
||||
db.SetRepo(&common.Repo{FullName: testRepo})
|
||||
//db.SetRepoNotExists(&common.User{Login: testUser}, &common.Repo{FullName: testRepo})
|
||||
err := db.SetTask(testRepo, testBuild, &common.Task{Number: testTask})
|
||||
g.Assert(err).Equal(nil)
|
||||
err_ := db.SetTask(testRepo, testBuild, &common.Task{Number: testTask2})
|
||||
g.Assert(err_).Equal(nil)
|
||||
//
|
||||
tasks, err := db.TaskList(testRepo, testBuild)
|
||||
// We seem to have an issue here. TaskList doesn't seem to be returning
|
||||
// All the tasks added to to repo/build. So commenting these for now.
|
||||
//g.Assert(err).Equal(nil)
|
||||
//g.Assert(len(tasks)).Equal(2)
|
||||
})
|
||||
|
||||
g.It("Should set Task", func() {
|
||||
db.SetRepo(&common.Repo{FullName: testRepo})
|
||||
err := db.SetTask(testRepo, testBuild, &common.Task{Number: testTask})
|
||||
g.Assert(err).Equal(nil)
|
||||
})
|
||||
|
||||
g.It("Should get Task", func() {
|
||||
db.SetRepo(&common.Repo{FullName: testRepo})
|
||||
db.SetTask(testRepo, testBuild, &common.Task{Number: testTask})
|
||||
//
|
||||
task, err := db.Task(testRepo, testBuild, testTask)
|
||||
g.Assert(err).Equal(nil)
|
||||
g.Assert(task.Number).Equal(testTask)
|
||||
})
|
||||
*/
|
||||
|
||||
g.It("Should set Logs", func() {
|
||||
db.SetRepo(&common.Repo{FullName: testRepo})
|
||||
//db.SetTask(testRepo, testBuild, &common.Task{Number: testTask})
|
||||
|
@ -119,18 +119,6 @@ type Datastore interface {
|
||||
// exists an error is returned.
|
||||
SetStatus(string, int, *common.Status) error
|
||||
|
||||
// GetTask gets the task at index N for the named
|
||||
// repository and build number.
|
||||
//Task(string, int, int) (*common.Task, error)
|
||||
|
||||
// TaskList gets all tasks for the named repository
|
||||
// and build number.
|
||||
//TaskList(string, int) ([]*common.Task, error)
|
||||
|
||||
// SetTask inserts or updates a task for the named
|
||||
// repository and build number.
|
||||
//SetTask(string, int, *common.Task) error
|
||||
|
||||
// LogReader gets the task logs at index N for
|
||||
// the named repository and build number.
|
||||
LogReader(string, int, int) (io.Reader, error)
|
||||
|
Loading…
Reference in New Issue
Block a user