model

package
v0.5.0-beta.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 16, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Settings = &settings.Settings
)

Functions

func All

func All() []any

All builds all models. Models are enumerated such that each are listed after all the other models on which they may depend.

Types

type Analysis

type Analysis struct {
	Model
	Effort        int
	Issues        []Issue          `gorm:"constraint:OnDelete:CASCADE"`
	Dependencies  []TechDependency `gorm:"constraint:OnDelete:CASCADE"`
	ApplicationID uint             `gorm:"index;not null"`
	Application   *Application
}

Analysis report.

type Application

type Application struct {
	Model
	BucketOwner
	Name              string `gorm:"index;unique;not null"`
	Description       string
	Review            *Review `gorm:"constraint:OnDelete:CASCADE"`
	Repository        JSON    `gorm:"type:json"`
	Binary            string
	Facts             []Fact `gorm:"constraint:OnDelete:CASCADE"`
	Comments          string
	Tasks             []Task     `gorm:"constraint:OnDelete:CASCADE"`
	Tags              []Tag      `gorm:"many2many:ApplicationTags"`
	Identities        []Identity `gorm:"many2many:ApplicationIdentity;constraint:OnDelete:CASCADE"`
	BusinessServiceID *uint      `gorm:"index"`
	BusinessService   *BusinessService
	OwnerID           *uint         `gorm:"index"`
	Owner             *Stakeholder  `gorm:"foreignKey:OwnerID"`
	Contributors      []Stakeholder `gorm:"many2many:ApplicationContributors;constraint:OnDelete:CASCADE"`
	Analyses          []Analysis    `gorm:"constraint:OnDelete:CASCADE"`
	MigrationWaveID   *uint         `gorm:"index"`
	MigrationWave     *MigrationWave
	Ticket            *Ticket      `gorm:"constraint:OnDelete:CASCADE"`
	Assessments       []Assessment `gorm:"constraint:OnDelete:CASCADE"`
}

type ApplicationTag

type ApplicationTag struct {
	ApplicationID uint        `gorm:"primaryKey"`
	TagID         uint        `gorm:"primaryKey"`
	Source        string      `gorm:"primaryKey;not null"`
	Application   Application `gorm:"constraint:OnDelete:CASCADE"`
	Tag           Tag         `gorm:"constraint:OnDelete:CASCADE"`
}

ApplicationTag represents a row in the join table for the many-to-many relationship between Applications and Tags.

func (ApplicationTag) TableName

func (ApplicationTag) TableName() string

TableName must return "ApplicationTags" to ensure compatibility with the autogenerated join table name.

type Archetype

type Archetype struct {
	Model
	Name              string
	Description       string
	Comments          string
	Review            *Review            `gorm:"constraint:OnDelete:CASCADE"`
	Assessments       []Assessment       `gorm:"constraint:OnDelete:CASCADE"`
	CriteriaTags      []Tag              `gorm:"many2many:ArchetypeCriteriaTags;constraint:OnDelete:CASCADE"`
	Tags              []Tag              `gorm:"many2many:ArchetypeTags;constraint:OnDelete:CASCADE"`
	Stakeholders      []Stakeholder      `gorm:"many2many:ArchetypeStakeholders;constraint:OnDelete:CASCADE"`
	StakeholderGroups []StakeholderGroup `gorm:"many2many:ArchetypeStakeholderGroups;constraint:OnDelete:CASCADE"`
}

type Assessment

type Assessment struct {
	Model
	ApplicationID     *uint `gorm:"uniqueIndex:AssessmentA"`
	Application       *Application
	ArchetypeID       *uint `gorm:"uniqueIndex:AssessmentB"`
	Archetype         *Archetype
	QuestionnaireID   uint `gorm:"uniqueIndex:AssessmentA;uniqueIndex:AssessmentB"`
	Questionnaire     Questionnaire
	Sections          JSON               `gorm:"type:json"`
	Thresholds        JSON               `gorm:"type:json"`
	RiskMessages      JSON               `gorm:"type:json"`
	Stakeholders      []Stakeholder      `gorm:"many2many:AssessmentStakeholders;constraint:OnDelete:CASCADE"`
	StakeholderGroups []StakeholderGroup `gorm:"many2many:AssessmentStakeholderGroups;constraint:OnDelete:CASCADE"`
}

type Bucket

type Bucket struct {
	Model
	Path       string `gorm:"<-:create;uniqueIndex"`
	Expiration *time.Time
}

func (*Bucket) BeforeCreate

func (m *Bucket) BeforeCreate(db *gorm.DB) (err error)

type BucketOwner

type BucketOwner struct {
	BucketID *uint `gorm:"index" ref:"bucket"`
	Bucket   *Bucket
}

func (*BucketOwner) BeforeCreate

func (m *BucketOwner) BeforeCreate(db *gorm.DB) (err error)

func (*BucketOwner) HasBucket

func (m *BucketOwner) HasBucket() (b bool)

func (*BucketOwner) SetBucket

func (m *BucketOwner) SetBucket(id *uint)

type BusinessService

type BusinessService struct {
	Model
	Name          string `gorm:"index;unique;not null"`
	Description   string
	Applications  []Application `gorm:"constraint:OnDelete:SET NULL"`
	StakeholderID *uint         `gorm:"index"`
	Stakeholder   *Stakeholder
}

type Dependency

type Dependency struct {
	Model
	ToID   uint         `gorm:"index"`
	To     *Application `gorm:"foreignKey:ToID;constraint:OnDelete:CASCADE"`
	FromID uint         `gorm:"index"`
	From   *Application `gorm:"foreignKey:FromID;constraint:OnDelete:CASCADE"`
}

func (*Dependency) BeforeCreate

func (r *Dependency) BeforeCreate(db *gorm.DB) (err error)

Validation Hook to avoid cyclic dependencies.

func (*Dependency) Create

func (r *Dependency) Create(db *gorm.DB) (err error)

Create a dependency synchronized using a mutex.

type DependencyCyclicError

type DependencyCyclicError struct{}

Custom error type to allow API recognize Cyclic Dependency error and assign proper status code.

func (DependencyCyclicError) Error

func (err DependencyCyclicError) Error() string

type Fact

type Fact struct {
	ApplicationID uint   `gorm:"<-:create;primaryKey"`
	Key           string `gorm:"<-:create;primaryKey"`
	Source        string `gorm:"<-:create;primaryKey;not null"`
	Value         JSON   `gorm:"type:json;not null"`
	Application   *Application
}

type File

type File struct {
	Model
	Name       string
	Path       string `gorm:"<-:create;uniqueIndex"`
	Expiration *time.Time
}

func (*File) BeforeCreate

func (m *File) BeforeCreate(db *gorm.DB) (err error)

type Identity

type Identity struct {
	Model
	Kind        string `gorm:"not null"`
	Name        string `gorm:"index;unique;not null"`
	Description string
	User        string
	Password    string
	Key         string
	Settings    string
	Proxies     []Proxy `gorm:"constraint:OnDelete:SET NULL"`
}

Identity represents and identity with a set of credentials.

func (*Identity) Decrypt

func (r *Identity) Decrypt() (err error)

Decrypt sensitive fields.

func (*Identity) Encrypt

func (r *Identity) Encrypt(ref *Identity) (err error)

Encrypt sensitive fields. The ref identity is used to determine when sensitive fields have changed and need to be (re)encrypted.

type Import

type Import struct {
	Model
	Filename            string
	ApplicationName     string
	BusinessService     string
	Comments            string
	Dependency          string
	DependencyDirection string
	Description         string
	ErrorMessage        string
	IsValid             bool
	RecordType1         string
	ImportSummary       ImportSummary
	ImportSummaryID     uint `gorm:"index"`
	Processed           bool
	ImportTags          []ImportTag `gorm:"constraint:OnDelete:CASCADE"`
	BinaryGroup         string
	BinaryArtifact      string
	BinaryVersion       string
	BinaryPackaging     string
	RepositoryKind      string
	RepositoryURL       string
	RepositoryBranch    string
	RepositoryPath      string
}

func (*Import) AsMap

func (r *Import) AsMap() (m map[string]any)

type ImportSummary

type ImportSummary struct {
	Model
	Content        []byte
	Filename       string
	ImportStatus   string
	Imports        []Import `gorm:"constraint:OnDelete:CASCADE"`
	CreateEntities bool
}

type ImportTag

type ImportTag struct {
	Model
	Name     string
	Category string
	ImportID uint `gorm:"index"`
	Import   *Import
}

type 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
}

Incident report an issue incident.

type Issue

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
}

Issue report issue (violation).

type JSON

type JSON = []byte

JSON field (data) type.

type JobFunction

type JobFunction struct {
	Model
	UUID         *string `gorm:"uniqueIndex"`
	Username     string
	Name         string        `gorm:"index;unique;not null"`
	Stakeholders []Stakeholder `gorm:"constraint:OnDelete:SET NULL"`
}
type Link struct {
	URL   string `json:"url"`
	Title string `json:"title,omitempty"`
}

Link URL link.

type Map

type Map = map[string]any

Map alias.

type MigrationWave

type MigrationWave struct {
	Model
	Name              string             `gorm:"uniqueIndex:MigrationWaveA"`
	StartDate         time.Time          `gorm:"uniqueIndex:MigrationWaveA"`
	EndDate           time.Time          `gorm:"uniqueIndex:MigrationWaveA"`
	Applications      []Application      `gorm:"constraint:OnDelete:SET NULL"`
	Stakeholders      []Stakeholder      `gorm:"many2many:MigrationWaveStakeholders;constraint:OnDelete:CASCADE"`
	StakeholderGroups []StakeholderGroup `gorm:"many2many:MigrationWaveStakeholderGroups;constraint:OnDelete:CASCADE"`
}

type Model

type Model struct {
	ID         uint      `gorm:"<-:create;primaryKey"`
	CreateTime time.Time `gorm:"<-:create;autoCreateTime"`
	CreateUser string    `gorm:"<-:create"`
	UpdateUser string
}

Model Base model.

type Proxy

type Proxy struct {
	Model
	Enabled    bool
	Kind       string `gorm:"uniqueIndex"`
	Host       string `gorm:"not null"`
	Port       int
	Excluded   JSON  `gorm:"type:json"`
	IdentityID *uint `gorm:"index"`
	Identity   *Identity
}

Proxy configuration. kind = (http|https)

type Questionnaire

type Questionnaire struct {
	Model
	UUID         *string `gorm:"uniqueIndex"`
	Name         string  `gorm:"unique"`
	Description  string
	Required     bool
	Sections     JSON         `gorm:"type:json"`
	Thresholds   JSON         `gorm:"type:json"`
	RiskMessages JSON         `gorm:"type:json"`
	Assessments  []Assessment `gorm:"constraint:OnDelete:CASCADE"`
}

type Review

type Review struct {
	Model
	BusinessCriticality uint   `gorm:"not null"`
	EffortEstimate      string `gorm:"not null"`
	ProposedAction      string `gorm:"not null"`
	WorkPriority        uint   `gorm:"not null"`
	Comments            string
	ApplicationID       *uint `gorm:"uniqueIndex"`
	Application         *Application
	ArchetypeID         *uint `gorm:"uniqueIndex"`
	Archetype           *Archetype
}

type 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
}

Rule - Analysis rule.

type 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"`
}

RuleSet - Analysis ruleset.

func (*RuleSet) BeforeUpdate

func (r *RuleSet) BeforeUpdate(db *gorm.DB) (err error)

BeforeUpdate hook to avoid cyclic dependencies.

func (*RuleSet) Builtin

func (r *RuleSet) Builtin() bool

type Setting

type Setting struct {
	Model
	Key   string `gorm:"<-:create;uniqueIndex"`
	Value JSON   `gorm:"type:json"`
}

type Stakeholder

type Stakeholder struct {
	Model
	Name             string             `gorm:"not null;"`
	Email            string             `gorm:"index;unique;not null"`
	Groups           []StakeholderGroup `gorm:"many2many:StakeholderGroupStakeholder;constraint:OnDelete:CASCADE"`
	BusinessServices []BusinessService  `gorm:"constraint:OnDelete:SET NULL"`
	JobFunctionID    *uint              `gorm:"index"`
	JobFunction      *JobFunction
	Owns             []Application   `gorm:"foreignKey:OwnerID;constraint:OnDelete:SET NULL"`
	Contributes      []Application   `gorm:"many2many:ApplicationContributors;constraint:OnDelete:CASCADE"`
	MigrationWaves   []MigrationWave `gorm:"many2many:MigrationWaveStakeholders;constraint:OnDelete:CASCADE"`
	Assessments      []Assessment    `gorm:"many2many:AssessmentStakeholders;constraint:OnDelete:CASCADE"`
	Archetypes       []Archetype     `gorm:"many2many:ArchetypeStakeholders;constraint:OnDelete:CASCADE"`
}

type StakeholderGroup

type StakeholderGroup struct {
	Model
	Name           string `gorm:"index;unique;not null"`
	Username       string
	Description    string
	Stakeholders   []Stakeholder   `gorm:"many2many:StakeholderGroupStakeholder;constraint:OnDelete:CASCADE"`
	MigrationWaves []MigrationWave `gorm:"many2many:MigrationWaveStakeholderGroups;constraint:OnDelete:CASCADE"`
	Assessments    []Assessment    `gorm:"many2many:AssessmentStakeholderGroups;constraint:OnDelete:CASCADE"`
	Archetypes     []Archetype     `gorm:"many2many:ArchetypeStakeholderGroups;constraint:OnDelete:CASCADE"`
}

type TTL

type TTL struct {
	Created   int `json:"created,omitempty"`
	Pending   int `json:"pending,omitempty"`
	Postponed int `json:"postponed,omitempty"`
	Running   int `json:"running,omitempty"`
	Succeeded int `json:"succeeded,omitempty"`
	Failed    int `json:"failed,omitempty"`
}

TTL time-to-live.

type Tag

type Tag struct {
	Model
	UUID       *string `gorm:"uniqueIndex"`
	Name       string  `gorm:"uniqueIndex:tagA;not null"`
	Username   string
	CategoryID uint `gorm:"uniqueIndex:tagA;index;not null"`
	Category   TagCategory
}

type TagCategory

type TagCategory struct {
	Model
	UUID     *string `gorm:"uniqueIndex"`
	Name     string  `gorm:"index;unique;not null"`
	Username string
	Rank     uint
	Color    string
	Tags     []Tag `gorm:"foreignKey:CategoryID;constraint:OnDelete:CASCADE"`
}

type Target

type Target struct {
	Model
	UUID        *string `gorm:"uniqueIndex"`
	Name        string  `gorm:"uniqueIndex;not null"`
	Description string
	Choice      bool
	Labels      JSON `gorm:"type:json"`
	ImageID     uint `gorm:"index" ref:"file"`
	Image       *File
	RuleSetID   *uint `gorm:"index"`
	RuleSet     *RuleSet
}

Target - analysis rule selector.

func (*Target) Builtin

func (r *Target) Builtin() bool

type Task

type Task struct {
	Model
	BucketOwner
	Name          string `gorm:"index"`
	Addon         string `gorm:"index"`
	Locator       string `gorm:"index"`
	Priority      int
	Image         string
	Variant       string
	Policy        string
	TTL           JSON
	Data          JSON
	Started       *time.Time
	Terminated    *time.Time
	State         string `gorm:"index"`
	Errors        JSON
	Pod           string `gorm:"index"`
	Retries       int
	Canceled      bool
	Report        *TaskReport `gorm:"constraint:OnDelete:CASCADE"`
	ApplicationID *uint
	Application   *Application
	TaskGroupID   *uint `gorm:"<-:create"`
	TaskGroup     *TaskGroup
}

func (*Task) BeforeCreate

func (m *Task) BeforeCreate(db *gorm.DB) (err error)

func (*Task) Error

func (m *Task) Error(severity, description string, x ...any)

Error appends an error.

func (*Task) Reset

func (m *Task) Reset()

type TaskError

type TaskError struct {
	Severity    string `json:"severity"`
	Description string `json:"description"`
}

TaskError used in Task.Errors.

type TaskGroup

type TaskGroup struct {
	Model
	BucketOwner
	Name  string
	Addon string
	Data  JSON
	Tasks []Task `gorm:"constraint:OnDelete:CASCADE"`
	List  JSON
	State string
}

func (*TaskGroup) Propagate

func (m *TaskGroup) Propagate() (err error)

Propagate group data into the task.

type TaskReport

type TaskReport struct {
	Model
	Status    string
	Errors    JSON
	Total     int
	Completed int
	Activity  JSON `gorm:"type:json"`
	Result    JSON `gorm:"type:json"`
	TaskID    uint `gorm:"<-:create;uniqueIndex"`
	Task      *Task
}

type TechDependency

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
}

TechDependency report dependency.

type Ticket

type Ticket struct {
	Model
	// Kind of ticket in the external tracker.
	Kind string `gorm:"not null"`
	// Parent resource that this ticket should belong to in the tracker. (e.g. Jira project)
	Parent string `gorm:"not null"`
	// Custom fields to send to the tracker when creating the ticket
	Fields JSON `gorm:"type:json"`
	// Whether the last attempt to do something with the ticket reported an error
	Error bool
	// Error message, if any
	Message string
	// Whether the ticket was created in the external tracker
	Created bool
	// Reference id in external tracker
	Reference string
	// URL to ticket in external tracker
	Link string
	// Status of ticket in external tracker
	Status        string
	LastUpdated   time.Time
	Application   *Application
	ApplicationID uint `gorm:"uniqueIndex:ticketA;not null"`
	Tracker       *Tracker
	TrackerID     uint `gorm:"uniqueIndex:ticketA;not null"`
}

type Tracker

type Tracker struct {
	Model
	Name        string `gorm:"index;unique;not null"`
	URL         string
	Kind        string
	Identity    *Identity
	IdentityID  uint
	Connected   bool
	LastUpdated time.Time
	Message     string
	Insecure    bool
	Tickets     []Ticket
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL