feat(be): init boltdb

This commit is contained in:
Denis Gukov 2021-04-10 02:02:19 +05:00
parent 0787920d97
commit 696353ffdf
4 changed files with 25 additions and 3 deletions

View File

@ -55,7 +55,7 @@ func AddTask(w http.ResponseWriter, r *http.Request) {
return
}
helpers.WriteJSON(w, http.StatusCreated, taskObj)
helpers.WriteJSON(w, http.StatusCreated, newTask)
}
// GetTasksList returns a list of tasks for the current project in desc order to limit or error

View File

@ -1,11 +1,31 @@
package bolt
type BoltDb struct {
import (
"github.com/ansible-semaphore/semaphore/util"
bolt "go.etcd.io/bbolt"
)
type BoltDb struct {
db *bolt.DB
}
func (d *BoltDb) Migrate() {
}
func (d *BoltDb) Connect() error {
config, err := util.Config.GetDBConfig()
if err != nil {
return err
}
db, err := bolt.Open(config.Hostname, 0666, nil)
if err != nil {
return err
}
d.db = db
return nil
}
func (d *BoltDb) Close() error {
return d.db.Close()
}

3
go.mod
View File

@ -39,9 +39,10 @@ require (
github.com/radovskyb/watcher v1.0.7 // indirect
github.com/russross/blackfriday v1.5.2
github.com/sirupsen/logrus v1.4.2 // indirect
github.com/snikch/goodman v0.0.0-20171125024755-10e37e294daa
github.com/snikch/goodman v0.0.0-20171125024755-10e37e294daa // indirect
github.com/spf13/cobra v0.0.5 // indirect
github.com/ziutek/mymysql v1.5.4 // indirect
go.etcd.io/bbolt v1.3.2
golang.org/x/crypto v0.0.0-20200208060501-ecb85df21340
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e // indirect
golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5 // indirect

1
go.sum
View File

@ -288,6 +288,7 @@ github.com/vektah/gqlparser v1.1.2/go.mod h1:1ycwN7Ij5njmMkPPAOaRFY4rET2Enx7IkVv
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
github.com/ziutek/mymysql v1.5.4/go.mod h1:LMSpPZ6DbqWFxNCHW77HeMg9I646SAhApZ/wKdgO/C0=
go.etcd.io/bbolt v1.3.2 h1:Z/90sZLPOeCy2PwprqkFa25PdkusRzaj9P8zm/KNyvk=
go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
go.mongodb.org/mongo-driver v1.0.3/go.mod h1:u7ryQJ+DOzQmeO7zB6MHyr8jkEQvC8vH7qLUO4lqsUM=
go.mongodb.org/mongo-driver v1.1.1/go.mod h1:u7ryQJ+DOzQmeO7zB6MHyr8jkEQvC8vH7qLUO4lqsUM=