processor

package
v0.7.6 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	LighthouseTaskParams = []v1beta1.ParamSpec{
		{
			Name:        "BUILD_ID",
			Type:        "string",
			Description: "The unique build number",
			Default:     nil,
		},
		{
			Name:        "JOB_NAME",
			Type:        "string",
			Description: "The fileName of the job which is the trigger context fileName",
			Default:     nil,
		},
		{
			Name:        "JOB_SPEC",
			Type:        "string",
			Description: "The specification of the job",
			Default:     nil,
		},
		{
			Name:        "JOB_TYPE",
			Type:        "string",
			Description: "The kind of the job: postsubmit or presubmit",
			Default:     nil,
		},
		{
			Name:        "PULL_BASE_REF",
			Type:        "string",
			Description: "The base git reference of the pull request",
			Default:     nil,
		},
		{
			Name:        "PULL_BASE_SHA",
			Type:        "string",
			Description: "The git sha of the base of the pull request",
			Default:     nil,
		},
		{
			Name:        "PULL_NUMBER",
			Type:        "string",
			Description: "The git pull request number",
			Default:     &v1beta1.ParamValue{Type: "string", StringVal: ""},
		},
		{
			Name:        "PULL_PULL_REF",
			Type:        "string",
			Description: "The git pull request ref in the form 'refs/pull/$PULL_NUMBER/head'",
			Default:     &v1beta1.ParamValue{Type: "string", StringVal: ""},
		},
		{
			Name:        "PULL_PULL_SHA",
			Type:        "string",
			Description: "The git pull reference strings of base and latest in the form 'master:$PULL_BASE_SHA,$PULL_NUMBER:$PULL_PULL_SHA:refs/pull/$PULL_NUMBER/head'",
			Default:     nil,
		},
		{
			Name:        "PULL_REFS",
			Type:        "string",
			Description: "The git pull reference strings of base and latest in the form 'master:$PULL_BASE_SHA,$PULL_NUMBER:$PULL_PULL_SHA:refs/pull/$PULL_NUMBER/head'",
			Default:     nil,
		},
		{
			Name:        "REPO_NAME",
			Type:        "string",
			Description: "The git repository fileName",
			Default:     nil,
		},
		{
			Name:        "REPO_OWNER",
			Type:        "string",
			Description: "The git repository owner (user or organisation)",
			Default:     nil,
		},
		{
			Name:        "REPO_URL",
			Type:        "string",
			Description: "The URL of the git repo to clone",
			Default:     nil,
		},
	}

	LighthouseEnvs = ParamsToEnvVars(LighthouseTaskParams)

	HomeEnv = v1.EnvVar{
		Name:  "HOME",
		Value: "/workspace",
	}

	DefaultEnvFroms = []v1.EnvFromSource{
		{
			SecretRef: &v1.SecretEnvSource{
				LocalObjectReference: v1.LocalObjectReference{
					Name: "jx-boot-job-env-vars",
				},
				Optional: &trueRef,
			},
		},
	}
)

Functions

func AppendEnvsFromIfNotPresent added in v0.6.0

func AppendEnvsFromIfNotPresent(existing, toAdd []v1.EnvFromSource) []v1.EnvFromSource

func AppendEnvsIfNotPresent added in v0.6.0

func AppendEnvsIfNotPresent(existing, toAdd []v1.EnvVar) []v1.EnvVar

func AppendParamsIfNotPresent added in v0.6.0

func AppendParamsIfNotPresent(existing, toAdd []tektonv1beta1.ParamSpec) []tektonv1beta1.ParamSpec

func ConvertLegacyStepAnnotationURLToUsesImage

func ConvertLegacyStepAnnotationURLToUsesImage(ann map[string]string, key string) string

ConvertLegacyStepAnnotationURLToUsesImage converts the given append annotation URL to a uses string if its not blank

func FindStep

func FindStep(spec *v1beta1.TaskSpec, name string) *v1beta1.Step

FindStep returns the named step or nil

func ImageWithoutVersionTag

func ImageWithoutVersionTag(image string) string

ImageWithoutVersionTag returns the image string without any version tag.

func NewInliner

func NewInliner(input input.Interface, resolver *inrepo.UsesResolver, defaultSHA, step string, inlineProperties []string) *inliner

NewInliner

func NewModifier added in v0.0.135

func NewModifier(templateEnvs map[string]string) *modifier

NewModifier

func ParamsToEnvVars added in v0.6.0

func ParamsToEnvVars(params []tektonv1beta1.ParamSpec) []v1.EnvVar

func ProcessFile

func ProcessFile(processor Interface, path string) (bool, error)

ProcessFile processes the given file with the processor

func ProcessPipelineSpec

func ProcessPipelineSpec(ps *tektonv1beta1.PipelineSpec, path string, fn func(ts *tektonv1beta1.TaskSpec, path, name string) (bool, error)) (bool, error)

ProcessPipelineSpec default function for processing a pipeline spec which may be nil

func ReplaceOrAppendEnv added in v0.6.0

func ReplaceOrAppendEnv(existing []v1.EnvVar, toAdd v1.EnvVar) []v1.EnvVar

Types

type GitRef added in v0.7.0

type GitRef struct {
	URL        string
	Org        string
	Repository string
	Revision   string
	PathInRepo string
	IsPublic   bool
}

GitRef is a representation of the Tekton git resolver params

func (*GitRef) GetParentFileName added in v0.7.0

func (g *GitRef) GetParentFileName() string

GetParentFileName returns the filename of the parent pipeline run

func (*GitRef) ToParams added in v0.7.0

func (g *GitRef) ToParams() []v1beta1.Param

ToParams converts the GitRef to a slice of v1beta1.Param. If the GitRef is public, the URL param is used, otherwise the org and repo params are used

func (*GitRef) ToResolverRef added in v0.7.0

func (g *GitRef) ToResolverRef() v1beta1.ResolverRef

ToResolverRef converts the GitRef to a v1beta1.ResolverRef

type GitRefResolver added in v0.7.0

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

func NewGitRefResolver added in v0.7.0

func NewGitRefResolver(reversionOverride string) *GitRefResolver

func (*GitRefResolver) NewRefFromUsesImage added in v0.7.0

func (g *GitRefResolver) NewRefFromUsesImage(image, stepName string) (*GitRef, error)

NewRefFromUsesImage parses an image name of "uses:image" syntax as a GitRef

type Interface

type Interface interface {
	// ProcessTask processes a Task and returns if its modified and/or error
	ProcessTask(task *tektonv1beta1.Task, path string) (bool, error)

	// ProcessTaskRun processes a TaskRun and returns if its modified and/or error
	ProcessTaskRun(tr *tektonv1beta1.TaskRun, path string) (bool, error)

	// ProcessPipeline processes a Pipeline and returns if its modified and/or error
	ProcessPipeline(pipeline *tektonv1beta1.Pipeline, path string) (bool, error)

	// ProcessPipelineRun processes a PipelineRun and returns if its modified and/or error
	ProcessPipelineRun(prs *tektonv1beta1.PipelineRun, path string) (bool, error)
}

Interface the interface for a pipeline processor

type RemoteTasksMigrator added in v0.6.0

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

func NewRemoteTasksMigrator added in v0.6.0

func NewRemoteTasksMigrator(overrideSHA string, workspaceVolumeQuantity resource.Quantity) *RemoteTasksMigrator

NewRemoteTasksMigrator creates a new uses migrator

func (*RemoteTasksMigrator) NewPipelineTaskFromStepAndPipelineRun added in v0.6.0

func (p *RemoteTasksMigrator) NewPipelineTaskFromStepAndPipelineRun(step *v1beta1.Step, prs *v1beta1.PipelineRun) (v1beta1.PipelineTask, error)

func (*RemoteTasksMigrator) NewTaskFromStepAndPipelineRun added in v0.6.0

func (p *RemoteTasksMigrator) NewTaskFromStepAndPipelineRun(step *v1beta1.Step, prs *v1beta1.PipelineRun, isEmbeddedTask bool) (v1beta1.Task, error)

NewTaskFromStepAndPipelineRun takes a step and a PipelineRun and creates a Task from them.

func (*RemoteTasksMigrator) ProcessPipeline added in v0.6.0

func (p *RemoteTasksMigrator) ProcessPipeline(pipeline *v1beta1.Pipeline, path string) (bool, error)

func (*RemoteTasksMigrator) ProcessPipelineRun added in v0.6.0

func (p *RemoteTasksMigrator) ProcessPipelineRun(prs *v1beta1.PipelineRun, path string) (bool, error)

ProcessPipelineRun processes a PipelineRun and migrates it to either a new PipelineRun or to individual Tasks based on whether it is a parent or child PipelineRun

func (*RemoteTasksMigrator) ProcessTask added in v0.6.0

func (p *RemoteTasksMigrator) ProcessTask(task *v1beta1.Task, path string) (bool, error)

ProcessTask processes a task and appends the default params and environment variables to it

func (*RemoteTasksMigrator) ProcessTaskRun added in v0.6.0

func (p *RemoteTasksMigrator) ProcessTaskRun(tr *v1beta1.TaskRun, path string) (bool, error)

type UsesMigrator

type UsesMigrator struct {
	CatalogTaskSpec *v1beta1.TaskSpec
	Dir             string
	Owner           string
	Repository      string
	TasksFolder     string
	SHA             string
	UseSHA          string
	// contains filtered or unexported fields
}

func NewUsesMigrator

func NewUsesMigrator(dir, tasksFolder, owner, repository, useSHA string, catalog bool) *UsesMigrator

NewUsesMigrator creates a new uses migrator

func (*UsesMigrator) ProcessPipeline

func (p *UsesMigrator) ProcessPipeline(pipeline *v1beta1.Pipeline, path string) (bool, error)

func (*UsesMigrator) ProcessPipelineRun

func (p *UsesMigrator) ProcessPipelineRun(prs *v1beta1.PipelineRun, path string) (bool, error)

func (*UsesMigrator) ProcessTask

func (p *UsesMigrator) ProcessTask(task *v1beta1.Task, path string) (bool, error)

func (*UsesMigrator) ProcessTaskRun

func (p *UsesMigrator) ProcessTaskRun(tr *v1beta1.TaskRun, path string) (bool, error)

Jump to

Keyboard shortcuts

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