Skip to content

Commit

Permalink
Fix bucket propagation.
Browse files Browse the repository at this point in the history
Signed-off-by: Jeff Ortel <jortel@redhat.com>
  • Loading branch information
jortel committed Jun 14, 2024
1 parent 35316c8 commit 94a8292
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
13 changes: 7 additions & 6 deletions api/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,16 +342,16 @@ func (h TaskHandler) Delete(ctx *gin.Context) {
// @param task body Task true "Task data"
func (h TaskHandler) Update(ctx *gin.Context) {
id := h.pk(ctx)
var m model.Task
err := h.DB(ctx).First(&m, id).Error
m := &model.Task{}
err := h.DB(ctx).First(m, id).Error
if err != nil {
_ = ctx.Error(err)
return
}
r := &Task{}
if ctx.Request.Method == http.MethodPatch &&
ctx.Request.ContentLength > 0 {
r.With(&m)
r.With(m)
}
err = h.Bind(ctx, r)
if err != nil {
Expand All @@ -361,11 +361,12 @@ func (h TaskHandler) Update(ctx *gin.Context) {
if _, found := ctx.Get(Submit); found {
r.State = tasking.Ready
}
r.ID = id
m = r.Model()
m.ID = id
m.UpdateUser = h.CurrentUser(ctx)
rtx := WithContext(ctx)
task := &tasking.Task{}
task.With(r.Model())
task.UpdateUser = h.BaseHandler.CurrentUser(ctx)
task.With(m)
err = rtx.TaskManager.Update(h.DB(ctx), task)
if err != nil {
_ = ctx.Error(err)
Expand Down
2 changes: 2 additions & 0 deletions api/taskgroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ func (h TaskGroupHandler) Update(ctx *gin.Context) {
"Bucket")
m = r.Model()
m.ID = id
m.UpdateUser = h.CurrentUser(ctx)
switch m.State {
case "", tasking.Created:
err = db.Save(m).Error
Expand Down Expand Up @@ -237,6 +238,7 @@ func (h TaskGroupHandler) Update(ctx *gin.Context) {
for i := range m.Tasks {
task := &tasking.Task{}
task.With(&m.Tasks[i])
task.CreateUser = h.CurrentUser(ctx)
err = rtx.TaskManager.Create(h.DB(ctx), task)
if err != nil {
_ = ctx.Error(err)
Expand Down
2 changes: 2 additions & 0 deletions task/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ func (m *Manager) Create(db *gorm.DB, requested *Task) (err error) {
task.TTL = requested.TTL
task.Data = requested.Data
task.ApplicationID = requested.ApplicationID
task.BucketID = requested.BucketID
default:
err = &BadRequest{
Reason: "state must be (Created|Ready)",
Expand Down Expand Up @@ -193,6 +194,7 @@ func (m *Manager) Update(db *gorm.DB, requested *Task) (err error) {
Postponed:
task.UpdateUser = requested.UpdateUser
task.Name = requested.Name
task.Locator = requested.Locator
task.Data = requested.Data
task.Priority = requested.Priority
task.Policy = requested.Policy
Expand Down

0 comments on commit 94a8292

Please sign in to comment.