mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-12-28 11:20:30 +00:00
31 lines
743 B
Go
31 lines
743 B
Go
package datastore
|
|
|
|
import (
|
|
"github.com/drone/drone/model"
|
|
"github.com/russross/meddler"
|
|
)
|
|
|
|
func (db *datastore) GetKey(repo *model.Repo) (*model.Key, error) {
|
|
var key = new(model.Key)
|
|
var err = meddler.QueryRow(db, key, rebind(keyQuery), repo.ID)
|
|
return key, err
|
|
}
|
|
|
|
func (db *datastore) CreateKey(key *model.Key) error {
|
|
return meddler.Save(db, keyTable, key)
|
|
}
|
|
|
|
func (db *datastore) UpdateKey(key *model.Key) error {
|
|
return meddler.Save(db, keyTable, key)
|
|
}
|
|
|
|
func (db *datastore) DeleteKey(key *model.Key) error {
|
|
var _, err = db.Exec(rebind(keyDeleteStmt), key.ID)
|
|
return err
|
|
}
|
|
|
|
const keyTable = "keys"
|
|
|
|
const keyQuery = "SELECT * FROM `keys` WHERE key_repo_id=? LIMIT 1"
|
|
|
|
const keyDeleteStmt = "DELETE FROM `keys` WHERE key_id=?"
|