-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add analysis archiving. Adds (2) fields to the Analysis: - Archived (bool) - Summary JSON which contains the analysis summary when archived. When an analysis is created, all previously _unarchived_ (archived=FALSE) resources will be archived. There should not be more than one but the logic will do them all just to be sure. Archived is: - Summary is created. This is an array of archived issues. - Archived flag set. - Issues deleted (cascade delete incidents). - TechDependencies deleted. fixes: #428 --------- Signed-off-by: Jeff Ortel <jortel@redhat.com>
- Loading branch information
Showing
6 changed files
with
267 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package v10 | ||
|
||
import ( | ||
"github.com/jortel/go-utils/logr" | ||
"github.com/konveyor/tackle2-hub/migration/v10/model" | ||
"gorm.io/gorm" | ||
) | ||
|
||
var log = logr.WithName("migration|v9") | ||
|
||
type Migration struct{} | ||
|
||
func (r Migration) Apply(db *gorm.DB) (err error) { | ||
err = db.AutoMigrate(r.Models()...) | ||
return | ||
} | ||
|
||
func (r Migration) Models() []interface{} { | ||
return model.All() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package model | ||
|
||
// | ||
// Analysis report. | ||
type Analysis struct { | ||
Model | ||
Effort int | ||
Archived bool `json:"archived"` | ||
Summary JSON `gorm:"type:json"` | ||
Issues []Issue `gorm:"constraint:OnDelete:CASCADE"` | ||
Dependencies []TechDependency `gorm:"constraint:OnDelete:CASCADE"` | ||
ApplicationID uint `gorm:"index;not null"` | ||
Application *Application | ||
} | ||
|
||
// | ||
// TechDependency report dependency. | ||
type TechDependency struct { | ||
Model | ||
Provider string `gorm:"uniqueIndex:depA"` | ||
Name string `gorm:"uniqueIndex:depA"` | ||
Version string `gorm:"uniqueIndex:depA"` | ||
SHA string `gorm:"uniqueIndex:depA"` | ||
Indirect bool | ||
Labels JSON `gorm:"type:json"` | ||
AnalysisID uint `gorm:"index;uniqueIndex:depA;not null"` | ||
Analysis *Analysis | ||
} | ||
|
||
// | ||
// Issue report issue (violation). | ||
type Issue struct { | ||
Model | ||
RuleSet string `gorm:"uniqueIndex:issueA;not null"` | ||
Rule string `gorm:"uniqueIndex:issueA;not null"` | ||
Name string `gorm:"index"` | ||
Description string | ||
Category string `gorm:"index;not null"` | ||
Incidents []Incident `gorm:"foreignKey:IssueID;constraint:OnDelete:CASCADE"` | ||
Links JSON `gorm:"type:json"` | ||
Facts JSON `gorm:"type:json"` | ||
Labels JSON `gorm:"type:json"` | ||
Effort int `gorm:"index;not null"` | ||
AnalysisID uint `gorm:"index;uniqueIndex:issueA;not null"` | ||
Analysis *Analysis | ||
} | ||
|
||
// | ||
// Incident report an issue incident. | ||
type Incident struct { | ||
Model | ||
File string `gorm:"index;not null"` | ||
Line int | ||
Message string | ||
CodeSnip string | ||
Facts JSON `gorm:"type:json"` | ||
IssueID uint `gorm:"index;not null"` | ||
Issue *Issue | ||
} | ||
|
||
// | ||
// Link URL link. | ||
type Link struct { | ||
URL string `json:"url"` | ||
Title string `json:"title,omitempty"` | ||
} | ||
|
||
// | ||
// ArchivedIssue resource created when issues are archived. | ||
type ArchivedIssue struct { | ||
RuleSet string `json:"ruleSet"` | ||
Rule string `json:"rule"` | ||
Name string `json:"name,omitempty" yaml:",omitempty"` | ||
Description string `json:"description,omitempty" yaml:",omitempty"` | ||
Category string `json:"category"` | ||
Effort int `json:"effort"` | ||
Incidents int `json:"incidents"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
package model | ||
|
||
import "github.com/konveyor/tackle2-hub/migration/v9/model" | ||
|
||
// | ||
// JSON field (data) type. | ||
type JSON = []byte | ||
|
||
type Model = model.Model | ||
type Application = model.Application | ||
type Archetype = model.Archetype | ||
type Assessment = model.Assessment | ||
type Bucket = model.Bucket | ||
type BucketOwner = model.BucketOwner | ||
type BusinessService = model.BusinessService | ||
type Dependency = model.Dependency | ||
type File = model.File | ||
type Fact = model.Fact | ||
type Identity = model.Identity | ||
type Import = model.Import | ||
type ImportSummary = model.ImportSummary | ||
type ImportTag = model.ImportTag | ||
type JobFunction = model.JobFunction | ||
type MigrationWave = model.MigrationWave | ||
type Proxy = model.Proxy | ||
type Questionnaire = model.Questionnaire | ||
type Review = model.Review | ||
type Setting = model.Setting | ||
type RuleSet = model.RuleSet | ||
type Rule = model.Rule | ||
type Stakeholder = model.Stakeholder | ||
type StakeholderGroup = model.StakeholderGroup | ||
type Tag = model.Tag | ||
type TagCategory = model.TagCategory | ||
type Target = model.Target | ||
type Task = model.Task | ||
type TaskGroup = model.TaskGroup | ||
type TaskReport = model.TaskReport | ||
type Ticket = model.Ticket | ||
type Tracker = model.Tracker | ||
type TTL = model.TTL | ||
type ApplicationTag = model.ApplicationTag | ||
type DependencyCyclicError = model.DependencyCyclicError | ||
|
||
// | ||
// All builds all models. | ||
// Models are enumerated such that each are listed after | ||
// all the other models on which they may depend. | ||
func All() []interface{} { | ||
return []interface{}{ | ||
Application{}, | ||
TechDependency{}, | ||
Incident{}, | ||
Analysis{}, | ||
Issue{}, | ||
Bucket{}, | ||
BusinessService{}, | ||
Dependency{}, | ||
File{}, | ||
Fact{}, | ||
Identity{}, | ||
Import{}, | ||
ImportSummary{}, | ||
ImportTag{}, | ||
JobFunction{}, | ||
MigrationWave{}, | ||
Proxy{}, | ||
Review{}, | ||
Setting{}, | ||
RuleSet{}, | ||
Rule{}, | ||
Stakeholder{}, | ||
StakeholderGroup{}, | ||
Tag{}, | ||
TagCategory{}, | ||
Target{}, | ||
Task{}, | ||
TaskGroup{}, | ||
TaskReport{}, | ||
Ticket{}, | ||
Tracker{}, | ||
ApplicationTag{}, | ||
Questionnaire{}, | ||
Assessment{}, | ||
Archetype{}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters