Skip to content

Commit

Permalink
⚠️ Only trigger discovery tasks if the Application has a repository s…
Browse files Browse the repository at this point in the history
…pecified (konveyor#715)

Signed-off-by: Sam Lucidi <[email protected]>
  • Loading branch information
mansam authored Jul 11, 2024
1 parent 0e52e70 commit 5c139ac
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
8 changes: 8 additions & 0 deletions migration/v14/model/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,3 +296,11 @@ type ImportTag struct {
ImportID uint `gorm:"index"`
Import *Import
}

type Repository struct {
Kind string `json:"kind"`
URL string `json:"url"`
Branch string `json:"branch"`
Tag string `json:"tag"`
Path string `json:"path"`
}
1 change: 1 addition & 0 deletions model/pkg.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ type TaskError = model.TaskError
type TaskEvent = model.TaskEvent
type TaskPolicy = model.TaskPolicy
type Attachment = model.Attachment
type Repository = model.Repository

// Join tables
type ApplicationTag = model.ApplicationTag
Expand Down
5 changes: 4 additions & 1 deletion trigger/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,17 @@ func (r *Application) Updated(m *model.Application) (err error) {
if !Settings.Discovery.Enabled {
return
}
if len(m.Repository) == 0 || string(m.Repository) == "null" {
return
}
kinds, err := r.FindTasks(Settings.Discovery.Label)
if err != nil {
return
}
for _, kind := range kinds {
t := &tasking.Task{Task: &model.Task{}}
t.Kind = kind.Name
t.Name = fmt.Sprintf("%s-%s", m.Name, t.Name)
t.Name = fmt.Sprintf("%s-%s", m.Name, t.Kind)
t.ApplicationID = &m.ID
t.State = tasking.Ready
err = r.TaskManager.Create(r.DB, t)
Expand Down

0 comments on commit 5c139ac

Please sign in to comment.