mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-12-30 12:20:33 +00:00
parent
b57b6f27f6
commit
e1c31df6c6
1 changed files with 5 additions and 5 deletions
|
@ -20,6 +20,8 @@ import (
|
|||
"github.com/woodpecker-ci/woodpecker/server/model"
|
||||
)
|
||||
|
||||
var ErrNoTokenProvided = errors.New("Please provide a token")
|
||||
|
||||
func (s storage) AgentList(p *model.ListOptions) ([]*model.Agent, error) {
|
||||
var agents []*model.Agent
|
||||
return agents, s.paginate(p).Find(&agents)
|
||||
|
@ -33,12 +35,10 @@ func (s storage) AgentFind(id int64) (*model.Agent, error) {
|
|||
func (s storage) AgentFindByToken(token string) (*model.Agent, error) {
|
||||
// Searching with an empty token would result in an empty where clause and therefore returning first item
|
||||
if token == "" {
|
||||
return nil, errors.New("Please provide a token")
|
||||
return nil, ErrNoTokenProvided
|
||||
}
|
||||
agent := &model.Agent{
|
||||
Token: token,
|
||||
}
|
||||
return agent, wrapGet(s.engine.Get(agent))
|
||||
agent := new(model.Agent)
|
||||
return agent, wrapGet(s.engine.Where("token = ?", token).Get(agent))
|
||||
}
|
||||
|
||||
func (s storage) AgentCreate(agent *model.Agent) error {
|
||||
|
|
Loading…
Reference in a new issue