resources

package
v0.33.2 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2022 License: Apache-2.0 Imports: 25 Imported by: 36

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddInputResource

func AddInputResource(
	ctx context.Context,
	kubeclient kubernetes.Interface,
	images pipeline.Images,
	taskName string,
	taskSpec *v1beta1.TaskSpec,
	taskRun *v1beta1.TaskRun,
	inputResources map[string]v1beta1.PipelineResourceInterface,
) (*v1beta1.TaskSpec, error)

AddInputResource reads the inputs resources and adds the corresponding container steps This function reads the `paths` to check if resource copies needs to be fetched from previous tasks output(from PVC) 1. If resource has paths declared then serially copies the resource from previous task output paths into current resource destination. 2. If resource has custom destination directory using targetPath then that directory is created and resource is fetched / copied from previous task 3. If resource has paths declared then fresh copy of resource is not fetched

func AddOutputImageDigestExporter

func AddOutputImageDigestExporter(
	imageDigestExporterImage string,
	tr *v1beta1.TaskRun,
	taskSpec *v1beta1.TaskSpec,
	gr GetResource,
) error

AddOutputImageDigestExporter add a step to check the index.json for all output images

func AddOutputResources

func AddOutputResources(
	ctx context.Context,
	kubeclient kubernetes.Interface,
	images pipeline.Images,
	taskName string,
	taskSpec *v1beta1.TaskSpec,
	taskRun *v1beta1.TaskRun,
	outputResources map[string]v1beta1.PipelineResourceInterface,
) (*v1beta1.TaskSpec, error)

AddOutputResources reads the output resources and adds the corresponding container steps This function also reads the inputs to check if resources are redeclared in inputs and has any custom target directory. Steps executed:

  1. If taskrun has owner reference as pipelinerun then all outputs are copied to parents PVC

and also runs any custom upload steps (upload to blob store)

  1. If taskrun does not have pipelinerun as owner reference then all outputs resources execute their custom

upload steps (like upload to blob store )

Resource source path determined 1. If resource has a targetpath that is used. Otherwise: 2. If resource is declared in outputs only then the default is /output/resource_name

func ApplyContexts added in v0.14.0

func ApplyContexts(spec *v1beta1.TaskSpec, taskName string, tr *v1beta1.TaskRun) *v1beta1.TaskSpec

ApplyContexts applies the substitution from $(context.(taskRun|task).*) with the specified values. Uses "" as a default if a value is not available.

func ApplyCredentialsPath added in v0.11.0

func ApplyCredentialsPath(spec *v1beta1.TaskSpec, path string) *v1beta1.TaskSpec

ApplyCredentialsPath applies a substitution of the key $(credentials.path) with the path that credentials from annotated secrets are written to.

func ApplyParameters

func ApplyParameters(spec *v1beta1.TaskSpec, tr *v1beta1.TaskRun, defaults ...v1beta1.ParamSpec) *v1beta1.TaskSpec

ApplyParameters applies the params from a TaskRun.Input.Parameters to a TaskSpec

func ApplyReplacements

func ApplyReplacements(spec *v1beta1.TaskSpec, stringReplacements map[string]string, arrayReplacements map[string][]string) *v1beta1.TaskSpec

ApplyReplacements replaces placeholders for declared parameters with the specified replacements.

func ApplyResources

func ApplyResources(spec *v1beta1.TaskSpec, resolvedResources map[string]v1beta1.PipelineResourceInterface, replacementStr string) *v1beta1.TaskSpec

ApplyResources applies the substitution from values in resources which are referenced in spec as subitems of the replacementStr.

func ApplyStepExitCodePath added in v0.27.0

func ApplyStepExitCodePath(spec *v1beta1.TaskSpec) *v1beta1.TaskSpec

ApplyStepExitCodePath replaces the occurrences of exitCode path with the absolute tekton internal path Replace $(steps.<step-name>.exitCode.path) with pipeline.StepPath/<step-name>/exitCode

func ApplyTaskResults added in v0.11.0

func ApplyTaskResults(spec *v1beta1.TaskSpec) *v1beta1.TaskSpec

ApplyTaskResults applies the substitution from values in results which are referenced in spec as subitems of the replacementStr.

func ApplyWorkspaces added in v0.10.0

func ApplyWorkspaces(ctx context.Context, spec *v1beta1.TaskSpec, declarations []v1beta1.WorkspaceDeclaration, bindings []v1beta1.WorkspaceBinding, vols map[string]corev1.Volume) *v1beta1.TaskSpec

ApplyWorkspaces applies the substitution from paths that the workspaces in declarations mounted to, the volumes that bindings are realized with in the task spec and the PersistentVolumeClaim names for the workspaces.

func GetPVCVolume

func GetPVCVolume(name string) corev1.Volume

GetPVCVolume gets pipelinerun pvc volume

func GetResourceFromBinding added in v0.8.0

GetResourceFromBinding will return an instance of a PipelineResource to use for r, either by getting it with getter or by instantiating it from the embedded spec.

func GetTaskData

func GetTaskData(ctx context.Context, taskRun *v1beta1.TaskRun, getTask GetTask) (*metav1.ObjectMeta, *v1beta1.TaskSpec, error)

GetTaskData will retrieve the Task metadata and Spec associated with the provided TaskRun. This can come from a reference Task or from the TaskRun's metadata and embedded TaskSpec.

func GetTaskKind added in v0.25.0

func GetTaskKind(taskrun *v1beta1.TaskRun) v1beta1.TaskKind

GetTaskKind returns the referenced Task kind (Task, ClusterTask, ...) if the TaskRun is using TaskRef.

func IsGetTaskErrTransient added in v0.31.0

func IsGetTaskErrTransient(err error) bool

IsGetTaskErrTransient returns true if an error returned by GetTask is retryable.

Types

type GetClusterTask

type GetClusterTask func(name string) (v1beta1.TaskObject, error)

GetClusterTask is a function that will retrieve the Task from name and namespace.

type GetResource

type GetResource func(string) (*resourcev1alpha1.PipelineResource, error)

GetResource is a function used to retrieve PipelineResources.

type GetTask

type GetTask func(context.Context, string) (v1beta1.TaskObject, error)

GetTask is a function used to retrieve Tasks.

func GetTaskFunc added in v0.18.0

func GetTaskFunc(ctx context.Context, k8s kubernetes.Interface, tekton clientset.Interface, tr *v1beta1.TaskRef, namespace, saName string) (GetTask, error)

GetTaskFunc is a factory function that will use the given TaskRef as context to return a valid GetTask function. It also requires a kubeclient, tektonclient, namespace, and service account in case it needs to find that task in cluster or authorize against an external repositroy. It will figure out whether it needs to look in the cluster or in a remote image to fetch the reference. It will also return the "kind" of the task being referenced.

func GetTaskFuncFromTaskRun added in v0.25.0

func GetTaskFuncFromTaskRun(ctx context.Context, k8s kubernetes.Interface, tekton clientset.Interface, taskrun *v1beta1.TaskRun) (GetTask, error)

GetTaskFuncFromTaskRun is a factory function that will use the given TaskRef as context to return a valid GetTask function. It also requires a kubeclient, tektonclient, namespace, and service account in case it needs to find that task in cluster or authorize against an external repositroy. It will figure out whether it needs to look in the cluster or in a remote image to fetch the reference. It will also return the "kind" of the task being referenced.

type GetTaskRun

type GetTaskRun func(string) (*v1beta1.TaskRun, error)

GetTaskRun is a function used to retrieve TaskRuns

type LocalTaskRefResolver added in v0.12.0

type LocalTaskRefResolver struct {
	Namespace    string
	Kind         v1beta1.TaskKind
	Tektonclient clientset.Interface
}

LocalTaskRefResolver uses the current cluster to resolve a task reference.

func (*LocalTaskRefResolver) GetTask added in v0.12.0

GetTask will resolve either a Task or ClusterTask from the local cluster using a versioned Tekton client. It will return an error if it can't find an appropriate Task for any reason.

type ResolvedTaskResources

type ResolvedTaskResources struct {
	TaskName string
	Kind     v1beta1.TaskKind
	TaskSpec *v1beta1.TaskSpec
	// Inputs is a map from the name of the input required by the Task
	// to the actual Resource to use for it
	Inputs map[string]*resourcev1alpha1.PipelineResource
	// Outputs is a map from the name of the output required by the Task
	// to the actual Resource to use for it
	Outputs map[string]*resourcev1alpha1.PipelineResource
}

ResolvedTaskResources contains all the data that is needed to execute the TaskRun: the TaskRun, it's Task and the PipelineResources it needs.

func ResolveTaskResources

func ResolveTaskResources(ts *v1beta1.TaskSpec, taskName string, kind v1beta1.TaskKind, inputs []v1beta1.TaskResourceBinding, outputs []v1beta1.TaskResourceBinding, gr GetResource) (*ResolvedTaskResources, error)

ResolveTaskResources looks up PipelineResources referenced by inputs and outputs and returns a structure that unites the resolved references and the Task Spec. If referenced PipelineResources can't be found, an error is returned.

Jump to

Keyboard shortcuts

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