resources

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2023 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ConditionUnknownStrategyKind                     string = "UnknownStrategyKind"
	ClusterBuildStrategyNotFound                     string = "ClusterBuildStrategyNotFound"
	BuildStrategyNotFound                            string = "BuildStrategyNotFound"
	ConditionSetOwnerReferenceFailed                 string = "SetOwnerReferenceFailed"
	ConditionFailed                                  string = "Failed"
	ConditionTaskRunIsMissing                        string = "TaskRunIsMissing"
	ConditionTaskRunGenerationFailed                 string = "TaskRunGenerationFailed"
	ConditionServiceAccountNotFound                  string = "ServiceAccountNotFound"
	ConditionBuildRegistrationFailed                 string = "BuildRegistrationFailed"
	ConditionBuildNotFound                           string = "BuildNotFound"
	ConditionMissingParameterValues                  string = "MissingParameterValues"
	ConditionRestrictedParametersInUse               string = "RestrictedParametersInUse"
	ConditionUndefinedParameter                      string = "UndefinedParameter"
	ConditionWrongParameterValueType                 string = "WrongParameterValueType"
	ConditionInconsistentParameterValues             string = "InconsistentParameterValues"
	ConditionEmptyArrayItemParameterValues           string = "EmptyArrayItemParameterValues"
	ConditionIncompleteConfigMapValueParameterValues string = "IncompleteConfigMapValueParameterValues"
	ConditionIncompleteSecretValueParameterValues    string = "IncompleteSecretValueParameterValues"
	BuildRunNameInvalid                              string = "BuildRunNameInvalid"
	BuildRunNoRefOrSpec                              string = "BuildRunNoRefOrSpec"
	BuildRunAmbiguousBuild                           string = "BuildRunAmbiguousBuild"
	BuildRunBuildFieldOverrideForbidden              string = "BuildRunBuildFieldOverrideForbidden"
)

Common condition strings for reason, kind, etc.

View Source
const (
	// DefaultServiceAccountName defines the default sa name
	// in vanilla Kubernetes clusters
	DefaultServiceAccountName = "default"
	// PipelineServiceAccountName defines the default sa name
	// in vanilla OpenShift clusters
	PipelineServiceAccountName = "pipeline"
)

Variables

This section is empty.

Functions

func AmendTaskSpecWithSources added in v0.5.0

func AmendTaskSpecWithSources(
	cfg *config.Config,
	taskSpec *pipeline.TaskSpec,
	build *buildv1alpha1.Build,
	buildRun *buildv1alpha1.BuildRun,
)

AmendTaskSpecWithSources adds the necessary steps to either wait for user upload ("LocalCopy"), or alternatively, configures the Task steps to use bundle and "git clone".

func ApplyCredentials

func ApplyCredentials(ctx context.Context, build *buildv1alpha1.Build, buildRun *buildv1alpha1.BuildRun, serviceAccount *corev1.ServiceAccount) bool

ApplyCredentials adds all credentials that are referenced by the build and adds them to the service account. The function returns true if the service account was modified.

func CheckTaskRunVolumesExist added in v0.10.0

func CheckTaskRunVolumesExist(ctx context.Context, client client.Client, taskRun *v1beta1.TaskRun) error

CheckTaskRunVolumesExist tries to find some of the volumes referenced by the BuildRun with all the overrides. If some secret or configmap does not exist in the namespace, function returns error describing the missing resource

func DeleteServiceAccount added in v0.6.0

func DeleteServiceAccount(ctx context.Context, client client.Client, completedBuildRun *buildv1alpha1.BuildRun) error

DeleteServiceAccount deletes the service account of a completed BuildRun if the service account was generated

func FindParamValueByName added in v0.8.0

func FindParamValueByName(paramValues []buildv1alpha1.ParamValue, name string) *buildv1alpha1.ParamValue

FindParamValueByName returns the first entry in a ParamValue array with a specified name, or nil

func FindParameterByName added in v0.8.0

func FindParameterByName(parameters []buildv1alpha1.Parameter, name string) *buildv1alpha1.Parameter

FindParameterByName returns the first entry in a Parameter array with a specified name, or nil

func GenerateSA

func GenerateSA(ctx context.Context, client client.Client, build *buildv1alpha1.Build, buildRun *buildv1alpha1.BuildRun) (serviceAccount *corev1.ServiceAccount, err error)

GenerateSA generates a new service account on the fly

func GenerateTaskRun

func GenerateTaskRun(
	cfg *config.Config,
	build *buildv1alpha1.Build,
	buildRun *buildv1alpha1.BuildRun,
	serviceAccountName string,
	strategy buildv1alpha1.BuilderStrategy,
) (*v1beta1.TaskRun, error)

GenerateTaskRun creates a Tekton TaskRun to be used for a build run

func GenerateTaskSpec

func GenerateTaskSpec(
	cfg *config.Config,
	build *buildv1alpha1.Build,
	buildRun *buildv1alpha1.BuildRun,
	buildSteps []buildv1alpha1.BuildStep,
	parameterDefinitions []buildv1alpha1.Parameter,
	buildStrategyVolumes []buildv1alpha1.BuildStrategyVolume,
) (*v1beta1.TaskSpec, error)

GenerateTaskSpec creates Tekton TaskRun spec to be used for a build run

func GetBuildObject

func GetBuildObject(ctx context.Context, client client.Client, buildRun *buildv1alpha1.BuildRun, build *buildv1alpha1.Build) error

GetBuildObject retrieves an existing Build based on a name and namespace

func GetGeneratedServiceAccountName

func GetGeneratedServiceAccountName(buildRun *buildv1alpha1.BuildRun) string

GetGeneratedServiceAccountName returns the name of the generated service account for a build run

func HandleTaskRunParam added in v0.8.0

func HandleTaskRunParam(taskRun *pipeline.TaskRun, parameterDefinition *buildv1alpha1.Parameter, paramValue buildv1alpha1.ParamValue) error

HandleTaskRunParam makes the necessary changes to a TaskRun for a parameter

func IsClientStatusUpdateError

func IsClientStatusUpdateError(err error) bool

IsClientStatusUpdateError checks whether the given error is of type ClientStatusUpdateError or in case this is a list of errors, that it contains at least one error of type ClientStatusUpdateError

func IsGeneratedServiceAccountUsed

func IsGeneratedServiceAccountUsed(buildRun *buildv1alpha1.BuildRun) bool

IsGeneratedServiceAccountUsed checks if a build run uses a generated service account

func IsOwnedByBuild

func IsOwnedByBuild(build *buildv1alpha1.Build, controlledReferences []metav1.OwnerReference) bool

IsOwnedByBuild checks if the controllerReferences contains a well known owner Kind

func IsSystemReservedParameter added in v0.6.0

func IsSystemReservedParameter(param string) bool

IsSystemReservedParameter verifies if we are using a system reserved parameter name

func OverrideParams added in v0.9.0

func OverrideParams(originalParams []buildv1alpha1.ParamValue, overrideParams []buildv1alpha1.ParamValue) []buildv1alpha1.ParamValue

OverrideParams allows to override an existing list of parameters with a second list, as long as their entry names matches

func RetrieveBuildStrategy

func RetrieveBuildStrategy(ctx context.Context, client client.Client, build *buildv1alpha1.Build) (*buildv1alpha1.BuildStrategy, error)

RetrieveBuildStrategy returns a namespace scoped strategy

func RetrieveClusterBuildStrategy

func RetrieveClusterBuildStrategy(ctx context.Context, client client.Client, build *buildv1alpha1.Build) (*buildv1alpha1.ClusterBuildStrategy, error)

RetrieveClusterBuildStrategy returns a cluster scoped strategy

func RetrieveServiceAccount

func RetrieveServiceAccount(ctx context.Context, client client.Client, build *buildv1alpha1.Build, buildRun *buildv1alpha1.BuildRun) (serviceAccount *corev1.ServiceAccount, err error)

RetrieveServiceAccount provides either a default sa with a referenced secret or it will generate a new sa on the fly. When not using the generate feature, it will modify and return the default sa from a k8s namespace, which is "default" or the default sa inside an openshift namespace, which is "pipeline".

func SetupImageProcessing added in v0.12.0

func SetupImageProcessing(taskRun *pipeline.TaskRun, cfg *config.Config, buildOutput, buildRunOutput build.Image)

SetupImageProcessing appends the image-processing step to a TaskRun if desired

func UpdateBuildRunUsingTaskFailures added in v0.8.0

func UpdateBuildRunUsingTaskFailures(ctx context.Context, client client.Client, buildRun *buildv1alpha1.BuildRun, taskRun *v1beta1.TaskRun)

UpdateBuildRunUsingTaskFailures is extracting failures from taskRun steps and adding them to buildRun (mutates)

func UpdateBuildRunUsingTaskResults added in v0.6.0

func UpdateBuildRunUsingTaskResults(
	ctx context.Context,
	buildRun *build.BuildRun,
	taskRunResult []pipeline.TaskRunResult,
	request reconcile.Request,
)

UpdateBuildRunUsingTaskResults surface the task results to the buildrun

func UpdateBuildRunUsingTaskRunCondition

func UpdateBuildRunUsingTaskRunCondition(ctx context.Context, client client.Client, buildRun *buildv1alpha1.BuildRun, taskRun *v1beta1.TaskRun, trCondition *apis.Condition) error

UpdateBuildRunUsingTaskRunCondition updates the BuildRun Succeeded Condition

func UpdateConditionWithFalseStatus

func UpdateConditionWithFalseStatus(ctx context.Context, client client.Client, buildRun *buildv1alpha1.BuildRun, errorMessage string, reason string) error

UpdateConditionWithFalseStatus sets the Succeeded condition fields and mark the condition as Status False. It also updates the object in the cluster by calling client Status Update

Types

type ClientStatusUpdateError

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

ClientStatusUpdateError is an error that occurrs when trying to update a runtime object status

func (ClientStatusUpdateError) Error

func (e ClientStatusUpdateError) Error() string

type Errors

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

Errors allows you to wrap multiple errors in a single struct. Useful when wrapping multiple errors with a single message.

func HandleError

func HandleError(message string, listOfErrors ...error) Errors

HandleError returns multiple errors if each error is not nil. And its error message.

func (Errors) Error

func (e Errors) Error() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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