Documentation
¶
Index ¶
- Variables
- func WithCheckSlug(checkSlug string) func(db *gorm.DB) *gorm.DB
- func WithComponentID(componentID uuid.UUID) func(db *gorm.DB) *gorm.DB
- func WithLatestPerCheck() func(db *gorm.DB) *gorm.DB
- func WithOrderByTimestamp() func(db *gorm.DB) *gorm.DB
- func WithPagination(limit, offset int) func(db *gorm.DB) *gorm.DB
- func WithPreloads() func(db *gorm.DB) *gorm.DB
- func WithSince(since time.Time) func(db *gorm.DB) *gorm.DB
- func WithStatus(status CheckStatus) func(db *gorm.DB) *gorm.DB
- type Check
- type CheckReport
- type CheckStatus
- type Component
- type Config
- type CreateCheckReportInput
- type JSONB
- func (j JSONB) Delete(key string)
- func (j JSONB) Get(key string) (interface{}, bool)
- func (j JSONB) GormDBDataType(db *gorm.DB, field *schema.Field) string
- func (j JSONB) GormDataType() string
- func (j JSONB) Has(key string) bool
- func (j JSONB) Keys() []string
- func (j *JSONB) Scan(value interface{}) error
- func (j JSONB) Set(key string, value interface{})
- func (j JSONB) Value() (driver.Value, error)
- type Repository
- func (r *Repository) CreateCheck(ctx context.Context, check Check) error
- func (r *Repository) CreateCheckReportFromSubmission(ctx context.Context, input CreateCheckReportInput) (uuid.UUID, error)
- func (r *Repository) CreateComponent(ctx context.Context, component Component) error
- func (r *Repository) GetCheckBySlug(ctx context.Context, slug string) (*Check, error)
- func (r *Repository) GetCheckReportsForComponentWithPagination(ctx context.Context, componentID string, status *CheckStatus, ...) ([]CheckReport, int64, error)
- func (r *Repository) GetComponentByID(ctx context.Context, componentID string) (*Component, error)
- func (r *Repository) GetComponents(ctx context.Context) ([]Component, error)
- func (r *Repository) GetComponentsByTeam(ctx context.Context, team string) ([]Component, error)
- func (r *Repository) GetOrCreateCheckBySlug(ctx context.Context, slug string, name *string, description *string) (uuid.UUID, error)
- func (r *Repository) HealthCheck(ctx context.Context) error
- func (r *Repository) Migrate(ctx context.Context) error
- func (r *Repository) Name() string
- type StringArray
- func (sa StringArray) Contains(value string) bool
- func (sa StringArray) ContainsAny(values []string) bool
- func (sa StringArray) GormDBDataType(db *gorm.DB, field *schema.Field) string
- func (sa StringArray) GormDataType() string
- func (sa *StringArray) Scan(value interface{}) error
- func (sa StringArray) Value() (driver.Value, error)
Constants ¶
This section is empty.
Variables ¶
var ErrCheckNotFound = errors.New("check not found")
ErrCheckNotFound is returned when a check is not found
var ErrComponentNotFound = errors.New("component not found")
ErrComponentNotFound is returned when a component is not found
Functions ¶
func WithCheckSlug ¶
WithCheckSlug scope filters by check slug
func WithComponentID ¶
WithComponentID scope filters by component ID
func WithLatestPerCheck ¶
WithLatestPerCheck scope applies latest per check logic For PostgreSQL, uses DISTINCT ON; for SQLite, uses a subquery approach
func WithOrderByTimestamp ¶
WithOrderByTimestamp scope orders by timestamp descending
func WithPagination ¶
WithPagination scope applies pagination
func WithPreloads ¶
WithPreloads scope adds necessary preloads
func WithStatus ¶
func WithStatus(status CheckStatus) func(db *gorm.DB) *gorm.DB
WithStatus scope filters by check status
Types ¶
type Check ¶
type Check struct { ID uuid.UUID `gorm:"type:uuid;primaryKey"` Slug string `gorm:"not null;uniqueIndex;size:100"` Name string `gorm:"not null;size:255"` Description string `gorm:"type:text"` CreatedAt time.Time `gorm:"autoCreateTime"` UpdatedAt time.Time `gorm:"autoUpdateTime"` }
Check represents a quality check that can be performed on components
type CheckReport ¶
type CheckReport struct { ID uuid.UUID `gorm:"type:uuid;primaryKey"` CheckID uuid.UUID `gorm:"type:uuid;not null;index:idx_check_timestamp"` ComponentID uuid.UUID `gorm:"type:uuid;not null;index:idx_component_check"` Status CheckStatus `gorm:"type:varchar(20);not null;index:idx_check_status"` Timestamp time.Time `gorm:"not null;index:idx_check_timestamp"` Details JSONB `gorm:"type:jsonb"` Metadata JSONB `gorm:"type:jsonb"` CreatedAt time.Time `gorm:"autoCreateTime"` UpdatedAt time.Time `gorm:"autoUpdateTime"` // Relationships Check Check Component Component }
CheckReport represents a report of a check execution on a component
func (*CheckReport) BeforeCreate ¶
func (cr *CheckReport) BeforeCreate(tx *gorm.DB) (err error)
type CheckStatus ¶
type CheckStatus string
CheckStatus represents the status of a check execution
const ( CheckStatusPass CheckStatus = "pass" CheckStatusFail CheckStatus = "fail" CheckStatusDisabled CheckStatus = "disabled" CheckStatusSkipped CheckStatus = "skipped" CheckStatusUnknown CheckStatus = "unknown" CheckStatusError CheckStatus = "error" CheckStatusCompleted CheckStatus = "completed" )
type Component ¶
type Component struct { ID uuid.UUID `gorm:"type:uuid;primaryKey"` ComponentID string `gorm:"not null;uniqueIndex"` // Unique identifier from manifest Name string `gorm:"not null"` Description string Maintainers StringArray `gorm:"type:jsonb"` Team string // Relationships CheckReports []CheckReport }
Component represents a component stored in the database.
type Config ¶
type CreateCheckReportInput ¶
type CreateCheckReportInput struct { ComponentID string CheckSlug string CheckName *string CheckDescription *string Status CheckStatus Timestamp time.Time Details JSONB Metadata JSONB }
CreateCheckReportInput represents the input data for creating a check report
type JSONB ¶
type JSONB map[string]interface{}
JSONB is a custom type to handle PostgreSQL JSONB fields This allows for flexible storage of JSON data with powerful querying capabilities using PostgreSQL's JSONB operators and functions
func (JSONB) GormDBDataType ¶
GormDBDataType implements GormDBDataTypeInterface
func (JSONB) GormDataType ¶
GormDataType implements GormDataTypeInterface
type Repository ¶
func ConnectAndMigrate ¶
func ConnectAndMigrate(ctx context.Context, dsn string) (*Repository, error)
func (*Repository) CreateCheck ¶
func (r *Repository) CreateCheck(ctx context.Context, check Check) error
func (*Repository) CreateCheckReportFromSubmission ¶
func (r *Repository) CreateCheckReportFromSubmission(ctx context.Context, input CreateCheckReportInput) (uuid.UUID, error)
CreateCheckReportFromSubmission creates a check report from API submission data
func (*Repository) CreateComponent ¶
func (r *Repository) CreateComponent(ctx context.Context, component Component) error
CreateComponent creates a new component
func (*Repository) GetCheckBySlug ¶
Check methods - only what's needed for handlers
func (*Repository) GetCheckReportsForComponentWithPagination ¶
func (r *Repository) GetCheckReportsForComponentWithPagination(ctx context.Context, componentID string, status *CheckStatus, checkSlug *string, since *time.Time, limit int, offset int, latestPerCheck bool) ([]CheckReport, int64, error)
GetCheckReportsForComponentWithPagination retrieves check reports for a component with database-level filtering, pagination, and latest per check
func (*Repository) GetComponentByID ¶
GetComponentByID returns a component by its unique identifier
func (*Repository) GetComponents ¶
func (r *Repository) GetComponents(ctx context.Context) ([]Component, error)
Component methods
func (*Repository) GetComponentsByTeam ¶
GetComponentsByTeam returns all components owned by a specific team
func (*Repository) GetOrCreateCheckBySlug ¶
func (r *Repository) GetOrCreateCheckBySlug(ctx context.Context, slug string, name *string, description *string) (uuid.UUID, error)
GetOrCreateCheckBySlug auto-creates a check if it doesn't exist, returns CheckID
func (*Repository) HealthCheck ¶
func (r *Repository) HealthCheck(ctx context.Context) error
HealthCheck implements the health.Checker interface
func (*Repository) Name ¶
func (r *Repository) Name() string
type StringArray ¶
type StringArray []string
StringArray is a custom type to handle PostgreSQL JSONB arrays This allows for powerful querying capabilities using PostgreSQL's JSONB operators: - ? : Check if a string exists in the array - ?| : Check if any of the strings exist in the array - ?& : Check if all of the strings exist in the array Example queries:
WHERE maintainers ? 'alice@company.com' -- Find components maintained by alice WHERE maintainers ?| '["alice@company.com", "bob@company.com"]' -- Find components maintained by either alice or bob WHERE maintainers ?& '["alice@company.com", "bob@company.com"]' -- Find components maintained by both alice and bob
func (StringArray) Contains ¶
func (sa StringArray) Contains(value string) bool
Contains checks if the array contains a specific string
func (StringArray) ContainsAny ¶
func (sa StringArray) ContainsAny(values []string) bool
ContainsAny checks if the array contains any of the provided strings
func (StringArray) GormDBDataType ¶
GormDBDataType implements GormDBDataTypeInterface
func (StringArray) GormDataType ¶
func (sa StringArray) GormDataType() string
GormDataType implements GormDataTypeInterface
func (*StringArray) Scan ¶
func (sa *StringArray) Scan(value interface{}) error
Scan implements sql.Scanner interface for database retrieval