Skip to content

Commit

Permalink
checkpoint
Browse files Browse the repository at this point in the history
Signed-off-by: Jeff Ortel <[email protected]>
  • Loading branch information
jortel committed Jul 18, 2024
1 parent 5b44666 commit 9f3b406
Showing 1 changed file with 47 additions and 25 deletions.
72 changes: 47 additions & 25 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"time"

"github.com/gin-gonic/gin/binding"
"github.com/konveyor/tackle2-addon-analyzer/builder"
"github.com/konveyor/tackle2-addon/ssh"
hub "github.com/konveyor/tackle2-hub/addon"
"github.com/konveyor/tackle2-hub/api"
Expand Down Expand Up @@ -115,31 +116,11 @@ func main() {
// RuleError
ruleErr := issues.RuleError()
ruleErr.Report()
if !d.Mode.Discovery {
//
// Post report.
appAnalysis := addon.Application.Analysis(application.ID)
mark := time.Now()
analysis := &api.Analysis{}
err = appAnalysis.Create(
analysis,
binding.MIMEYAML,
issues.Reader(),
deps.Reader())
if err != nil {
return
}
addon.Activity("Analysis reported. duration: %s", time.Since(mark))
//
// Facts
facts := addon.Application.Facts(application.ID)
facts.Source(Source)
err = facts.Replace(issues.Facts())
if err == nil {
addon.Activity("Facts updated.")
} else {
return
}
//
// Update application.
err = updateApplication(d, application.ID, issues, deps)
if err != nil {
return
}
//
// Tags.
Expand All @@ -158,3 +139,44 @@ func main() {
return
})
}

// updateApplication creates analysis report and updates
// the application facts and tags.
func updateApplication(d *Data, appId uint, issues *builder.Issues, deps *builder.Deps) (err error) {
//
// Tags.
if d.Tagger.Enabled {
if d.Tagger.Source == "" {
d.Tagger.Source = Source
}
err = d.Tagger.Update(appId, issues.Tags())
if err != nil {
return
}
}
if d.Mode.Discovery {
return
}
//
// Analysis.
appAnalysis := addon.Application.Analysis(appId)
mark := time.Now()
analysis := &api.Analysis{}
err = appAnalysis.Create(
analysis,
binding.MIMEYAML,
issues.Reader(),
deps.Reader())
if err != nil {
return
}
addon.Activity("Analysis reported. duration: %s", time.Since(mark))
// Facts.
facts := addon.Application.Facts(appId)
facts.Source(Source)
err = facts.Replace(issues.Facts())
if err == nil {
addon.Activity("Facts updated.")
}
return
}

0 comments on commit 9f3b406

Please sign in to comment.