database

package
v0.11.1 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2025 License: AGPL-3.0 Imports: 19 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.11.0

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

DeleteConfigResource deletes a resource configuration from the database.

func DeleteReport added in v0.11.0

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

DeleteReport deletes a report from the database.

func GetConditionConfigs added in v0.11.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.11.0

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

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

func GetSCM added in v0.11.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.11.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.11.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 InsertConfigResource added in v0.11.0

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

InsertConfigResource inserts a new resource configuration into the database.

func InsertReport added in v0.11.0

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

InsertReport inserts a new report into the database.

func InsertSCM added in v0.11.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.11.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.11.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.11.0

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

SearchReport searches a report by its database record id.

Types

type Options

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

type ReportSearchOptions added in v0.11.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.11.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.11.0

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

SCMDataset represents the response for the FindSCMSummary endpoint.

func GetSCMSummary added in v0.11.0

func GetSCMSummary(ctx context.Context, scmRows []model.SCM, totalCount, monitoringDurationDays int) (*SCMDataset, error)

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

type ScmSummaryData added in v0.11.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.11.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 SearchLatestReport added in v0.11.0

func SearchLatestReport(ctx context.Context, scmID, sourceID, conditionID, targetID string, options ReportSearchOptions, limit, page int) ([]SearchLatestReportData, int, error)

SearchLatestReport searches the latest reports according some parameters.

Jump to

Keyboard shortcuts

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