status

package
v0.0.0-...-392d2aa Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2024 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Overview

Package status is a generated GoMock package.

Package status is a generated GoMock package.

Index

Constants

View Source
const (
	PACSecret = "pipelines-as-code-secret"
)

Used by statusReport to get pipelines-as-code-secret under NS integration-service

Variables

This section is empty.

Functions

func FormatComment

func FormatComment(title, text string) (string, error)

FormatComment build a markdown comment with the details in text

func FormatDetails

func FormatDetails(taskRun *helpers.TaskRun) (string, error)

FormatDetails accepts a TaskRun and returns a Markdown friendly representation of its detailed test results, if any.

func FormatFootnotes

func FormatFootnotes(taskRuns []*helpers.TaskRun) (string, error)

FormatResults accepts a list of TaskRuns and returns a Markdown friendly representation of their footnotes, if any.

func FormatNamespace

func FormatNamespace(taskRun *helpers.TaskRun) (string, error)

FormatNamespace accepts a TaskRun and returns a Markdown friendly representation of its test suite, if any.

func FormatPipelineURL

func FormatPipelineURL(pipelinerun string, namespace string, logger logr.Logger) string

FormatPipelineURL accepts a name of application, pipelinerun, namespace and returns a complete pipelineURL.

func FormatPullRequestURL

func FormatPullRequestURL(repoUrl string, pullRequestNumber string) string

FormatPullRequestURL accepts a name of application, pipelinerun, namespace and returns a complete pipelineURL.

func FormatRepoURL

func FormatRepoURL(repoUrl string) string

func FormatStatus

func FormatStatus(taskRun *helpers.TaskRun) (string, error)

FormatStatus accepts a TaskRun and returns a Markdown friendly representation of its overall status, if any.

func FormatTaskLogURL

func FormatTaskLogURL(taskRun *helpers.TaskRun, pipelinerun string, namespace string, logger logr.Logger) string

FormatTaskLogURL accepts name of pipelinerun, task, namespace and returns a complete task log URL.

func FormatTaskName

func FormatTaskName(taskRun *helpers.TaskRun) (string, error)

FormatTaskName accepts a TaskRun and returns a Markdown friendly representation of its name.

func FormatTestsSummary

func FormatTestsSummary(taskRuns []*helpers.TaskRun, pipelineRunName string, namespace string, componentSnapshotInfos []*gitops.ComponentSnapshotInfo, logger logr.Logger) (string, error)

FormatTestsSummary builds a markdown summary for a list of integration TaskRuns.

func GenerateGitlabCommitState

func GenerateGitlabCommitState(state intgteststat.IntegrationTestStatus) (gitlab.BuildStateValue, error)

GenerateGitlabCommitState transforms internal integration test state into Gitlab state

func GenerateSummary

func GenerateSummary(state intgteststat.IntegrationTestStatus, snapshotName, scenarioName string) (string, error)

GenerateSummary returns summary for the given state, snapshotName and scenarioName

func GetAppCredentials

func GetAppCredentials(ctx context.Context, k8sclient client.Client, object client.Object) (*appCredentials, error)

func GetComponentSnapshotsFromGroupSnapshot

func GetComponentSnapshotsFromGroupSnapshot(ctx context.Context, c client.Client, groupSnapshot *applicationapiv1alpha1.Snapshot) ([]*applicationapiv1alpha1.Snapshot, error)

GetComponentSnapshotsFromGroupSnapshot return the component snapshot list which component snapshot is created from

func GetPACGitProviderToken

func GetPACGitProviderToken(ctx context.Context, k8sClient client.Client, snapshot *applicationapiv1alpha1.Snapshot) (string, error)

GetPACGitProviderToken lookup for configured repo and fetch token from namespace

func MigrateSnapshotToReportStatus

func MigrateSnapshotToReportStatus(s *applicationapiv1alpha1.Snapshot, testStatuses []*intgteststat.IntegrationTestStatusDetail)

MigrateSnapshotToReportStatus migrates old way of keeping updates sync to the new way by updating annotations in snapshot

func WriteSnapshotReportStatus

func WriteSnapshotReportStatus(ctx context.Context, c client.Client, s *applicationapiv1alpha1.Snapshot, srs *SnapshotReportStatus) error

WriteSnapshotReportStatus writes report status

Types

type CheckRunStatusUpdater

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

CheckRunStatusUpdater updates PR status using CheckRuns (when application integration is enabled in repo)

func NewCheckRunStatusUpdater

func NewCheckRunStatusUpdater(
	ghClient github.ClientInterface,
	k8sClient client.Client,
	logger *logr.Logger,
	owner string,
	repo string,
	sha string,
	snapshot *applicationapiv1alpha1.Snapshot,
) *CheckRunStatusUpdater

NewCheckRunStatusUpdater returns a pointer to initialized CheckRunStatusUpdater

func (*CheckRunStatusUpdater) Authenticate

func (cru *CheckRunStatusUpdater) Authenticate(ctx context.Context, snapshot *applicationapiv1alpha1.Snapshot) error

Authenticate Github Client with application credentials

func (*CheckRunStatusUpdater) UpdateStatus

func (cru *CheckRunStatusUpdater) UpdateStatus(ctx context.Context, report TestReport) error

UpdateStatus updates CheckRun status of PR

type CommentTemplateData

type CommentTemplateData struct {
	Title   string
	Summary string
}

CommentTemplateData holds the data necessary to construct a PipelineRun comment.

type CommitStatusUpdater

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

CommitStatusUpdater updates PR using Commit/RepoStatus (without application integration enabled)

func NewCommitStatusUpdater

func NewCommitStatusUpdater(
	ghClient github.ClientInterface,
	k8sClient client.Client,
	logger *logr.Logger,
	owner string,
	repo string,
	sha string,
	snapshot *applicationapiv1alpha1.Snapshot,
) *CommitStatusUpdater

NewCommitStatusUpdater returns a pointer to initialized CommitStatusUpdater

func (*CommitStatusUpdater) Authenticate

func (csu *CommitStatusUpdater) Authenticate(ctx context.Context, snapshot *applicationapiv1alpha1.Snapshot) error

Authenticate Github Client with token secret ref defined in snapshot

func (*CommitStatusUpdater) UpdateStatus

func (csu *CommitStatusUpdater) UpdateStatus(ctx context.Context, report TestReport) error

UpdateStatus updates commit status in PR

type GitHubReporter

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

GitHubReporter reports status back to GitHub for a Snapshot.

func NewGitHubReporter

func NewGitHubReporter(logger logr.Logger, k8sClient client.Client, opts ...GitHubReporterOption) *GitHubReporter

NewGitHubReporter returns a struct implementing the Reporter interface for GitHub

func (*GitHubReporter) Detect

func (r *GitHubReporter) Detect(snapshot *applicationapiv1alpha1.Snapshot) bool

Detect if GitHubReporter can be used

func (*GitHubReporter) GetReporterName

func (r *GitHubReporter) GetReporterName() string

Return reporter name

func (*GitHubReporter) Initialize

func (r *GitHubReporter) Initialize(ctx context.Context, snapshot *applicationapiv1alpha1.Snapshot) error

Initialize github reporter. Must be called before updating status

func (*GitHubReporter) ReportStatus

func (r *GitHubReporter) ReportStatus(ctx context.Context, report TestReport) error

Update status in Github

type GitHubReporterOption

type GitHubReporterOption = func(r *GitHubReporter)

GitHubReporterOption is used to extend GitHubReporter with optional parameters.

func WithGitHubClient

func WithGitHubClient(client github.ClientInterface) GitHubReporterOption

type GitLabReporter

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

func NewGitLabReporter

func NewGitLabReporter(logger logr.Logger, k8sClient client.Client) *GitLabReporter

func (*GitLabReporter) Detect

func (r *GitLabReporter) Detect(snapshot *applicationapiv1alpha1.Snapshot) bool

Detect if snapshot has been created from gitlab provider

func (*GitLabReporter) GetExistingCommitStatus

func (r *GitLabReporter) GetExistingCommitStatus(commitStatuses []*gitlab.CommitStatus, statusName string) *gitlab.CommitStatus

GetExistingCommitStatus returns existing GitLab commit status that matches .

func (*GitLabReporter) GetExistingNoteID

func (r *GitLabReporter) GetExistingNoteID(notes []*gitlab.Note, scenarioName, snapshotName string) *int

GetExistingNoteID returns existing GitLab note for the scenario of ref.

func (*GitLabReporter) GetReporterName

func (r *GitLabReporter) GetReporterName() string

GetReporterName returns the reporter name

func (*GitLabReporter) Initialize

func (r *GitLabReporter) Initialize(ctx context.Context, snapshot *applicationapiv1alpha1.Snapshot) error

Initialize initializes gitlab reporter

func (*GitLabReporter) ReportStatus

func (r *GitLabReporter) ReportStatus(ctx context.Context, report TestReport) error

ReportStatus reports test result to gitlab

type MockReporterInterface

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

MockReporterInterface is a mock of ReporterInterface interface.

func NewMockReporterInterface

func NewMockReporterInterface(ctrl *gomock.Controller) *MockReporterInterface

NewMockReporterInterface creates a new mock instance.

func (*MockReporterInterface) Detect

func (m *MockReporterInterface) Detect(arg0 *v1alpha1.Snapshot) bool

Detect mocks base method.

func (*MockReporterInterface) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockReporterInterface) GetReporterName

func (m *MockReporterInterface) GetReporterName() string

GetReporterName mocks base method.

func (*MockReporterInterface) Initialize

func (m *MockReporterInterface) Initialize(arg0 context.Context, arg1 *v1alpha1.Snapshot) error

Initialize mocks base method.

func (*MockReporterInterface) ReportStatus

func (m *MockReporterInterface) ReportStatus(arg0 context.Context, arg1 TestReport) error

ReportStatus mocks base method.

type MockReporterInterfaceMockRecorder

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

MockReporterInterfaceMockRecorder is the mock recorder for MockReporterInterface.

func (*MockReporterInterfaceMockRecorder) Detect

Detect indicates an expected call of Detect.

func (*MockReporterInterfaceMockRecorder) GetReporterName

func (mr *MockReporterInterfaceMockRecorder) GetReporterName() *gomock.Call

GetReporterName indicates an expected call of GetReporterName.

func (*MockReporterInterfaceMockRecorder) Initialize

func (mr *MockReporterInterfaceMockRecorder) Initialize(arg0, arg1 any) *gomock.Call

Initialize indicates an expected call of Initialize.

func (*MockReporterInterfaceMockRecorder) ReportStatus

func (mr *MockReporterInterfaceMockRecorder) ReportStatus(arg0, arg1 any) *gomock.Call

ReportStatus indicates an expected call of ReportStatus.

type MockStatusInterface

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

MockStatusInterface is a mock of StatusInterface interface.

func NewMockStatusInterface

func NewMockStatusInterface(ctrl *gomock.Controller) *MockStatusInterface

NewMockStatusInterface creates a new mock instance.

func (*MockStatusInterface) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockStatusInterface) GetReporter

GetReporter mocks base method.

func (*MockStatusInterface) IsMRInSnapshotOpened

func (m *MockStatusInterface) IsMRInSnapshotOpened(arg0 context.Context, arg1 ReporterInterface, arg2 *v1alpha1.Snapshot) (bool, error)

IsMRInSnapshotOpened mocks base method.

func (*MockStatusInterface) IsPRInSnapshotOpened

func (m *MockStatusInterface) IsPRInSnapshotOpened(arg0 context.Context, arg1 ReporterInterface, arg2 *v1alpha1.Snapshot) (bool, error)

IsPRInSnapshotOpened mocks base method.

func (*MockStatusInterface) IsPRMRInSnapshotOpened

func (m *MockStatusInterface) IsPRMRInSnapshotOpened(arg0 context.Context, arg1 *v1alpha1.Snapshot) (bool, error)

IsPRMRInSnapshotOpened mocks base method.

type MockStatusInterfaceMockRecorder

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

MockStatusInterfaceMockRecorder is the mock recorder for MockStatusInterface.

func (*MockStatusInterfaceMockRecorder) GetReporter

func (mr *MockStatusInterfaceMockRecorder) GetReporter(arg0 any) *gomock.Call

GetReporter indicates an expected call of GetReporter.

func (*MockStatusInterfaceMockRecorder) IsMRInSnapshotOpened

func (mr *MockStatusInterfaceMockRecorder) IsMRInSnapshotOpened(arg0, arg1, arg2 any) *gomock.Call

IsMRInSnapshotOpened indicates an expected call of IsMRInSnapshotOpened.

func (*MockStatusInterfaceMockRecorder) IsPRInSnapshotOpened

func (mr *MockStatusInterfaceMockRecorder) IsPRInSnapshotOpened(arg0, arg1, arg2 any) *gomock.Call

IsPRInSnapshotOpened indicates an expected call of IsPRInSnapshotOpened.

func (*MockStatusInterfaceMockRecorder) IsPRMRInSnapshotOpened

func (mr *MockStatusInterfaceMockRecorder) IsPRMRInSnapshotOpened(arg0, arg1 any) *gomock.Call

IsPRMRInSnapshotOpened indicates an expected call of IsPRMRInSnapshotOpened.

type ReporterInterface

type ReporterInterface interface {
	// Detect if the reporter can be used with the snapshot
	Detect(*applicationapiv1alpha1.Snapshot) bool
	// Initialize reporter to be able to update statuses (authenticate, fetching metadata)
	Initialize(context.Context, *applicationapiv1alpha1.Snapshot) error
	// Get plain reporter name
	GetReporterName() string
	// Update status of the integration test
	ReportStatus(context.Context, TestReport) error
}

type ScenarioReportStatus

type ScenarioReportStatus struct {
	LastUpdateTime *time.Time `json:"lastUpdateTime"`
}

ScenarioReportStatus keep report status of git provider for the particular scenario

type SnapshotReportStatus

type SnapshotReportStatus struct {
	Scenarios map[string]*ScenarioReportStatus `json:"scenarios"`
	// contains filtered or unexported fields
}

SnapshotReportStatus keep report status of git provider for the snapshot

func NewSnapshotReportStatus

func NewSnapshotReportStatus(jsondata string) (*SnapshotReportStatus, error)

NewSnapshotReportStatus creates new object

func NewSnapshotReportStatusFromSnapshot

func NewSnapshotReportStatusFromSnapshot(s *applicationapiv1alpha1.Snapshot) (*SnapshotReportStatus, error)

NewSnapshotReportStatusFromSnapshot creates new SnapshotTestStatus struct from snapshot annotation

func (*SnapshotReportStatus) IsDirty

func (srs *SnapshotReportStatus) IsDirty() bool

IsDirty returns true if there are new changes to be written

func (*SnapshotReportStatus) IsNewer

func (srs *SnapshotReportStatus) IsNewer(scenarioName string, snapshotName string, t time.Time) bool

IsNewer returns true if given scenario and snapshot has newer time than the last updated

func (*SnapshotReportStatus) ResetDirty

func (srs *SnapshotReportStatus) ResetDirty()

ResetDirty marks changes as synced to snapshot

func (*SnapshotReportStatus) SetLastUpdateTime

func (srs *SnapshotReportStatus) SetLastUpdateTime(scenarioName string, snapshotName string, t time.Time)

SetLastUpdateTime updates the last udpate time of the given scenario and snapshot to the given time

func (*SnapshotReportStatus) ToAnnotationString

func (srs *SnapshotReportStatus) ToAnnotationString() (string, error)

ToAnnotationString exports data in format for annotation

type Status

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

func NewStatus

func NewStatus(logger logr.Logger, client client.Client) *Status

func (*Status) GetReporter

func (s *Status) GetReporter(snapshot *applicationapiv1alpha1.Snapshot) ReporterInterface

GetReporter returns reporter to process snapshot using the right git provider, nil means no suitable reporter found

func (Status) IsMRInSnapshotOpened

func (s Status) IsMRInSnapshotOpened(ctx context.Context, reporter ReporterInterface, snapshot *applicationapiv1alpha1.Snapshot) (bool, error)

IsMRInSnapshotOpened check if the gitlab merge request triggering snapshot is opened

func (Status) IsPRInSnapshotOpened

func (s Status) IsPRInSnapshotOpened(ctx context.Context, reporter ReporterInterface, snapshot *applicationapiv1alpha1.Snapshot) (bool, error)

IsPRInSnapshotOpened check if the github pull request triggering snapshot is opened

func (Status) IsPRMRInSnapshotOpened

func (s Status) IsPRMRInSnapshotOpened(ctx context.Context, snapshot *applicationapiv1alpha1.Snapshot) (bool, error)

type StatusInterface

type StatusInterface interface {
	GetReporter(*applicationapiv1alpha1.Snapshot) ReporterInterface
	// Check if PR/MR is opened
	IsPRMRInSnapshotOpened(context.Context, *applicationapiv1alpha1.Snapshot) (bool, error)
	// Check if github PR is open
	IsPRInSnapshotOpened(context.Context, ReporterInterface, *applicationapiv1alpha1.Snapshot) (bool, error)
	// Check if gitlab MR is open
	IsMRInSnapshotOpened(context.Context, ReporterInterface, *applicationapiv1alpha1.Snapshot) (bool, error)
}

type StatusUpdater

type StatusUpdater interface {
	// Authentication of client
	Authenticate(ctx context.Context, snapshot *applicationapiv1alpha1.Snapshot) error
	// Update status of PR
	UpdateStatus(ctx context.Context, report TestReport) error
}

StatusUpdater is common interface used by status reporter to update PR status

type SummaryTemplateData

type SummaryTemplateData struct {
	TaskRuns               []*helpers.TaskRun
	PipelineRunName        string
	Namespace              string
	ComponentSnapshotInfos []*gitops.ComponentSnapshotInfo
	Logger                 logr.Logger
}

SummaryTemplateData holds the data necessary to construct a PipelineRun summary.

type TaskLogTemplateData

type TaskLogTemplateData struct {
	TaskName        string
	PipelineRunName string
	Namespace       string
}

TaskLogTemplateData holds the data necessary to construct a Task log URL.

type TestReport

type TestReport struct {
	// FullName describing the snapshot and integration test
	FullName string
	// Name of scenario
	ScenarioName string
	// Name of snapshot
	SnapshotName string
	// Name of Component that triggered snapshot creation (optional)
	ComponentName string
	// text with details of test results
	Text string
	// test status
	Status intgteststat.IntegrationTestStatus
	// short summary of test results
	Summary string
	// time when test started
	StartTime *time.Time
	// time when test completed
	CompletionTime *time.Time
	// pipelineRun Name
	TestPipelineRunName string
}

func GenerateTestReport

func GenerateTestReport(ctx context.Context, client client.Client, detail intgteststat.IntegrationTestStatusDetail, testedSnapshot *applicationapiv1alpha1.Snapshot, componentName string) (*TestReport, error)

GenerateTestReport generates TestReport to be used by all reporters

Jump to

Keyboard shortcuts

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