mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-12-30 04:10:32 +00:00
parent
a06d3e1a61
commit
9b32d021b3
13 changed files with 24 additions and 19 deletions
|
@ -204,7 +204,7 @@ func DeleteCron(c *gin.Context) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err := store.FromContext(c).CronDelete(repo, id); err != nil {
|
if err := store.FromContext(c).CronDelete(repo, id); err != nil {
|
||||||
c.String(http.StatusInternalServerError, "Error deleting cron %d. %s", id, err)
|
handleDbGetError(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
c.String(http.StatusNoContent, "")
|
c.String(http.StatusNoContent, "")
|
||||||
|
|
|
@ -118,7 +118,7 @@ func PatchGlobalSecret(c *gin.Context) {
|
||||||
func DeleteGlobalSecret(c *gin.Context) {
|
func DeleteGlobalSecret(c *gin.Context) {
|
||||||
name := c.Param("secret")
|
name := c.Param("secret")
|
||||||
if err := server.Config.Services.Secrets.GlobalSecretDelete(name); err != nil {
|
if err := server.Config.Services.Secrets.GlobalSecretDelete(name); err != nil {
|
||||||
c.String(http.StatusInternalServerError, "Error deleting global secret %q. %s", name, err)
|
handleDbGetError(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
c.String(http.StatusNoContent, "")
|
c.String(http.StatusNoContent, "")
|
||||||
|
|
|
@ -131,7 +131,7 @@ func DeleteOrgSecret(c *gin.Context) {
|
||||||
name = c.Param("secret")
|
name = c.Param("secret")
|
||||||
)
|
)
|
||||||
if err := server.Config.Services.Secrets.OrgSecretDelete(owner, name); err != nil {
|
if err := server.Config.Services.Secrets.OrgSecretDelete(owner, name); err != nil {
|
||||||
c.String(http.StatusInternalServerError, "Error deleting org %q secret %q. %s", owner, name, err)
|
handleDbGetError(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
c.String(http.StatusNoContent, "")
|
c.String(http.StatusNoContent, "")
|
||||||
|
|
|
@ -135,7 +135,7 @@ func DeleteRegistry(c *gin.Context) {
|
||||||
)
|
)
|
||||||
err := server.Config.Services.Registries.RegistryDelete(repo, name)
|
err := server.Config.Services.Registries.RegistryDelete(repo, name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.String(http.StatusInternalServerError, "Error deleting registry %q. %s", name, err)
|
handleDbGetError(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
c.String(http.StatusNoContent, "")
|
c.String(http.StatusNoContent, "")
|
||||||
|
|
|
@ -133,7 +133,7 @@ func DeleteSecret(c *gin.Context) {
|
||||||
name = c.Param("secret")
|
name = c.Param("secret")
|
||||||
)
|
)
|
||||||
if err := server.Config.Services.Secrets.SecretDelete(repo, name); err != nil {
|
if err := server.Config.Services.Secrets.SecretDelete(repo, name); err != nil {
|
||||||
c.String(http.StatusInternalServerError, "Error deleting secret %q. %s", name, err)
|
handleDbGetError(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
c.String(http.StatusNoContent, "")
|
c.String(http.StatusNoContent, "")
|
||||||
|
|
|
@ -47,6 +47,5 @@ func (s storage) AgentUpdate(agent *model.Agent) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s storage) AgentDelete(agent *model.Agent) error {
|
func (s storage) AgentDelete(agent *model.Agent) error {
|
||||||
_, err := s.engine.ID(agent.ID).Delete(new(model.Agent))
|
return wrapDelete(s.engine.ID(agent.ID).Delete(new(model.Agent)))
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,8 +47,7 @@ func (s storage) CronUpdate(_ *model.Repo, cron *model.Cron) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s storage) CronDelete(repo *model.Repo, id int64) error {
|
func (s storage) CronDelete(repo *model.Repo, id int64) error {
|
||||||
_, err := s.engine.ID(id).Where("repo_id = ?", repo.ID).Delete(new(model.Cron))
|
return wrapDelete(s.engine.ID(id).Where("repo_id = ?", repo.ID).Delete(new(model.Cron)))
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// CronListNextExecute returns limited number of jobs with NextExec being less or equal to the provided unix timestamp
|
// CronListNextExecute returns limited number of jobs with NextExec being less or equal to the provided unix timestamp
|
||||||
|
|
|
@ -28,3 +28,14 @@ func wrapGet(exist bool, err error) error {
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// wrapDelete return error if err not nil or if requested entry do not exist
|
||||||
|
func wrapDelete(c int64, err error) error {
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if c == 0 {
|
||||||
|
return types.RecordNotExist
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
|
@ -76,10 +76,9 @@ func (s storage) permUpsert(sess *xorm.Session, perm *model.Perm) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s storage) PermDelete(perm *model.Perm) error {
|
func (s storage) PermDelete(perm *model.Perm) error {
|
||||||
_, err := s.engine.
|
return wrapDelete(s.engine.
|
||||||
Where("perm_user_id = ? AND perm_repo_id = ?", perm.UserID, perm.RepoID).
|
Where("perm_user_id = ? AND perm_repo_id = ?", perm.UserID, perm.RepoID).
|
||||||
Delete(new(model.Perm))
|
Delete(new(model.Perm)))
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s storage) PermFlush(user *model.User, before int64) error {
|
func (s storage) PermFlush(user *model.User, before int64) error {
|
||||||
|
|
|
@ -57,8 +57,7 @@ func (s storage) SecretUpdate(secret *model.Secret) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s storage) SecretDelete(secret *model.Secret) error {
|
func (s storage) SecretDelete(secret *model.Secret) error {
|
||||||
_, err := s.engine.ID(secret.ID).Delete(new(model.Secret))
|
return wrapDelete(s.engine.ID(secret.ID).Delete(new(model.Secret)))
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s storage) OrgSecretFind(owner, name string) (*model.Secret, error) {
|
func (s storage) OrgSecretFind(owner, name string) (*model.Secret, error) {
|
||||||
|
|
|
@ -41,6 +41,5 @@ func (s storage) ServerConfigDelete(key string) error {
|
||||||
Key: key,
|
Key: key,
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err := s.engine.Delete(config)
|
return wrapDelete(s.engine.Delete(config))
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,5 @@ func (s storage) TaskInsert(task *model.Task) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s storage) TaskDelete(id string) error {
|
func (s storage) TaskDelete(id string) error {
|
||||||
_, err := s.engine.Where("task_id = ?", id).Delete(new(model.Task))
|
return wrapDelete(s.engine.Where("task_id = ?", id).Delete(new(model.Task)))
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,7 @@ func (s storage) DeleteUser(user *model.User) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := sess.ID(user.ID).Delete(new(model.User)); err != nil {
|
if err := wrapDelete(sess.ID(user.ID).Delete(new(model.User))); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue