filter

package
v0.0.0-...-958d37d Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const Prefix = "triggers.shipwright.io"

Prefix prefix used in all annotations.

Variables

View Source
var (
	// OwnedByTektonRun annotates the BuildRun as owned by Tekton CustomRun.
	OwnedByTektonCustomRun = fmt.Sprintf("%s/owned-by-customrun", Prefix)
	// OwnedByTektonRun annotates the BuildRun as owned by Tekton Run.
	OwnedByTektonRun = fmt.Sprintf("%s/owned-by-run", Prefix)
	// OwnedByTektonPipelineRun lables the BuildRun as owned by Tekton PipelineRun.
	OwnedByTektonPipelineRun = fmt.Sprintf("%s/owned-by-pipelinerun", Prefix)
	// BuildRunsCreated annotates the PipelineRun with the BuildRuns created.
	BuildRunsCreated = fmt.Sprintf("%s/buildrun-names", Prefix)

	// TektonPipelineRunName annotates PipelineRuns with its current name, avoid object reprocessing.
	TektonPipelineRunName = fmt.Sprintf("%s/pipelinerun-name", Prefix)
	// TektonPipelineRunTriggeredBuilds contains references for all Builds triggered, JSON formatted
	TektonPipelineRunTriggeredBuilds = fmt.Sprintf("%s/pipelinerun-triggered-builds", Prefix)
)

Functions

func AppendIntoTriggeredBuildSliceAsAnnotation

func AppendIntoTriggeredBuildSliceAsAnnotation(
	triggeredBuilds []TriggeredBuild,
	buildNames []string,
	objectRef *buildapi.WhenObjectRef,
) (string, error)

AppendIntoTriggeredBuildSliceAsAnnotation appends the build names with the objectRef into the informed triggered-builds slice, the payload returned is marshalled JSON which can emit errors.

func AppendIssuedBuildRunsLabel

func AppendIssuedBuildRunsLabel(pipelineRun *tektonapi.PipelineRun, buildRunsIssued []string)

AppendIssuedBuildRunsLabel update or add the label to document the BuildRuns issued for the PipelineRun instance informed.

func CustomRunEventFilterPredicate

func CustomRunEventFilterPredicate(obj client.Object) bool

CustomRunEventFilterPredicate inspects the object expecting a Tekton's CustomRun, filtering out when is not yet started, or has already being processed by the custom-tasks controller by inspecting the Status' ExtraFields.

func ExtractBuildRunCustomRunOwner

func ExtractBuildRunCustomRunOwner(br *buildapi.BuildRun) *types.NamespacedName

ExtractBuildRunCustomRunOwner inspect the object owners for Tekton CustomRun and returns it, otherwise nil.

func ParsePipelineRunStatus

func ParsePipelineRunStatus(
	ctx context.Context,
	now time.Time,
	pipelineRun *tektonapi.PipelineRun,
) (string, error)

ParsePipelineRunStatus parte the informed object status to extract its status.

func PipelineRunAnnotateName

func PipelineRunAnnotateName(pipelineRun *tektonapi.PipelineRun)

func PipelineRunAnnotatedNameMatchesObject

func PipelineRunAnnotatedNameMatchesObject(pipelineRun *tektonapi.PipelineRun) bool

func PipelineRunAppendTriggeredBuildsAnnotation

func PipelineRunAppendTriggeredBuildsAnnotation(
	pipelineRun *tektonapi.PipelineRun,
	triggeredBuilds []TriggeredBuild,
	buildNames []string,
	objectRef *buildapi.WhenObjectRef,
) error

PipelineRunAppendTriggeredBuildsAnnotation set or update the triggered-builds annotation.

func PipelineRunEventFilterPredicate

func PipelineRunEventFilterPredicate(obj client.Object) bool

PipelineRunEventFilterPredicate predicate filter for the basic inspections in the object, filtering only what needs to go through reconciliation. PipelineRun objects referencing Custom-Tasks are also skipped.

func PipelineRunGetAnnotations

func PipelineRunGetAnnotations(pipelineRun *tektonapi.PipelineRun) map[string]string

PipelineRunGetAnnotations extract the annotations, return an empty map otherwise.

func PipelineRunGetLabels

func PipelineRunGetLabels(pipelineRun *tektonapi.PipelineRun) map[string]string

PipelineRunGetLabels extract labels from informed object, returns an empty map when `nil` labels.

func PipelineRunToObjectRef

func PipelineRunToObjectRef(
	ctx context.Context,
	now time.Time,
	pipelineRun *tektonapi.PipelineRun,
) (*buildapi.WhenObjectRef, error)

PipelineRunToObjectRef transforms the informed PipelineRun instance to a ObjectRef.

func TektonCustomRunParamsToShipwrightParamValues

func TektonCustomRunParamsToShipwrightParamValues(customRun *tektonapibeta.CustomRun) []buildapi.ParamValue

TektonCustomRunParamsToShipwrightParamValues transforms the informed Tekton Run params into Shipwright ParamValues slice.

func TriggereBuildsContainsObjectRef

func TriggereBuildsContainsObjectRef(
	triggeredBuilds []TriggeredBuild,
	buildNames []string,
	objectRef *buildapi.WhenObjectRef,
) bool

TriggereBuildsContainsObjectRef asserts if the slice contains the informed entry.

Types

type ExtraFields

type ExtraFields struct {
	BuildRunNamespace string `json:"buildRunNamespace,omitempty"` // buildrun namespace
	BuildRunName      string `json:"buildRunName,omitempty"`      // buildrun name
}

ExtraFields carry on meta-information linking Tekton Run with Shipwright Build.

func NewExtraFields

func NewExtraFields(br *buildapi.BuildRun) ExtraFields

NewExtraFields instantiates a ExtraFields with informed BuildRun.

func (*ExtraFields) GetNamespacedName

func (e *ExtraFields) GetNamespacedName() types.NamespacedName

GetNamespacedName returns a NamespacedName representation.

func (*ExtraFields) IsEmpty

func (e *ExtraFields) IsEmpty() bool

IsEmpty checks if the BuildRunName is defined.

type TriggeredBuild

type TriggeredBuild struct {
	BuildName string                  `json:"buildName"`
	ObjectRef *buildapi.WhenObjectRef `json:"objectRef"`
}

TriggeredBuild represents previously triggered builds by storing together the original build name and it's objectRef. Both are the criteria needed to find the Builds with matching triggers in the Inventory.

func PipelineRunExtractTriggeredBuildsSlice

func PipelineRunExtractTriggeredBuildsSlice(
	pipelineRun *tektonapi.PipelineRun,
) ([]TriggeredBuild, error)

PipelineRunExtractTriggeredBuildsSlice extracts the triggered-builds annotation and returns a valid slice of the type. When the annotation is empty, or not present, an empty slice is returned instead.

func UnmarshalIntoTriggeredAnnotationSlice

func UnmarshalIntoTriggeredAnnotationSlice(payload string) ([]TriggeredBuild, error)

UnmarshalIntoTriggeredAnnotationSlice executes the un-marshalling of the informed string payload into a slice of TriggeredBuild type. JSON validation is strict, returns error on unknown fields.

Jump to

Keyboard shortcuts

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