-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
✨ Kai support #631
Merged
Merged
✨ Kai support #631
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -197,6 +197,7 @@ version: 8 | |
# | ||
file=${aPath} | ||
echo -n "--- | ||
commit: "42b22a90" | ||
issues: | ||
dependencies: | ||
" > ${file} | ||
|
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 v14 | ||
|
||
import ( | ||
"github.com/jortel/go-utils/logr" | ||
"github.com/konveyor/tackle2-hub/migration/v14/model" | ||
"gorm.io/gorm" | ||
) | ||
|
||
var log = logr.WithName("migration|v13") | ||
|
||
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,157 @@ | ||
package model | ||
|
||
import "gorm.io/gorm" | ||
|
||
// Analysis report. | ||
type Analysis struct { | ||
Model | ||
Effort int | ||
Commit string | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hint: adds commit. |
||
Archived bool | ||
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"` | ||
} | ||
|
||
// RuleSet - Analysis ruleset. | ||
type RuleSet struct { | ||
Model | ||
UUID *string `gorm:"uniqueIndex"` | ||
Kind string | ||
Name string `gorm:"uniqueIndex;not null"` | ||
Description string | ||
Repository JSON `gorm:"type:json"` | ||
IdentityID *uint `gorm:"index"` | ||
Identity *Identity | ||
Rules []Rule `gorm:"constraint:OnDelete:CASCADE"` | ||
DependsOn []RuleSet `gorm:"many2many:RuleSetDependencies;constraint:OnDelete:CASCADE"` | ||
} | ||
|
||
func (r *RuleSet) Builtin() bool { | ||
return r.UUID != nil | ||
} | ||
|
||
// BeforeUpdate hook to avoid cyclic dependencies. | ||
func (r *RuleSet) BeforeUpdate(db *gorm.DB) (err error) { | ||
seen := make(map[uint]bool) | ||
var nextDeps []RuleSet | ||
var nextRuleSetIDs []uint | ||
for _, dep := range r.DependsOn { | ||
nextRuleSetIDs = append(nextRuleSetIDs, dep.ID) | ||
} | ||
for len(nextRuleSetIDs) != 0 { | ||
result := db.Preload("DependsOn").Where("ID IN ?", nextRuleSetIDs).Find(&nextDeps) | ||
if result.Error != nil { | ||
err = result.Error | ||
return | ||
} | ||
nextRuleSetIDs = nextRuleSetIDs[:0] | ||
for _, nextDep := range nextDeps { | ||
for _, dep := range nextDep.DependsOn { | ||
if seen[dep.ID] { | ||
continue | ||
} | ||
if dep.ID == r.ID { | ||
err = DependencyCyclicError{} | ||
return | ||
} | ||
seen[dep.ID] = true | ||
nextRuleSetIDs = append(nextRuleSetIDs, dep.ID) | ||
} | ||
} | ||
} | ||
|
||
return | ||
} | ||
|
||
// Rule - Analysis rule. | ||
type Rule struct { | ||
Model | ||
Name string | ||
Description string | ||
Labels JSON `gorm:"type:json"` | ||
RuleSetID uint `gorm:"uniqueIndex:RuleA;not null"` | ||
RuleSet *RuleSet | ||
FileID *uint `gorm:"uniqueIndex:RuleA" ref:"file"` | ||
File *File | ||
} | ||
|
||
// Target - analysis rule selector. | ||
type Target struct { | ||
Model | ||
UUID *string `gorm:"uniqueIndex"` | ||
Name string `gorm:"uniqueIndex;not null"` | ||
Description string | ||
Provider string | ||
Choice bool | ||
Labels JSON `gorm:"type:json"` | ||
ImageID uint `gorm:"index" ref:"file"` | ||
Image *File | ||
RuleSetID *uint `gorm:"index"` | ||
RuleSet *RuleSet | ||
} | ||
|
||
func (r *Target) Builtin() bool { | ||
return r.UUID != nil | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
log message needs to be updated to v14