requirement

package
v0.0.0-...-9eda336 Latest Latest
Warning

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

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

Documentation

Overview

Package requirement computes Tryjob Requirements and provides various utility functions related to Tryjob Requirements.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ComputationFailure

type ComputationFailure interface {
	// Reason returns a human-readable string that explains what fails the
	// requirement computation.
	//
	// This will be shown directly to users. Make sure it doesn't leak any
	// information.
	Reason() string
}

ComputationFailure is what fails the Tryjob Requirement computation.

type ComputationResult

type ComputationResult struct {
	// Requirement is the derived Tryjob Requirement to verify the Run.
	//
	// Mutually exclusive with `ComputationFailure`.
	Requirement *tryjob.Requirement
	// ComputationFailure is what fails the Requirement computation.
	//
	// This is different from the returned error from the `Compute` function.
	// This failure is typically caused by invalid directive from users or
	// Project Config (e.g. including a builder that is not defined in Project
	// config via git-footer). It should be reported back to the user to decide
	// the next step. On the other hand, the returned error from the `Compute`
	// function is typically caused by internal errors, like remote RPC call
	// failure, and should generally be retried.
	//
	// Mutually exclusive with `Requirement`.
	ComputationFailure ComputationFailure
}

ComputationResult is the result of Tryjob Requirement computation.

func Compute

func Compute(ctx context.Context, in Input) (*ComputationResult, error)

Compute computes the Tryjob Requirement to verify the run.

func (ComputationResult) OK

func (r ComputationResult) OK() bool

OK returns true if the Tryjob Requirement is successfully computed.

`ComputationFailure` MUST be present if false is returned.

type DefinitionMapping

type DefinitionMapping map[*tryjob.Definition]*tryjob.Definition

DefinitionMapping is a mapping between two definitions.

func (DefinitionMapping) Has

func (dm DefinitionMapping) Has(def *tryjob.Definition) bool

Has reports whether the given tryjob definition is in the mapping as a key.

type DiffResult

type DiffResult struct {
	// RemovedDefs contains the definitions in `base` that are no longer present
	// in `target`.
	//
	// Only the keys will be populated, the values will be nil.
	RemovedDefs DefinitionMapping
	// ChangedDefs contains mapping between definitions in `base` and `target`
	// that have changed.
	//
	// The categorization of changes may vary across different backend. For
	// buildbucket tryjob, a definition is considered changed if the main builder
	// stays the same and other properties like equivalent builder, reuse config
	// have changed.
	ChangedDefs DefinitionMapping
	// ChangedDefsReverse is a reverse mapping of `ChangedDefs`
	ChangedDefsReverse DefinitionMapping
	// AddedDefs contains the definitions that are added to `target` but are not
	// in `base`.
	//
	// Only the keys will be populated, the values will be nil.
	AddedDefs DefinitionMapping
	// UnchangedDefs is like `ChangeDefs` but contain unchanged definitions.
	//
	// This comes handy when trying to locate the corresponding definition in the
	// `target` when iterating through `base`.
	UnchangedDefs DefinitionMapping
	// UnchangedDefsReverse is a reverse mapping of `UnchangedDefs`
	UnchangedDefsReverse DefinitionMapping

	// RetryConfigChanged indicates the retry configuration has changed.
	RetryConfigChanged bool
}

DiffResult contains a diff between two Tryjob requirements.

func Diff

func Diff(base, target *tryjob.Requirement) DiffResult

Diff computes the diff between two Tryjob Requirements.

type Input

type Input struct {
	GFactory    gerrit.Factory
	ConfigGroup *cfgpb.ConfigGroup
	RunOwner    identity.Identity
	CLs         []*run.RunCL
	RunOptions  *run.Options
	RunMode     run.Mode
}

Input contains all info needed to compute the Tryjob Requirement.

Jump to

Keyboard shortcuts

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