database

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2026 License: AGPL-3.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	URIEnvVariableName string = "UDASH_DB_URI"
)

Variables

Functions

func Connect

func Connect(o Options) error

func DeleteConfigResource added in v0.10.0

func DeleteConfigResource(ctx context.Context, resourceType string, id string) error

DeleteConfigResource deletes a resource configuration from the database.

func DeleteReport added in v0.10.0

func DeleteReport(ctx context.Context, id string) error

DeleteReport deletes a report from the database.

func GetConditionConfigs added in v0.10.0

func GetConditionConfigs(ctx context.Context, kind, id, config string, limit, page int) ([]model.ConfigCondition, int, error)

GetConditionConfigs returns a list of resource configurations from the database.

func GetConfigKind added in v0.10.0

func GetConfigKind(ctx context.Context, resourceType string) ([]string, error)

GetConfigKind returns a list of resource configurations from the database filtered by kind.

func GetLabelKeyOnlyRecords added in v0.14.0

func GetLabelKeyOnlyRecords(ctx context.Context, startTime, endTime string, limit, page int) ([]string, int, error)

GetLabelKeyOnlyRecords returns a list of labels from the labels database table.

func GetLabelRecords added in v0.14.0

func GetLabelRecords(ctx context.Context, id, key, value, startTime, endTime string, limit, page int) ([]model.Label, int, error)

GetLabelRecords returns a list of labels from the labels database table.

func GetSCM added in v0.10.0

func GetSCM(ctx context.Context, id, url, branch string, limit, page int) ([]model.SCM, int, error)

GetSCM returns a list of scms from the scm database table.

func GetSourceConfigs added in v0.10.0

func GetSourceConfigs(ctx context.Context, kind, id, config string, limit, page int) ([]model.ConfigSource, int, error)

GetSourceConfigs returns a list of resource configurations from the database.

func GetTargetConfigs added in v0.10.0

func GetTargetConfigs(ctx context.Context, kind, id, config string, limit, page int) ([]model.ConfigTarget, int, error)

GetTargetConfigs returns a list of resource configurations from the database.

func InitLabels added in v0.14.0

func InitLabels(ctx context.Context, labels map[string]string) ([]uuid.UUID, error)

InitLabels takes a map of labels and ensures that they exist in the database, creating them if necessary.

func InsertConfigResource added in v0.10.0

func InsertConfigResource(ctx context.Context, resourceType, resourceKind string, resourceConfig interface{}) (string, error)

InsertConfigResource inserts a new resource configuration into the database.

func InsertLabel added in v0.14.0

func InsertLabel(ctx context.Context, key, value string) (string, error)

InsertLabel creates a new label and inserts it into the database.

It returns the ID of the newly created label.

func InsertReport added in v0.10.0

func InsertReport(ctx context.Context, report reports.Report) (string, error)

InsertReport inserts a new report into the database.

func InsertSCM added in v0.10.0

func InsertSCM(ctx context.Context, url, branch string) (string, error)

InsertSCM creates a new SCM and inserts it into the database.

It returns the ID of the newly created SCM.

func RunMigrationUp

func RunMigrationUp() error

func SearchLatestReportByPipelineID added in v0.10.0

func SearchLatestReportByPipelineID(ctx context.Context, id string) (*model.PipelineReport, error)

SearchLatestReportByPipelineID searches the latest report for a specific pipeline id.

func SearchNumberOfReportsByPipelineID added in v0.10.0

func SearchNumberOfReportsByPipelineID(ctx context.Context, id string) (int, error)

SearchNumberOfReportsByPipelineID searches the number of reports for a specific pipeline id.

func SearchReport added in v0.10.0

func SearchReport(ctx context.Context, id string) (*model.PipelineReport, error)

SearchReport searches a report by its database record id.

Types

type GetSCMSummaryParams added in v0.14.0

type GetSCMSummaryParams struct {
	MonitoringDurationDays int
	StartTime              string
	EndTime                string
	Labels                 map[string]string
	TotalCount             int
	Ctx                    context.Context
	ScmRows                []model.SCM
}

type Options

type Options struct {
	// URI defines the DB URI
	URI               string
	MigrationDisabled bool
}

type ReportSearchOptions added in v0.10.0

type ReportSearchOptions struct {
	// Days is the how far to look back for reports from today.
	Days int
}

ReportSearchOptions contains options for searching reports.

type SCMBranchDataset added in v0.10.0

type SCMBranchDataset map[string]ScmSummaryData

SCMBranchDataset represents a map of branches and their summary data for a single SCM URL.

type SCMDataset added in v0.10.0

type SCMDataset struct {
	Data map[string]SCMBranchDataset `json:"data"`
}

SCMDataset represents the response for the FindSCMSummary endpoint.

func GetSCMSummary added in v0.10.0

func GetSCMSummary(params GetSCMSummaryParams) (*SCMDataset, error)

GetSCMSummary returns a list of scms summary from the scm database table.

type ScmSummaryData added in v0.10.0

type ScmSummaryData struct {
	// ID is the unique identifier of the SCM.
	ID string `json:"id"`
	// TotalResultByType is a map of result types and their counts.
	TotalResultByType map[string]int `json:"total_result_by_type"`
	// TotalResult is the total number of results for this SCM.
	TotalResult int `json:"total_result"`
}

ScmSummaryData represents the summary data for a single SCM.

type SearchLatestReportData added in v0.10.0

type SearchLatestReportData struct {
	// ID represents the unique identifier of the report.
	ID string
	// Name represents the name of the report.
	Name string
	// Result represents the result of the report.
	Result string
	// Report contains the report data.
	Report reports.Report
	// FilteredResourceID contains the resource config ID that was filtered
	// It allows to identify in the report which resource was used to filter the report.
	FilteredResourceID string
	// CreatedAt represents the creation date of the report.
	CreatedAt string
	// UpdatedAt represents the last update date of the report.
	UpdatedAt string
}

SearchLatestReportData represents a report.

func SearchLatestReports added in v0.13.0

func SearchLatestReports(params SearchLatestReportsParams) ([]SearchLatestReportData, int, error)

SearchLatestReports searches the latest reports according some parameters.

type SearchLatestReportsParams added in v0.14.0

type SearchLatestReportsParams struct {
	Ctx         context.Context
	ScmID       string
	SourceID    string
	ConditionID string
	TargetID    string
	Options     ReportSearchOptions
	StartTime   string
	EndTime     string
	Limit       int
	Page        int
	Latest      bool
	Labels      map[string]string
}

Jump to

Keyboard shortcuts

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