schemas

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetMergeRequestIIDFromRefName

func GetMergeRequestIIDFromRefName(refName string) (string, error)

GetMergeRequestIIDFromRefName parses a refName to extract a merge request IID (Internal ID).

func GetRefRegexp

func GetRefRegexp(ppr config.ProjectPullRefs, rk RefKind) (re *regexp.Regexp, err error)

GetRefRegexp returns the expected regular expression for a given ProjectPullRefs config and RefKind.

Types

type Deployment

type Deployment struct {
	JobID           int     // Unique identifier for the job associated with the deployment
	RefKind         RefKind // The kind of reference (e.g., branch, tag) associated with the deployment
	RefName         string  // The name of the reference associated with the deployment
	Username        string  // The username of the user who triggered the deployment
	Timestamp       float64 // Unix timestamp of when the deployment was created or updated
	DurationSeconds float64 // Duration of the deployment process in seconds
	CommitShortID   string  // Short identifier for the commit associated with the deployment
	Status          string  // Status of the deployment (e.g., success, failed)
}

Deployment represents a deployment structure with detailed information about a GitLab deployment.

type Environment

type Environment struct {
	ProjectName      string     // Name of the project the environment belongs to
	ID               int        // Unique identifier for the environment
	Name             string     // Name of the environment
	ExternalURL      string     // External URL associated with the environment
	Available        bool       // Availability status of the environment
	LatestDeployment Deployment // Latest deployment information for the environment

	OutputSparseStatusMetrics bool // Flag to determine if sparse status metrics should be output
}

Environment represents an environment structure with detailed information about a GitLab environment.

func (Environment) DefaultLabelsValues

func (e Environment) DefaultLabelsValues() map[string]string

DefaultLabelsValues returns a map of default label values for an Environment.

func (Environment) InformationLabelsValues

func (e Environment) InformationLabelsValues() (v map[string]string)

InformationLabelsValues returns a map of detailed label values for an Environment, including default labels.

func (Environment) Key

func (e Environment) Key() EnvironmentKey

Key generates a unique key for an Environment using a CRC32 checksum of the project name and environment name.

type EnvironmentKey

type EnvironmentKey string

EnvironmentKey is a custom type used as a key for identifying environments.

type Environments

type Environments map[EnvironmentKey]Environment

Environments is a map used to keep track of multiple environments, with EnvironmentKey as the key.

func (Environments) Count

func (envs Environments) Count() int

Count returns the number of environments in the Environments map.

type Job

type Job struct {
	ID                    int     // Unique identifier for the job
	Name                  string  // Name of the job
	Stage                 string  // Stage of the job in the pipeline
	Timestamp             float64 // Unix timestamp of when the job was created
	DurationSeconds       float64 // Duration of the job execution in seconds
	QueuedDurationSeconds float64 // Duration the job was queued in seconds
	Status                string  // Status of the job
	PipelineID            int     // PipelineID of the job
	TagList               string  // Comma-separated list of tags associated with the job
	ArtifactSize          float64 // Total size of artifacts produced by the job in bytes
	FailureReason         string  // Reason for failure if the job failed
	Runner                Runner  // Runner information associated with the job
}

Job represents a job structure with detailed information about a GitLab CI/CD job.

func NewJob

func NewJob(gj goGitlab.Job) Job

NewJob creates a new Job instance from a GitLab job object.

type Jobs

type Jobs map[string]Job

Jobs is a map used to keep track of multiple jobs, with job names as the keys.

type Metric

type Metric struct {
	Kind   MetricKind        // The kind of metric
	Labels prometheus.Labels // Labels associated with the metric
	Value  float64           // The value of the metric
}

Metric represents a metric with a kind, labels, and a value.

func (Metric) Key

func (m Metric) Key() MetricKey

Key generates a unique key for a Metric based on its kind and labels.

type MetricKey

type MetricKey string

MetricKey is a custom type used as a key for identifying metrics.

type MetricKind

type MetricKind int32

MetricKind represents different kinds of metrics that can be collected.

const (
	// MetricKindCoverage refers to the coverage metric of a job or pipeline.
	MetricKindCoverage MetricKind = iota

	// MetricKindDurationSeconds refers to the duration of a job or pipeline in seconds.
	MetricKindDurationSeconds

	// MetricKindEnvironmentBehindCommitsCount refers to the number of commits an environment is behind.
	MetricKindEnvironmentBehindCommitsCount

	// MetricKindEnvironmentBehindDurationSeconds refers to the duration in seconds an environment is behind.
	MetricKindEnvironmentBehindDurationSeconds

	// MetricKindEnvironmentDeploymentCount refers to the count of deployments in an environment.
	MetricKindEnvironmentDeploymentCount

	// MetricKindEnvironmentDeploymentDurationSeconds refers to the duration of a deployment in an environment in seconds.
	MetricKindEnvironmentDeploymentDurationSeconds

	// MetricKindEnvironmentDeploymentJobID refers to the job ID of a deployment in an environment.
	MetricKindEnvironmentDeploymentJobID

	// MetricKindEnvironmentDeploymentStatus refers to the status of a deployment in an environment.
	MetricKindEnvironmentDeploymentStatus

	// MetricKindEnvironmentDeploymentTimestamp refers to the timestamp of a deployment in an environment.
	MetricKindEnvironmentDeploymentTimestamp

	// MetricKindEnvironmentInformation refers to general information about an environment.
	MetricKindEnvironmentInformation

	// MetricKindID refers to the ID of a job or pipeline.
	MetricKindID

	// MetricKindJobArtifactSizeBytes refers to the size of job artifacts in bytes.
	MetricKindJobArtifactSizeBytes

	// MetricKindJobDurationSeconds refers to the duration of a job in seconds.
	MetricKindJobDurationSeconds

	// MetricKindJobID refers to the ID of a job.
	MetricKindJobID

	// MetricKindJobQueuedDurationSeconds refers to the queued duration of a job in seconds.
	MetricKindJobQueuedDurationSeconds

	// MetricKindJobRunCount refers to the run count of a job.
	MetricKindJobRunCount

	// MetricKindJobStatus refers to the status of a job.
	MetricKindJobStatus

	// MetricKindJobTimestamp refers to the timestamp of a job.
	MetricKindJobTimestamp

	// MetricKindQueuedDurationSeconds refers to the queued duration of a pipeline in seconds.
	MetricKindQueuedDurationSeconds

	// MetricKindRunCount refers to the run count of a pipeline.
	MetricKindRunCount

	// MetricKindStatus refers to the status of a pipeline.
	MetricKindStatus

	// MetricKindTimestamp refers to the timestamp of a pipeline.
	MetricKindTimestamp

	// MetricKindTestReportTotalTime refers to the total time of a test report in seconds.
	MetricKindTestReportTotalTime

	// MetricKindTestReportTotalCount refers to the total count of tests in a test report.
	MetricKindTestReportTotalCount

	// MetricKindTestReportSuccessCount refers to the count of successful tests in a test report.
	MetricKindTestReportSuccessCount

	// MetricKindTestReportFailedCount refers to the count of failed tests in a test report.
	MetricKindTestReportFailedCount

	// MetricKindTestReportSkippedCount refers to the count of skipped tests in a test report.
	MetricKindTestReportSkippedCount

	// MetricKindTestReportErrorCount refers to the count of tests with errors in a test report.
	MetricKindTestReportErrorCount

	// MetricKindTestSuiteTotalTime refers to the total time of a test suite in seconds.
	MetricKindTestSuiteTotalTime

	// MetricKindTestSuiteTotalCount refers to the total count of tests in a test suite.
	MetricKindTestSuiteTotalCount

	// MetricKindTestSuiteSuccessCount refers to the count of successful tests in a test suite.
	MetricKindTestSuiteSuccessCount

	// MetricKindTestSuiteFailedCount refers to the count of failed tests in a test suite.
	MetricKindTestSuiteFailedCount

	// MetricKindTestSuiteSkippedCount refers to the count of skipped tests in a test suite.
	MetricKindTestSuiteSkippedCount

	// MetricKindTestSuiteErrorCount refers to the count of tests with errors in a test suite.
	MetricKindTestSuiteErrorCount

	// MetricKindTestCaseExecutionTime refers to the execution time of a test case in seconds.
	MetricKindTestCaseExecutionTime

	// MetricKindTestCaseStatus refers to the status of a test case.
	MetricKindTestCaseStatus
)

type Metrics

type Metrics map[MetricKey]Metric

Metrics is a map used to keep track of multiple metrics, with MetricKey as the key.

type Pipeline

type Pipeline struct {
	ID                    int        // Unique identifier for the pipeline
	Coverage              float64    // Coverage percentage of the pipeline
	Timestamp             float64    // Unix timestamp of when the pipeline was updated
	DurationSeconds       float64    // Duration of the pipeline execution in seconds
	QueuedDurationSeconds float64    // Duration the pipeline was queued in seconds
	Source                string     // Source of the pipeline trigger
	Status                string     // Status of the pipeline
	Variables             string     // Variables associated with the pipeline
	TestReport            TestReport // Test report associated with the pipeline
}

Pipeline represents a pipeline structure with detailed information about a GitLab CI/CD pipeline.

func NewPipeline

func NewPipeline(ctx context.Context, gp goGitlab.Pipeline) Pipeline

NewPipeline creates a new Pipeline instance from a GitLab pipeline object.

type Project

type Project struct {
	config.Project // Embedding the Project type from the config package

	Topics string // Additional field to store topics related to the project
}

Project represents a project structure that extends a configuration project with additional fields.

func NewProject

func NewProject(name string) Project

NewProject creates a new Project instance with the given name.

func (Project) Key

func (p Project) Key() ProjectKey

Key generates a unique key for a Project using a CRC32 checksum of the project's name.

type ProjectKey

type ProjectKey string

ProjectKey is a custom type used as a key for identifying projects.

type Projects

type Projects map[ProjectKey]Project

Projects is a map used to keep track of multiple projects, with ProjectKey as the key.

type Ref

type Ref struct {
	Kind           RefKind  // The kind of the reference (branch, tag, merge-request)
	Name           string   // The name of the reference
	Project        Project  // The project associated with the reference
	LatestPipeline Pipeline // The latest pipeline associated with the reference
	LatestJobs     Jobs     // The latest jobs associated with the reference
}

Ref represents a reference entity on which metrics operations will be performed.

func NewRef

func NewRef(
	project Project,
	kind RefKind,
	name string,
) Ref

NewRef is a helper function that returns a new Ref.

func (Ref) DefaultLabelsValues

func (ref Ref) DefaultLabelsValues() map[string]string

DefaultLabelsValues returns a map of default label values for a Ref.

func (Ref) Key

func (ref Ref) Key() RefKey

Key generates a unique key for a Ref using a CRC32 checksum.

type RefKey

type RefKey string

RefKey is a custom type used as a key for references.

type RefKind

type RefKind string

RefKind is a custom type used to determine the kind of a reference.

const (

	// RefKindBranch refers to a branch reference kind.
	RefKindBranch RefKind = "branch"

	// RefKindTag refers to a tag reference kind.
	RefKindTag RefKind = "tag"

	// RefKindMergeRequest refers to a merge request reference kind.
	RefKindMergeRequest RefKind = "merge-request"
)

type Refs

type Refs map[RefKey]Ref

Refs is a map used to keep track of all configured or discovered references.

func (Refs) Count

func (refs Refs) Count() int

Count returns the number of references in the Refs map.

type Runner

type Runner struct {
	Description string // Description of the runner
}

Runner represents information about a GitLab runner.

type TaskType

type TaskType string

TaskType represents the type of task as a string.

const (
	// TaskTypePullProject represents a task type for pulling a single project.
	TaskTypePullProject TaskType = "PullProject"

	// TaskTypePullProjectsFromWildcard represents a task type for pulling projects from a wildcard pattern.
	TaskTypePullProjectsFromWildcard TaskType = "PullProjectsFromWildcard"

	// TaskTypePullProjectsFromWildcards represents a task type for pulling projects from multiple wildcard patterns.
	TaskTypePullProjectsFromWildcards TaskType = "PullProjectsFromWildcards"

	// TaskTypePullEnvironmentsFromProject represents a task type for pulling environments from a single project.
	TaskTypePullEnvironmentsFromProject TaskType = "PullEnvironmentsFromProject"

	// TaskTypePullEnvironmentsFromProjects represents a task type for pulling environments from multiple projects.
	TaskTypePullEnvironmentsFromProjects TaskType = "PullEnvironmentsFromProjects"

	// TaskTypePullEnvironmentMetrics represents a task type for pulling metrics from environments.
	TaskTypePullEnvironmentMetrics TaskType = "PullEnvironmentMetrics"

	// TaskTypePullMetrics represents a task type for pulling metrics.
	TaskTypePullMetrics TaskType = "PullMetrics"

	// TaskTypePullRefsFromProject represents a task type for pulling references from a single project.
	TaskTypePullRefsFromProject TaskType = "PullRefsFromProject"

	// TaskTypePullRefsFromProjects represents a task type for pulling references from multiple projects.
	TaskTypePullRefsFromProjects TaskType = "PullRefsFromProjects"

	// TaskTypePullRefMetrics represents a task type for pulling metrics from references.
	TaskTypePullRefMetrics TaskType = "PullRefMetrics"

	// TaskTypeGarbageCollectProjects represents a task type for garbage collecting projects.
	TaskTypeGarbageCollectProjects TaskType = "GarbageCollectProjects"

	// TaskTypeGarbageCollectEnvironments represents a task type for garbage collecting environments.
	TaskTypeGarbageCollectEnvironments TaskType = "GarbageCollectEnvironments"

	// TaskTypeGarbageCollectRefs represents a task type for garbage collecting references.
	TaskTypeGarbageCollectRefs TaskType = "GarbageCollectRefs"

	// TaskTypeGarbageCollectMetrics represents a task type for garbage collecting metrics.
	TaskTypeGarbageCollectMetrics TaskType = "GarbageCollectMetrics"
)

type Tasks

type Tasks map[TaskType]map[string]interface{}

Tasks is a map structure used to keep track of tasks. It maps a TaskType to another map, which associates task identifiers with empty interfaces.

type TestCase

type TestCase struct {
	Name          string  // Name of the test case
	Classname     string  // Class name of the test case
	ExecutionTime float64 // Execution time of the test case in seconds
	Status        string  // Status of the test case
}

TestCase represents a test case structure with detailed information about an individual test.

func NewTestCase

func NewTestCase(gtc *goGitlab.PipelineTestCases) TestCase

NewTestCase creates a new TestCase instance from a GitLab test case object.

type TestReport

type TestReport struct {
	TotalTime    float64     // Total time taken by all tests in seconds
	TotalCount   int         // Total number of tests
	SuccessCount int         // Number of successful tests
	FailedCount  int         // Number of failed tests
	SkippedCount int         // Number of skipped tests
	ErrorCount   int         // Number of tests with errors
	TestSuites   []TestSuite // List of test suites in the report
}

TestReport represents a test report structure with detailed information about test results.

func NewTestReport

func NewTestReport(gtr goGitlab.PipelineTestReport) TestReport

NewTestReport creates a new TestReport instance from a GitLab test report object.

type TestSuite

type TestSuite struct {
	Name         string     // Name of the test suite
	TotalTime    float64    // Total time taken by the test suite in seconds
	TotalCount   int        // Total number of tests in the suite
	SuccessCount int        // Number of successful tests in the suite
	FailedCount  int        // Number of failed tests in the suite
	SkippedCount int        // Number of skipped tests in the suite
	ErrorCount   int        // Number of tests with errors in the suite
	TestCases    []TestCase // List of test cases in the suite
}

TestSuite represents a test suite structure with detailed information about a suite of tests.

func NewTestSuite

func NewTestSuite(gts *goGitlab.PipelineTestSuites) TestSuite

NewTestSuite creates a new TestSuite instance from a GitLab test suite object.

Jump to

Keyboard shortcuts

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