gerrit

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 3, 2023 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package reporter implements a reporter interface for gerrit

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is a gerrit reporter client

func NewReporter

func NewReporter(orgRepoConfigGetter func() *config.GerritOrgRepoConfigs, cookiefilePath string, pjclientset ctrlruntimeclient.Client) (*Client, error)

NewReporter returns a reporter client

func (*Client) GetName

func (c *Client) GetName() string

GetName returns the name of the reporter

func (*Client) Report

func (c *Client) Report(ctx context.Context, logger *logrus.Entry, pj *v1.ProwJob) ([]*v1.ProwJob, *reconcile.Result, error)

Report will send the current prowjob status as a gerrit review

func (*Client) ShouldReport

func (c *Client) ShouldReport(ctx context.Context, log *logrus.Entry, pj *v1.ProwJob) bool

ShouldReport returns if this prowjob should be reported by the gerrit reporter

type Job

type Job struct {
	Name  string
	State v1.ProwJobState
	Icon  string
	URL   string
}

Job is the view of a prowjob scoped for a report

type JobReport

type JobReport struct {
	Jobs    []Job
	Success int
	Total   int
	Message string
	Header  string
}

JobReport is the structured job report format

func GenerateReport

func GenerateReport(pjs []*v1.ProwJob, customCommentSizeLimit int) JobReport

GenerateReport generates a JobReport based on pjs passed in. As URLs are very long string, including them in the report could easily make the report exceed the maxCommentSizeLimit of 14400 characters. Unfortunately we need info for all prowjobs for /retest to work, which is by far the most reliable way of retrieving prow jobs results (this is because prowjob custom resources are garbage-collected by sinker after max_pod_age, which normally is 48 hours). So to ensure that all prow jobs results are displayed, URLs for some of the jobs are omitted from this report to keep it under 14400 characters.

Note that even if we drop all URLs, it may be that we're forced to drop jobs names entirely if there are just too many jobs. So there is actually no guarantee that we'll always report all job names (although this is rare in practice).

customCommentSizeLimit is used by unit tests that actually test that we perform job serialization with or without URLs (without this, our unit tests would have to be very large to hit the default maxCommentSizeLimit to trigger the "don't print URLs" behavior).

func ParseReport

func ParseReport(message string) *JobReport

ParseReport creates a jobReport from a string, nil if cannot parse

func (JobReport) String

func (r JobReport) String() string

String implements Stringer for JobReport

Jump to

Keyboard shortcuts

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