code
stringlengths 12
335k
| docstring
stringlengths 20
20.8k
| func_name
stringlengths 1
105
| language
stringclasses 1
value | repo
stringclasses 498
values | path
stringlengths 5
172
| url
stringlengths 43
235
| license
stringclasses 4
values |
---|---|---|---|---|---|---|---|
func (in *WhenExpression) DeepCopyInto(out *WhenExpression) {
*out = *in
if in.Values != nil {
in, out := &in.Values, &out.Values
*out = make([]string, len(*in))
copy(*out, *in)
}
return
} | DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. | DeepCopyInto | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/zz_generated.deepcopy.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/zz_generated.deepcopy.go | Apache-2.0 |
func (in *WhenExpression) DeepCopy() *WhenExpression {
if in == nil {
return nil
}
out := new(WhenExpression)
in.DeepCopyInto(out)
return out
} | DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WhenExpression. | DeepCopy | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/zz_generated.deepcopy.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/zz_generated.deepcopy.go | Apache-2.0 |
func (in WhenExpressions) DeepCopyInto(out *WhenExpressions) {
{
in := &in
*out = make(WhenExpressions, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
return
}
} | DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. | DeepCopyInto | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/zz_generated.deepcopy.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/zz_generated.deepcopy.go | Apache-2.0 |
func (in WhenExpressions) DeepCopy() WhenExpressions {
if in == nil {
return nil
}
out := new(WhenExpressions)
in.DeepCopyInto(out)
return *out
} | DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WhenExpressions. | DeepCopy | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/zz_generated.deepcopy.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/zz_generated.deepcopy.go | Apache-2.0 |
func (in *WorkspaceBinding) DeepCopyInto(out *WorkspaceBinding) {
*out = *in
if in.VolumeClaimTemplate != nil {
in, out := &in.VolumeClaimTemplate, &out.VolumeClaimTemplate
*out = new(corev1.PersistentVolumeClaim)
(*in).DeepCopyInto(*out)
}
if in.PersistentVolumeClaim != nil {
in, out := &in.PersistentVolumeClaim, &out.PersistentVolumeClaim
*out = new(corev1.PersistentVolumeClaimVolumeSource)
**out = **in
}
if in.EmptyDir != nil {
in, out := &in.EmptyDir, &out.EmptyDir
*out = new(corev1.EmptyDirVolumeSource)
(*in).DeepCopyInto(*out)
}
if in.ConfigMap != nil {
in, out := &in.ConfigMap, &out.ConfigMap
*out = new(corev1.ConfigMapVolumeSource)
(*in).DeepCopyInto(*out)
}
if in.Secret != nil {
in, out := &in.Secret, &out.Secret
*out = new(corev1.SecretVolumeSource)
(*in).DeepCopyInto(*out)
}
if in.Projected != nil {
in, out := &in.Projected, &out.Projected
*out = new(corev1.ProjectedVolumeSource)
(*in).DeepCopyInto(*out)
}
if in.CSI != nil {
in, out := &in.CSI, &out.CSI
*out = new(corev1.CSIVolumeSource)
(*in).DeepCopyInto(*out)
}
return
} | DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. | DeepCopyInto | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/zz_generated.deepcopy.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/zz_generated.deepcopy.go | Apache-2.0 |
func (in *WorkspaceBinding) DeepCopy() *WorkspaceBinding {
if in == nil {
return nil
}
out := new(WorkspaceBinding)
in.DeepCopyInto(out)
return out
} | DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WorkspaceBinding. | DeepCopy | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/zz_generated.deepcopy.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/zz_generated.deepcopy.go | Apache-2.0 |
func (in *WorkspaceDeclaration) DeepCopyInto(out *WorkspaceDeclaration) {
*out = *in
return
} | DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. | DeepCopyInto | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/zz_generated.deepcopy.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/zz_generated.deepcopy.go | Apache-2.0 |
func (in *WorkspaceDeclaration) DeepCopy() *WorkspaceDeclaration {
if in == nil {
return nil
}
out := new(WorkspaceDeclaration)
in.DeepCopyInto(out)
return out
} | DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WorkspaceDeclaration. | DeepCopy | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/zz_generated.deepcopy.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/zz_generated.deepcopy.go | Apache-2.0 |
func (in *WorkspacePipelineTaskBinding) DeepCopyInto(out *WorkspacePipelineTaskBinding) {
*out = *in
return
} | DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. | DeepCopyInto | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/zz_generated.deepcopy.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/zz_generated.deepcopy.go | Apache-2.0 |
func (in *WorkspacePipelineTaskBinding) DeepCopy() *WorkspacePipelineTaskBinding {
if in == nil {
return nil
}
out := new(WorkspacePipelineTaskBinding)
in.DeepCopyInto(out)
return out
} | DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WorkspacePipelineTaskBinding. | DeepCopy | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/zz_generated.deepcopy.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/zz_generated.deepcopy.go | Apache-2.0 |
func (in *WorkspaceUsage) DeepCopyInto(out *WorkspaceUsage) {
*out = *in
return
} | DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. | DeepCopyInto | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/zz_generated.deepcopy.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/zz_generated.deepcopy.go | Apache-2.0 |
func (in *WorkspaceUsage) DeepCopy() *WorkspaceUsage {
if in == nil {
return nil
}
out := new(WorkspaceUsage)
in.DeepCopyInto(out)
return out
} | DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WorkspaceUsage. | DeepCopy | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/zz_generated.deepcopy.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/zz_generated.deepcopy.go | Apache-2.0 |
func (w *WorkspaceBinding) ConvertFrom(ctx context.Context, source v1.WorkspaceBinding) {
w.Name = source.Name
w.SubPath = source.SubPath
w.VolumeClaimTemplate = source.VolumeClaimTemplate
w.PersistentVolumeClaim = source.PersistentVolumeClaim
w.EmptyDir = source.EmptyDir
w.ConfigMap = source.ConfigMap
w.Secret = source.Secret
w.Projected = source.Projected
w.CSI = source.CSI
} | ConvertFrom converts v1beta1 Param from v1 Param | ConvertFrom | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/workspace_conversion.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/workspace_conversion.go | Apache-2.0 |
func (t *ClusterTask) Validate(ctx context.Context) *apis.FieldError {
if apis.IsInDelete(ctx) {
return nil
}
errs := validate.ObjectMetadata(t.GetObjectMeta()).ViaField("metadata")
errs = errs.Also(t.Spec.Validate(apis.WithinSpec(ctx)).ViaField("spec"))
// We do not support propagated parameters in ClusterTasks.
// Validate that all params the ClusterTask uses are declared.
return errs.Also(ValidateUsageOfDeclaredParameters(ctx, t.Spec.Steps, t.Spec.Params))
} | Validate performs validation of the metadata and spec of this ClusterTask. | Validate | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/cluster_task_validation.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/cluster_task_validation.go | Apache-2.0 |
func (ref *PipelineRef) Validate(ctx context.Context) (errs *apis.FieldError) {
if ref == nil {
return errs
}
if apis.IsInCreate(ctx) && ref.Bundle != "" {
errs = errs.Also(apis.ErrDisallowedFields("bundle"))
}
switch {
case ref.Resolver != "" || ref.Params != nil:
if ref.Params != nil {
errs = errs.Also(config.ValidateEnabledAPIFields(ctx, "resolver params", config.BetaAPIFields).ViaField("params"))
if ref.Name != "" {
errs = errs.Also(apis.ErrMultipleOneOf("name", "params"))
}
if ref.Resolver == "" {
errs = errs.Also(apis.ErrMissingField("resolver"))
}
errs = errs.Also(ValidateParameters(ctx, ref.Params))
}
if ref.Resolver != "" {
errs = errs.Also(config.ValidateEnabledAPIFields(ctx, "resolver", config.BetaAPIFields).ViaField("resolver"))
if ref.Name != "" {
// make sure that the name is url-like.
err := RefNameLikeUrl(ref.Name)
if err == nil && !config.FromContextOrDefaults(ctx).FeatureFlags.EnableConciseResolverSyntax {
// If name is url-like then concise resolver syntax must be enabled
errs = errs.Also(apis.ErrGeneric(fmt.Sprintf("feature flag %s should be set to true to use concise resolver syntax", config.EnableConciseResolverSyntax), ""))
}
if err != nil {
errs = errs.Also(apis.ErrInvalidValue(err, "name"))
}
}
}
case ref.Name != "":
// ref name can be a Url-like format.
if err := RefNameLikeUrl(ref.Name); err == nil {
// If name is url-like then concise resolver syntax must be enabled
if !config.FromContextOrDefaults(ctx).FeatureFlags.EnableConciseResolverSyntax {
errs = errs.Also(apis.ErrGeneric(fmt.Sprintf("feature flag %s should be set to true to use concise resolver syntax", config.EnableConciseResolverSyntax), ""))
}
// In stage1 of concise remote resolvers syntax, this is a required field.
// TODO: remove this check when implementing stage 2 where this is optional.
if ref.Resolver == "" {
errs = errs.Also(apis.ErrMissingField("resolver"))
}
// Or, it must be a valid k8s name
} else {
// ref name must be a valid k8s name
if errSlice := validation.IsQualifiedName(ref.Name); len(errSlice) != 0 {
errs = errs.Also(apis.ErrInvalidValue(strings.Join(errSlice, ","), "name"))
}
}
default:
errs = errs.Also(apis.ErrMissingField("name"))
}
return //nolint:nakedret
} | Validate ensures that a supplied PipelineRef field is populated
correctly. No errors are returned for a nil PipelineRef. | Validate | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipelineref_validation.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipelineref_validation.go | Apache-2.0 |
func (s *StepAction) SetDefaults(ctx context.Context) {
s.Spec.SetDefaults(ctx)
} | SetDefaults implements apis.Defaultable | SetDefaults | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/stepaction_defaults.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/stepaction_defaults.go | Apache-2.0 |
func (ss *StepActionSpec) SetDefaults(ctx context.Context) {
for i := range ss.Params {
ss.Params[i].SetDefaults(ctx)
}
for i := range ss.Results {
ss.Results[i].SetDefaults(ctx)
}
} | SetDefaults set any defaults for the StepAction spec | SetDefaults | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/stepaction_defaults.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/stepaction_defaults.go | Apache-2.0 |
func (pr *PipelineRun) SupportedVerbs() []admissionregistrationv1.OperationType {
return []admissionregistrationv1.OperationType{admissionregistrationv1.Create, admissionregistrationv1.Update}
} | SupportedVerbs returns the operations that validation should be called for | SupportedVerbs | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipelinerun_validation.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipelinerun_validation.go | Apache-2.0 |
func (pr *PipelineRun) Validate(ctx context.Context) *apis.FieldError {
if apis.IsInDelete(ctx) {
return nil
}
errs := validate.ObjectMetadata(pr.GetObjectMeta()).ViaField("metadata")
if pr.IsPending() && pr.HasStarted() {
errs = errs.Also(apis.ErrInvalidValue("PipelineRun cannot be Pending after it is started", "spec.status"))
}
return errs.Also(pr.Spec.Validate(apis.WithinSpec(ctx)).ViaField("spec"))
} | Validate pipelinerun | Validate | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipelinerun_validation.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipelinerun_validation.go | Apache-2.0 |
func (ps *PipelineRunSpec) Validate(ctx context.Context) (errs *apis.FieldError) {
// Validate the spec changes
errs = errs.Also(ps.ValidateUpdate(ctx))
// Must have exactly one of pipelineRef and pipelineSpec.
if ps.PipelineRef == nil && ps.PipelineSpec == nil {
errs = errs.Also(apis.ErrMissingOneOf("pipelineRef", "pipelineSpec"))
}
if ps.PipelineRef != nil && ps.PipelineSpec != nil {
errs = errs.Also(apis.ErrMultipleOneOf("pipelineRef", "pipelineSpec"))
}
// Validate PipelineRef if it's present
if ps.PipelineRef != nil {
errs = errs.Also(ps.PipelineRef.Validate(ctx).ViaField("pipelineRef"))
}
// Validate PipelineSpec if it's present
if ps.PipelineSpec != nil {
if slices.Contains(strings.Split(
config.FromContextOrDefaults(ctx).FeatureFlags.DisableInlineSpec, ","), "pipelinerun") {
errs = errs.Also(apis.ErrDisallowedFields("pipelineSpec"))
}
errs = errs.Also(ps.PipelineSpec.Validate(ctx).ViaField("pipelineSpec"))
}
// Validate PipelineRun parameters
errs = errs.Also(ps.validatePipelineRunParameters(ctx))
// Validate propagated parameters
errs = errs.Also(ps.validateInlineParameters(ctx))
// Validate propagated workspaces
errs = errs.Also(ps.validatePropagatedWorkspaces(ctx))
if ps.Timeout != nil {
// timeout should be a valid duration of at least 0.
if ps.Timeout.Duration < 0 {
errs = errs.Also(apis.ErrInvalidValue(ps.Timeout.Duration.String()+" should be >= 0", "timeout"))
}
}
if ps.Timeouts != nil {
if ps.Timeout != nil {
// can't have both at the same time
errs = errs.Also(apis.ErrDisallowedFields("timeout", "timeouts"))
}
// tasks timeout should be a valid duration of at least 0.
errs = errs.Also(validateTimeoutDuration("tasks", ps.Timeouts.Tasks))
// finally timeout should be a valid duration of at least 0.
errs = errs.Also(validateTimeoutDuration("finally", ps.Timeouts.Finally))
// pipeline timeout should be a valid duration of at least 0.
errs = errs.Also(validateTimeoutDuration("pipeline", ps.Timeouts.Pipeline))
if ps.Timeouts.Pipeline != nil {
errs = errs.Also(ps.validatePipelineTimeout(ps.Timeouts.Pipeline.Duration, "should be <= pipeline duration"))
} else {
defaultTimeout := time.Duration(config.FromContextOrDefaults(ctx).Defaults.DefaultTimeoutMinutes)
errs = errs.Also(ps.validatePipelineTimeout(defaultTimeout, "should be <= default timeout duration"))
}
}
errs = errs.Also(validateSpecStatus(ps.Status))
if ps.Workspaces != nil {
wsNames := make(map[string]int)
for idx, ws := range ps.Workspaces {
errs = errs.Also(ws.Validate(ctx).ViaFieldIndex("workspaces", idx))
if prevIdx, alreadyExists := wsNames[ws.Name]; alreadyExists {
errs = errs.Also(apis.ErrGeneric(fmt.Sprintf("workspace %q provided by pipelinerun more than once, at index %d and %d", ws.Name, prevIdx, idx), "name").ViaFieldIndex("workspaces", idx))
}
wsNames[ws.Name] = idx
}
}
for idx, trs := range ps.TaskRunSpecs {
errs = errs.Also(validateTaskRunSpec(ctx, trs).ViaIndex(idx).ViaField("taskRunSpecs"))
}
if ps.PodTemplate != nil {
errs = errs.Also(validatePodTemplateEnv(ctx, *ps.PodTemplate))
}
if ps.Resources != nil {
errs = errs.Also(apis.ErrDisallowedFields("resources"))
}
return errs
} | Validate pipelinerun spec | Validate | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipelinerun_validation.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipelinerun_validation.go | Apache-2.0 |
func (ps *PipelineRunSpec) ValidateUpdate(ctx context.Context) (errs *apis.FieldError) {
if !apis.IsInUpdate(ctx) {
return
}
oldObj, ok := apis.GetBaseline(ctx).(*PipelineRun)
if !ok || oldObj == nil {
return
}
old := &oldObj.Spec
// If already in the done state, the spec cannot be modified. Otherwise, only the status field can be modified.
tips := "Once the PipelineRun is complete, no updates are allowed"
if !oldObj.IsDone() {
old = old.DeepCopy()
old.Status = ps.Status
tips = "Once the PipelineRun has started, only status updates are allowed"
}
if !equality.Semantic.DeepEqual(old, ps) {
errs = errs.Also(apis.ErrInvalidValue(tips, ""))
}
return
} | ValidateUpdate validates the update of a PipelineRunSpec | ValidateUpdate | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipelinerun_validation.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipelinerun_validation.go | Apache-2.0 |
func (ps *PipelineRunSpec) validatePropagatedWorkspaces(ctx context.Context) (errs *apis.FieldError) {
if ps.PipelineSpec == nil {
return errs
}
workspaceNames := sets.NewString()
for _, w := range ps.Workspaces {
workspaceNames.Insert(w.Name)
}
for _, w := range ps.PipelineSpec.Workspaces {
workspaceNames.Insert(w.Name)
}
for i, pt := range ps.PipelineSpec.Tasks {
for _, w := range pt.Workspaces {
workspaceNames.Insert(w.Name)
}
errs = errs.Also(pt.validateWorkspaces(workspaceNames).ViaIndex(i))
}
for i, pt := range ps.PipelineSpec.Finally {
for _, w := range pt.Workspaces {
workspaceNames.Insert(w.Name)
}
errs = errs.Also(pt.validateWorkspaces(workspaceNames).ViaIndex(i))
}
return errs
} | validatePropagatedWorkspaces validates workspaces that are propagated. | validatePropagatedWorkspaces | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipelinerun_validation.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipelinerun_validation.go | Apache-2.0 |
func (ps *PipelineRunSpec) validateInlineParameters(ctx context.Context) (errs *apis.FieldError) {
if ps.PipelineSpec == nil {
return errs
}
paramSpecForValidation := make(map[string]ParamSpec)
for _, p := range ps.Params {
paramSpecForValidation = createParamSpecFromParam(p, paramSpecForValidation)
}
for _, p := range ps.PipelineSpec.Params {
var err *apis.FieldError
paramSpecForValidation, err = combineParamSpec(p, paramSpecForValidation)
if err != nil {
errs = errs.Also(err)
}
}
for _, pt := range ps.PipelineSpec.Tasks {
paramSpecForValidation = appendPipelineTaskParams(paramSpecForValidation, pt.Params)
if pt.TaskSpec != nil && pt.TaskSpec.Params != nil {
for _, p := range pt.TaskSpec.Params {
var err *apis.FieldError
paramSpecForValidation, err = combineParamSpec(p, paramSpecForValidation)
if err != nil {
errs = errs.Also(err)
}
}
}
}
var paramSpec []ParamSpec
for _, v := range paramSpecForValidation {
paramSpec = append(paramSpec, v)
}
if ps.PipelineSpec != nil && ps.PipelineSpec.Tasks != nil {
for _, pt := range ps.PipelineSpec.Tasks {
if pt.TaskSpec != nil && pt.TaskSpec.Steps != nil {
errs = errs.Also(ValidateParameterTypes(ctx, paramSpec))
errs = errs.Also(ValidateParameterVariables(ctx, pt.TaskSpec.Steps, paramSpec))
errs = errs.Also(ValidateUsageOfDeclaredParameters(ctx, pt.TaskSpec.Steps, paramSpec))
}
}
errs = errs.Also(ValidatePipelineParameterVariables(ctx, ps.PipelineSpec.Tasks, paramSpec))
errs = errs.Also(validatePipelineTaskParameterUsage(ps.PipelineSpec.Tasks, paramSpec))
}
return errs
} | validateInlineParameters validates parameters that are defined inline.
This is crucial for propagated parameters since the parameters could
be defined under pipelineRun and then called directly in the task steps.
In this case, parameters cannot be validated by the underlying pipelineSpec
or taskSpec since they may not have the parameters declared because of propagation. | validateInlineParameters | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipelinerun_validation.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipelinerun_validation.go | Apache-2.0 |
func (t *Task) SupportedVerbs() []admissionregistrationv1.OperationType {
return []admissionregistrationv1.OperationType{admissionregistrationv1.Create, admissionregistrationv1.Update}
} | SupportedVerbs returns the operations that validation should be called for | SupportedVerbs | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/task_validation.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/task_validation.go | Apache-2.0 |
func (t *Task) Validate(ctx context.Context) *apis.FieldError {
errs := validate.ObjectMetadata(t.GetObjectMeta()).ViaField("metadata")
errs = errs.Also(t.Spec.Validate(apis.WithinSpec(ctx)).ViaField("spec"))
// When a Task is created directly, instead of declared inline in a TaskRun or PipelineRun,
// we do not support propagated parameters. Validate that all params it uses are declared.
return errs.Also(ValidateUsageOfDeclaredParameters(ctx, t.Spec.Steps, t.Spec.Params).ViaField("spec"))
} | Validate implements apis.Validatable | Validate | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/task_validation.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/task_validation.go | Apache-2.0 |
func (ts *TaskSpec) Validate(ctx context.Context) (errs *apis.FieldError) {
if len(ts.Steps) == 0 {
errs = errs.Also(apis.ErrMissingField("steps"))
}
errs = errs.Also(ValidateVolumes(ts.Volumes).ViaField("volumes"))
errs = errs.Also(validateDeclaredWorkspaces(ts.Workspaces, ts.Steps, ts.StepTemplate).ViaField("workspaces"))
errs = errs.Also(validateWorkspaceUsages(ctx, ts))
mergedSteps, err := MergeStepsWithStepTemplate(ts.StepTemplate, ts.Steps)
if err != nil {
errs = errs.Also(&apis.FieldError{
Message: fmt.Sprintf("error merging step template and steps: %s", err),
Paths: []string{"stepTemplate"},
Details: err.Error(),
})
}
errs = errs.Also(validateSteps(ctx, mergedSteps).ViaField("steps"))
errs = errs.Also(validateSidecarNames(ts.Sidecars))
errs = errs.Also(ValidateParameterTypes(ctx, ts.Params).ViaField("params"))
errs = errs.Also(ValidateParameterVariables(ctx, ts.Steps, ts.Params))
errs = errs.Also(validateTaskContextVariables(ctx, ts.Steps))
errs = errs.Also(validateTaskResultsVariables(ctx, ts.Steps, ts.Results))
errs = errs.Also(validateResults(ctx, ts.Results).ViaField("results"))
if ts.Resources != nil {
errs = errs.Also(apis.ErrDisallowedFields("resources"))
}
return errs
} | Validate implements apis.Validatable | Validate | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/task_validation.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/task_validation.go | Apache-2.0 |
func ValidateUsageOfDeclaredParameters(ctx context.Context, steps []Step, params ParamSpecs) *apis.FieldError {
var errs *apis.FieldError
_, _, objectParams := params.sortByType()
allParameterNames := sets.NewString(params.getNames()...)
errs = errs.Also(validateVariables(ctx, steps, "params", allParameterNames))
errs = errs.Also(validateObjectUsage(ctx, steps, objectParams))
errs = errs.Also(validateObjectParamsHaveProperties(ctx, params))
return errs
} | ValidateUsageOfDeclaredParameters validates that all parameters referenced in the Task are declared by the Task. | ValidateUsageOfDeclaredParameters | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/task_validation.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/task_validation.go | Apache-2.0 |
func validateObjectParamsHaveProperties(ctx context.Context, params ParamSpecs) *apis.FieldError {
var errs *apis.FieldError
for _, p := range params {
if p.Type == ParamTypeObject && p.Properties == nil {
errs = errs.Also(apis.ErrMissingField(p.Name + ".properties"))
}
}
return errs
} | validateObjectParamsHaveProperties returns an error if any declared object params are missing properties | validateObjectParamsHaveProperties | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/task_validation.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/task_validation.go | Apache-2.0 |
func validateDeclaredWorkspaces(workspaces []WorkspaceDeclaration, steps []Step, stepTemplate *StepTemplate) (errs *apis.FieldError) {
mountPaths := sets.NewString()
for _, step := range steps {
for _, vm := range step.VolumeMounts {
mountPaths.Insert(filepath.Clean(vm.MountPath))
}
}
if stepTemplate != nil {
for _, vm := range stepTemplate.VolumeMounts {
mountPaths.Insert(filepath.Clean(vm.MountPath))
}
}
wsNames := sets.NewString()
for idx, w := range workspaces {
// Workspace names must be unique
if wsNames.Has(w.Name) {
errs = errs.Also(apis.ErrGeneric(fmt.Sprintf("workspace name %q must be unique", w.Name), "name").ViaIndex(idx))
} else {
wsNames.Insert(w.Name)
}
// Workspaces must not try to use mount paths that are already used
mountPath := filepath.Clean(w.GetMountPath())
if _, ok := mountPaths[mountPath]; ok {
errs = errs.Also(apis.ErrGeneric(fmt.Sprintf("workspace mount path %q must be unique", mountPath), "mountpath").ViaIndex(idx))
}
mountPaths[mountPath] = struct{}{}
}
return errs
} | a mount path which conflicts with any other declared workspaces, with the explicitly
declared volume mounts, or with the stepTemplate. The names must also be unique. | validateDeclaredWorkspaces | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/task_validation.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/task_validation.go | Apache-2.0 |
func validateWorkspaceUsages(ctx context.Context, ts *TaskSpec) (errs *apis.FieldError) {
workspaces := ts.Workspaces
steps := ts.Steps
sidecars := ts.Sidecars
wsNames := sets.NewString()
for _, w := range workspaces {
wsNames.Insert(w.Name)
}
for stepIdx, step := range steps {
if len(step.Workspaces) != 0 {
errs = errs.Also(config.ValidateEnabledAPIFields(ctx, "step workspaces", config.BetaAPIFields).ViaIndex(stepIdx).ViaField("steps"))
}
for workspaceIdx, w := range step.Workspaces {
if !wsNames.Has(w.Name) {
errs = errs.Also(apis.ErrGeneric(fmt.Sprintf("undefined workspace %q", w.Name), "name").ViaIndex(workspaceIdx).ViaField("workspaces").ViaIndex(stepIdx).ViaField("steps"))
}
}
}
for sidecarIdx, sidecar := range sidecars {
if len(sidecar.Workspaces) != 0 {
errs = errs.Also(config.ValidateEnabledAPIFields(ctx, "sidecar workspaces", config.BetaAPIFields).ViaIndex(sidecarIdx).ViaField("sidecars"))
}
for workspaceIdx, w := range sidecar.Workspaces {
if !wsNames.Has(w.Name) {
errs = errs.Also(apis.ErrGeneric(fmt.Sprintf("undefined workspace %q", w.Name), "name").ViaIndex(workspaceIdx).ViaField("workspaces").ViaIndex(sidecarIdx).ViaField("sidecars"))
}
}
}
return errs
} | validateWorkspaceUsages checks that all WorkspaceUsage objects in Steps
refer to workspaces that are defined in the Task.
This is a beta feature and will fail validation if it's used by a step
or sidecar when the enable-api-fields feature gate is anything but "beta".
Note that this feature reached beta after the v1 API version has been released and
consequently it is *not* implicitly enabled on the v1beta1 API to avoid suffering
from the issues described in TEP-0138 https://github.com/tektoncd/community/pull/1034 | validateWorkspaceUsages | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/task_validation.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/task_validation.go | Apache-2.0 |
func ValidateVolumes(volumes []corev1.Volume) (errs *apis.FieldError) {
// Task must not have duplicate volume names.
vols := sets.NewString()
for idx, v := range volumes {
if vols.Has(v.Name) {
errs = errs.Also(apis.ErrGeneric(fmt.Sprintf("multiple volumes with same name %q", v.Name), "name").ViaIndex(idx))
} else {
vols.Insert(v.Name)
}
}
return errs
} | ValidateVolumes validates a slice of volumes to make sure there are no dupilcate names | ValidateVolumes | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/task_validation.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/task_validation.go | Apache-2.0 |
func isCreateOrUpdateAndDiverged(ctx context.Context, s Step) bool {
if apis.IsInCreate(ctx) {
return true
}
if apis.IsInUpdate(ctx) {
baseline := apis.GetBaseline(ctx)
var baselineStep Step
switch o := baseline.(type) {
case *TaskRun:
if o.Spec.TaskSpec != nil {
for _, step := range o.Spec.TaskSpec.Steps {
if s.Name == step.Name {
baselineStep = step
break
}
}
}
default:
// the baseline is not a taskrun.
// return true so that the validation can happen
return true
}
// If an update event, check if the results have diverged from the baseline
// this way, the feature flag check wont happen.
// This will avoid issues like https://github.com/tektoncd/pipeline/issues/5203
// when the feature is turned off mid-run.
diverged := !reflect.DeepEqual(s.Results, baselineStep.Results)
return diverged
} | isCreateOrUpdateAndDiverged checks if the webhook event was create or update
if create, it returns true.
if update, it checks if the step results have diverged and returns if diverged.
if neither, it returns false. | isCreateOrUpdateAndDiverged | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/task_validation.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/task_validation.go | Apache-2.0 |
func ValidateParameterTypes(ctx context.Context, params []ParamSpec) (errs *apis.FieldError) {
for _, p := range params {
errs = errs.Also(p.ValidateType(ctx))
}
return errs
} | ValidateParameterTypes validates all the types within a slice of ParamSpecs | ValidateParameterTypes | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/task_validation.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/task_validation.go | Apache-2.0 |
func ValidateParameterVariables(ctx context.Context, steps []Step, params ParamSpecs) *apis.FieldError {
var errs *apis.FieldError
errs = errs.Also(params.validateNoDuplicateNames())
errs = errs.Also(params.validateParamEnums(ctx).ViaField("params"))
stringParams, arrayParams, objectParams := params.sortByType()
stringParameterNames := sets.NewString(stringParams.getNames()...)
arrayParameterNames := sets.NewString(arrayParams.getNames()...)
errs = errs.Also(validateNameFormat(stringParameterNames.Insert(arrayParameterNames.List()...), objectParams))
return errs.Also(validateArrayUsage(steps, "params", arrayParameterNames))
} | ValidateParameterVariables validates all variables within a slice of ParamSpecs against a slice of Steps | ValidateParameterVariables | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/task_validation.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/task_validation.go | Apache-2.0 |
func validateTaskContextVariables(ctx context.Context, steps []Step) *apis.FieldError {
taskRunContextNames := sets.NewString().Insert(
"name",
"namespace",
"uid",
)
taskContextNames := sets.NewString().Insert(
"name",
"retry-count",
)
errs := validateVariables(ctx, steps, "context\\.taskRun", taskRunContextNames)
return errs.Also(validateVariables(ctx, steps, "context\\.task", taskContextNames))
} | validateTaskContextVariables returns an error if any Steps reference context variables that don't exist. | validateTaskContextVariables | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/task_validation.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/task_validation.go | Apache-2.0 |
func validateTaskResultsVariables(ctx context.Context, steps []Step, results []TaskResult) (errs *apis.FieldError) {
resultsNames := sets.NewString()
for _, r := range results {
resultsNames.Insert(r.Name)
}
for idx, step := range steps {
errs = errs.Also(substitution.ValidateNoReferencesToUnknownVariablesWithDetail(step.Script, "results", resultsNames).ViaField("script").ViaFieldIndex("steps", idx))
}
return errs
} | validateTaskResultsVariables validates if the results referenced in step script are defined in task results | validateTaskResultsVariables | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/task_validation.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/task_validation.go | Apache-2.0 |
func validateObjectUsage(ctx context.Context, steps []Step, params []ParamSpec) (errs *apis.FieldError) {
objectParameterNames := sets.NewString()
for _, p := range params {
// collect all names of object type params
objectParameterNames.Insert(p.Name)
// collect all keys for this object param
objectKeys := sets.NewString()
for key := range p.Properties {
objectKeys.Insert(key)
}
// check if the object's key names are referenced correctly i.e. param.objectParam.key1
errs = errs.Also(validateVariables(ctx, steps, "params\\."+p.Name, objectKeys))
}
return errs.Also(validateObjectUsageAsWhole(steps, "params", objectParameterNames))
} | validateObjectUsage validates the usage of individual attributes of an object param and the usage of the entire object | validateObjectUsage | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/task_validation.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/task_validation.go | Apache-2.0 |
func validateObjectUsageAsWhole(steps []Step, prefix string, vars sets.String) (errs *apis.FieldError) {
for idx, step := range steps {
errs = errs.Also(validateStepObjectUsageAsWhole(step, prefix, vars)).ViaFieldIndex("steps", idx)
}
return errs
} | validateObjectUsageAsWhole returns an error if the Steps contain references to the entire input object params in fields where these references are prohibited | validateObjectUsageAsWhole | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/task_validation.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/task_validation.go | Apache-2.0 |
func validateStepObjectUsageAsWhole(step Step, prefix string, vars sets.String) *apis.FieldError {
errs := substitution.ValidateNoReferencesToEntireProhibitedVariables(step.Name, prefix, vars).ViaField("name")
errs = errs.Also(substitution.ValidateNoReferencesToEntireProhibitedVariables(step.Image, prefix, vars).ViaField("image"))
errs = errs.Also(substitution.ValidateNoReferencesToEntireProhibitedVariables(step.WorkingDir, prefix, vars).ViaField("workingDir"))
errs = errs.Also(substitution.ValidateNoReferencesToEntireProhibitedVariables(step.Script, prefix, vars).ViaField("script"))
for i, cmd := range step.Command {
errs = errs.Also(substitution.ValidateNoReferencesToEntireProhibitedVariables(cmd, prefix, vars).ViaFieldIndex("command", i))
}
for i, arg := range step.Args {
errs = errs.Also(substitution.ValidateNoReferencesToEntireProhibitedVariables(arg, prefix, vars).ViaFieldIndex("args", i))
}
for _, env := range step.Env {
errs = errs.Also(substitution.ValidateNoReferencesToEntireProhibitedVariables(env.Value, prefix, vars).ViaFieldKey("env", env.Name))
}
for i, v := range step.VolumeMounts {
errs = errs.Also(substitution.ValidateNoReferencesToEntireProhibitedVariables(v.Name, prefix, vars).ViaField("name").ViaFieldIndex("volumeMount", i))
errs = errs.Also(substitution.ValidateNoReferencesToEntireProhibitedVariables(v.MountPath, prefix, vars).ViaField("mountPath").ViaFieldIndex("volumeMount", i))
errs = errs.Also(substitution.ValidateNoReferencesToEntireProhibitedVariables(v.SubPath, prefix, vars).ViaField("subPath").ViaFieldIndex("volumeMount", i))
}
return errs
} | validateStepObjectUsageAsWhole returns an error if the Step contains references to the entire input object params in fields where these references are prohibited | validateStepObjectUsageAsWhole | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/task_validation.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/task_validation.go | Apache-2.0 |
func validateArrayUsage(steps []Step, prefix string, arrayParamNames sets.String) (errs *apis.FieldError) {
for idx, step := range steps {
errs = errs.Also(validateStepArrayUsage(step, prefix, arrayParamNames)).ViaFieldIndex("steps", idx)
}
return errs
} | validateArrayUsage returns an error if the Steps contain references to the input array params in fields where these references are prohibited | validateArrayUsage | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/task_validation.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/task_validation.go | Apache-2.0 |
func validateStepArrayUsage(step Step, prefix string, arrayParamNames sets.String) *apis.FieldError {
errs := substitution.ValidateNoReferencesToProhibitedVariables(step.Name, prefix, arrayParamNames).ViaField("name")
errs = errs.Also(substitution.ValidateNoReferencesToProhibitedVariables(step.Image, prefix, arrayParamNames).ViaField("image"))
errs = errs.Also(substitution.ValidateNoReferencesToProhibitedVariables(step.WorkingDir, prefix, arrayParamNames).ViaField("workingDir"))
errs = errs.Also(substitution.ValidateNoReferencesToProhibitedVariables(step.Script, prefix, arrayParamNames).ViaField("script"))
for i, cmd := range step.Command {
errs = errs.Also(substitution.ValidateVariableReferenceIsIsolated(cmd, prefix, arrayParamNames).ViaFieldIndex("command", i))
}
for i, arg := range step.Args {
errs = errs.Also(substitution.ValidateVariableReferenceIsIsolated(arg, prefix, arrayParamNames).ViaFieldIndex("args", i))
}
for _, env := range step.Env {
errs = errs.Also(substitution.ValidateNoReferencesToProhibitedVariables(env.Value, prefix, arrayParamNames).ViaFieldKey("env", env.Name))
}
for i, v := range step.VolumeMounts {
errs = errs.Also(substitution.ValidateNoReferencesToProhibitedVariables(v.Name, prefix, arrayParamNames).ViaField("name").ViaFieldIndex("volumeMount", i))
errs = errs.Also(substitution.ValidateNoReferencesToProhibitedVariables(v.MountPath, prefix, arrayParamNames).ViaField("mountPath").ViaFieldIndex("volumeMount", i))
errs = errs.Also(substitution.ValidateNoReferencesToProhibitedVariables(v.SubPath, prefix, arrayParamNames).ViaField("subPath").ViaFieldIndex("volumeMount", i))
}
return errs
} | validateStepArrayUsage returns an error if the Step contains references to the input array params in fields where these references are prohibited | validateStepArrayUsage | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/task_validation.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/task_validation.go | Apache-2.0 |
func validateVariables(ctx context.Context, steps []Step, prefix string, vars sets.String) (errs *apis.FieldError) {
// We've checked param name format. Now, we want to check if param names are referenced correctly in each step
for idx, step := range steps {
errs = errs.Also(validateStepVariables(ctx, step, prefix, vars).ViaFieldIndex("steps", idx))
}
return errs
} | validateVariables returns an error if the Steps contain references to any unknown variables | validateVariables | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/task_validation.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/task_validation.go | Apache-2.0 |
func validateNameFormat(stringAndArrayParams sets.String, objectParams []ParamSpec) (errs *apis.FieldError) {
// checking string or array name format
// ----
invalidStringAndArrayNames := []string{}
// Converting to sorted list here rather than just looping map keys
// because we want the order of items in vars to be deterministic for purpose of unit testing
for _, name := range stringAndArrayParams.List() {
if !stringAndArrayVariableNameFormatRegex.MatchString(name) {
invalidStringAndArrayNames = append(invalidStringAndArrayNames, name)
}
}
if len(invalidStringAndArrayNames) != 0 {
errs = errs.Also(&apis.FieldError{
Message: fmt.Sprintf("The format of following array and string variable names is invalid: %s", invalidStringAndArrayNames),
Paths: []string{"params"},
Details: "String/Array Names: \nMust only contain alphanumeric characters, hyphens (-), underscores (_), and dots (.)\nMust begin with a letter or an underscore (_)",
})
}
// checking object name and key name format
// -----
invalidObjectNames := map[string][]string{}
for _, obj := range objectParams {
// check object param name
if !objectVariableNameFormatRegex.MatchString(obj.Name) {
invalidObjectNames[obj.Name] = []string{}
}
// check key names
for k := range obj.Properties {
if !objectVariableNameFormatRegex.MatchString(k) {
invalidObjectNames[obj.Name] = append(invalidObjectNames[obj.Name], k)
}
}
}
if len(invalidObjectNames) != 0 {
errs = errs.Also(&apis.FieldError{
Message: fmt.Sprintf("Object param name and key name format is invalid: %s", invalidObjectNames),
Paths: []string{"params"},
Details: "Object Names: \nMust only contain alphanumeric characters, hyphens (-), underscores (_) \nMust begin with a letter or an underscore (_)",
})
}
return errs
} | validateNameFormat validates that the name format of all param types follows the rules | validateNameFormat | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/task_validation.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/task_validation.go | Apache-2.0 |
func validateStepVariables(ctx context.Context, step Step, prefix string, vars sets.String) *apis.FieldError {
errs := substitution.ValidateNoReferencesToUnknownVariables(step.Name, prefix, vars).ViaField("name")
errs = errs.Also(substitution.ValidateNoReferencesToUnknownVariables(step.Image, prefix, vars).ViaField("image"))
errs = errs.Also(substitution.ValidateNoReferencesToUnknownVariables(step.WorkingDir, prefix, vars).ViaField("workingDir"))
errs = errs.Also(substitution.ValidateNoReferencesToUnknownVariablesWithDetail(step.Script, prefix, vars).ViaField("script"))
for i, cmd := range step.Command {
errs = errs.Also(substitution.ValidateNoReferencesToUnknownVariables(cmd, prefix, vars).ViaFieldIndex("command", i))
}
for i, arg := range step.Args {
errs = errs.Also(substitution.ValidateNoReferencesToUnknownVariables(arg, prefix, vars).ViaFieldIndex("args", i))
}
for _, env := range step.Env {
errs = errs.Also(substitution.ValidateNoReferencesToUnknownVariables(env.Value, prefix, vars).ViaFieldKey("env", env.Name))
}
for i, v := range step.VolumeMounts {
errs = errs.Also(substitution.ValidateNoReferencesToUnknownVariables(v.Name, prefix, vars).ViaField("name").ViaFieldIndex("volumeMount", i))
errs = errs.Also(substitution.ValidateNoReferencesToUnknownVariables(v.MountPath, prefix, vars).ViaField("MountPath").ViaFieldIndex("volumeMount", i))
errs = errs.Also(substitution.ValidateNoReferencesToUnknownVariables(v.SubPath, prefix, vars).ViaField("SubPath").ViaFieldIndex("volumeMount", i))
}
errs = errs.Also(substitution.ValidateNoReferencesToUnknownVariables(string(step.OnError), prefix, vars).ViaField("onError"))
return errs
} | validateStepVariables returns an error if the Step contains references to any unknown variables | validateStepVariables | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/task_validation.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/task_validation.go | Apache-2.0 |
func isParamRefs(s string) bool {
return strings.HasPrefix(s, "$("+ParamsPrefix)
} | isParamRefs attempts to check if a specified string looks like it contains any parameter reference
This is useful to make sure the specified value looks like a Parameter Reference before performing any strict validation | isParamRefs | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/task_validation.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/task_validation.go | Apache-2.0 |
func (r *CustomRun) SetDefaults(ctx context.Context) {
ctx = apis.WithinParent(ctx, r.ObjectMeta)
r.Spec.SetDefaults(apis.WithinSpec(ctx))
} | SetDefaults implements apis.Defaultable | SetDefaults | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/customrun_defaults.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/customrun_defaults.go | Apache-2.0 |
func (rs *CustomRunSpec) SetDefaults(ctx context.Context) {
cfg := config.FromContextOrDefaults(ctx)
defaultSA := cfg.Defaults.DefaultServiceAccount
if rs.ServiceAccountName == "" && defaultSA != "" {
rs.ServiceAccountName = defaultSA
}
} | SetDefaults implements apis.Defaultable | SetDefaults | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/customrun_defaults.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/customrun_defaults.go | Apache-2.0 |
func (w *WorkspaceDeclaration) GetMountPath() string {
if w.MountPath != "" {
return w.MountPath
}
return filepath.Join(pipeline.WorkspaceDir, w.Name)
} | GetMountPath returns the mountPath for w which is the MountPath if provided or the
default if not. | GetMountPath | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/workspace_types.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/workspace_types.go | Apache-2.0 |
func (pr *PipelineRun) SetDefaults(ctx context.Context) {
pr.Spec.SetDefaults(ctx)
// Silently filtering out Tekton Reserved annotations at creation
if apis.IsInCreate(ctx) {
pr.ObjectMeta.Annotations = kmap.Filter(pr.ObjectMeta.Annotations, func(s string) bool {
return filterReservedAnnotationRegexp.MatchString(s)
})
}
} | SetDefaults implements apis.Defaultable | SetDefaults | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipelinerun_defaults.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipelinerun_defaults.go | Apache-2.0 |
func (prs *PipelineRunSpec) SetDefaults(ctx context.Context) {
cfg := config.FromContextOrDefaults(ctx)
if prs.PipelineRef != nil && prs.PipelineRef.Name == "" && prs.PipelineRef.Resolver == "" {
prs.PipelineRef.Resolver = ResolverName(cfg.Defaults.DefaultResolverType)
}
if prs.Timeout == nil && prs.Timeouts == nil {
prs.Timeout = &metav1.Duration{Duration: time.Duration(cfg.Defaults.DefaultTimeoutMinutes) * time.Minute}
}
if prs.Timeouts != nil && prs.Timeouts.Pipeline == nil {
prs.Timeouts.Pipeline = &metav1.Duration{Duration: time.Duration(cfg.Defaults.DefaultTimeoutMinutes) * time.Minute}
}
defaultSA := cfg.Defaults.DefaultServiceAccount
if prs.ServiceAccountName == "" && defaultSA != "" {
prs.ServiceAccountName = defaultSA
}
defaultPodTemplate := cfg.Defaults.DefaultPodTemplate
prs.PodTemplate = pod.MergePodTemplateWithDefault(prs.PodTemplate, defaultPodTemplate)
if prs.PipelineSpec != nil {
prs.PipelineSpec.SetDefaults(ctx)
}
} | SetDefaults implements apis.Defaultable | SetDefaults | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipelinerun_defaults.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipelinerun_defaults.go | Apache-2.0 |
func (m *Matrix) FanOut() []Params {
var combinations, includeCombinations Combinations
includeCombinations = m.getIncludeCombinations()
if m.HasInclude() && !m.HasParams() {
// If there are only Matrix Include Parameters return explicit combinations
return includeCombinations.toParams()
}
// Generate combinations from Matrix Parameters
for _, parameter := range m.Params {
combinations = combinations.fanOutMatrixParams(parameter)
}
combinations.overwriteCombinations(includeCombinations)
combinations = combinations.addNewCombinations(includeCombinations)
return combinations.toParams()
} | FanOut returns an list of params that represent combinations | FanOut | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/matrix_types.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/matrix_types.go | Apache-2.0 |
func (cs Combinations) overwriteCombinations(ics Combinations) {
for _, paramCombination := range cs {
for _, includeCombination := range ics {
if paramCombination.contains(includeCombination) {
// overwrite the parameter name and value in existing combination
// with the include combination
for name, val := range includeCombination {
paramCombination[name] = val
}
}
}
}
} | overwriteCombinations replaces any missing include params in the initial
matrix params combinations by overwriting the initial combinations with the
include combinations | overwriteCombinations | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/matrix_types.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/matrix_types.go | Apache-2.0 |
func (cs Combinations) addNewCombinations(ics Combinations) Combinations {
for _, includeCombination := range ics {
if cs.shouldAddNewCombination(includeCombination) {
cs = append(cs, includeCombination)
}
}
return cs
} | addNewCombinations creates a new combination for any include parameter
values that are missing entirely from the initial combinations and
returns all combinations | addNewCombinations | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/matrix_types.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/matrix_types.go | Apache-2.0 |
func (c Combination) contains(includeCombination Combination) bool {
for name, val := range includeCombination {
if _, exist := c[name]; exist {
if c[name] != val {
return false
}
}
}
return true
} | contains returns true if the include parameter name and value exists in combinations | contains | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/matrix_types.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/matrix_types.go | Apache-2.0 |
func (cs Combinations) shouldAddNewCombination(includeCombination map[string]string) bool {
if len(includeCombination) == 0 {
return false
}
for _, paramCombination := range cs {
for name, val := range includeCombination {
if _, exist := paramCombination[name]; exist {
if paramCombination[name] == val {
return false
}
}
}
}
return true
} | shouldAddNewCombination returns true if the include parameter name exists but the value is
missing from combinations | shouldAddNewCombination | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/matrix_types.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/matrix_types.go | Apache-2.0 |
func (cs Combinations) toParams() []Params {
listOfParams := make([]Params, len(cs))
for i := range cs {
var params Params
combination := cs[i]
order, _ := combination.sortCombination()
for _, key := range order {
params = append(params, Param{
Name: key,
Value: ParamValue{Type: ParamTypeString, StringVal: combination[key]},
})
}
listOfParams[i] = params
}
return listOfParams
} | toParams transforms Combinations from a slice of map[string]string to a slice of Params
such that, these combinations can be directly consumed in creating taskRun/run object | toParams | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/matrix_types.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/matrix_types.go | Apache-2.0 |
func (cs Combinations) fanOutMatrixParams(param Param) Combinations {
if len(cs) == 0 {
return initializeCombinations(param)
}
return cs.distribute(param)
} | fanOutMatrixParams generates new combinations based on Matrix Parameters. | fanOutMatrixParams | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/matrix_types.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/matrix_types.go | Apache-2.0 |
func (m *Matrix) getIncludeCombinations() Combinations {
var combinations Combinations
for i := range m.Include {
includeParams := m.Include[i].Params
newCombination := make(Combination)
for _, param := range includeParams {
newCombination[param.Name] = param.Value.StringVal
}
combinations = append(combinations, newCombination)
}
return combinations
} | getIncludeCombinations generates combinations based on Matrix Include Parameters | getIncludeCombinations | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/matrix_types.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/matrix_types.go | Apache-2.0 |
func (cs Combinations) distribute(param Param) Combinations {
var expandedCombinations Combinations
for _, value := range param.Value.ArrayVal {
for _, combination := range cs {
newCombination := make(Combination)
maps.Copy(newCombination, combination)
newCombination[param.Name] = value
_, orderedCombination := newCombination.sortCombination()
expandedCombinations = append(expandedCombinations, orderedCombination)
}
}
return expandedCombinations
} | distribute generates a new Combination of Parameters by adding a new Parameter to an existing list of Combinations. | distribute | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/matrix_types.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/matrix_types.go | Apache-2.0 |
func initializeCombinations(param Param) Combinations {
var combinations Combinations
for _, value := range param.Value.ArrayVal {
combinations = append(combinations, Combination{param.Name: value})
}
return combinations
} | initializeCombinations generates a new Combination based on the first Parameter in the Matrix. | initializeCombinations | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/matrix_types.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/matrix_types.go | Apache-2.0 |
func (c Combination) sortCombination() ([]string, Combination) {
sortedCombination := make(Combination, len(c))
order := make([]string, 0, len(c))
for key := range c {
order = append(order, key)
}
sort.Slice(order, func(i, j int) bool {
return order[i] <= order[j]
})
for _, key := range order {
sortedCombination[key] = c[key]
}
return order, sortedCombination
} | sortCombination sorts the given Combination based on the Parameter names to produce a deterministic ordering | sortCombination | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/matrix_types.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/matrix_types.go | Apache-2.0 |
func (m *Matrix) CountCombinations() int {
// Iterate over Matrix Parameters and compute count of all generated Combinations
count := m.countGeneratedCombinationsFromParams()
// Add any additional Combinations generated from Matrix Include Parameters
count += m.countNewCombinationsFromInclude()
return count
} | CountCombinations returns the count of Combinations of Parameters generated from the Matrix in PipelineTask. | CountCombinations | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/matrix_types.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/matrix_types.go | Apache-2.0 |
func (m *Matrix) countGeneratedCombinationsFromParams() int {
if !m.HasParams() {
return 0
}
count := 1
for _, param := range m.Params {
count *= len(param.Value.ArrayVal)
}
return count
} | countGeneratedCombinationsFromParams returns the count of Combinations of Parameters generated from the Matrix
Parameters | countGeneratedCombinationsFromParams | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/matrix_types.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/matrix_types.go | Apache-2.0 |
func (m *Matrix) countNewCombinationsFromInclude() int {
if !m.HasInclude() {
return 0
}
if !m.HasParams() {
return len(m.Include)
}
count := 0
matrixParamMap := m.Params.extractParamMapArrVals()
for _, include := range m.Include {
for _, param := range include.Params {
if val, exist := matrixParamMap[param.Name]; exist {
// If the Matrix Include param values does not exist, a new Combination will be generated
if !slices.Contains(val, param.Value.StringVal) {
count++
} else {
break
}
}
}
}
return count
} | countNewCombinationsFromInclude returns the count of Combinations of Parameters generated from the Matrix
Include Parameters | countNewCombinationsFromInclude | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/matrix_types.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/matrix_types.go | Apache-2.0 |
func (m *Matrix) HasInclude() bool {
return m != nil && m.Include != nil && len(m.Include) > 0
} | HasInclude returns true if the Matrix has Include Parameters | HasInclude | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/matrix_types.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/matrix_types.go | Apache-2.0 |
func (m *Matrix) HasParams() bool {
return m != nil && m.Params != nil && len(m.Params) > 0
} | HasParams returns true if the Matrix has Parameters | HasParams | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/matrix_types.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/matrix_types.go | Apache-2.0 |
func (m *Matrix) GetAllParams() Params {
var params Params
if m.HasParams() {
params = append(params, m.Params...)
}
if m.HasInclude() {
for _, include := range m.Include {
params = append(params, include.Params...)
}
}
return params
} | GetAllParams returns a list of all Matrix Parameters | GetAllParams | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/matrix_types.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/matrix_types.go | Apache-2.0 |
func (m *Matrix) validateUniqueParams() (errs *apis.FieldError) {
if m != nil {
if m.HasInclude() {
for i, include := range m.Include {
errs = errs.Also(include.Params.validateDuplicateParameters().ViaField(fmt.Sprintf("matrix.include[%d].params", i)))
}
}
if m.HasParams() {
errs = errs.Also(m.Params.validateDuplicateParameters().ViaField("matrix.params"))
}
}
return errs
} | validateUniqueParams validates Matrix.Params for a unique list of params
and a unique list of params in each Matrix.Include.Params specification | validateUniqueParams | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/matrix_types.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/matrix_types.go | Apache-2.0 |
func (m *Matrix) validatePipelineParametersVariablesInMatrixParameters(prefix string, paramNames sets.String, arrayParamNames sets.String, objectParamNameKeys map[string][]string) (errs *apis.FieldError) {
if m.HasInclude() {
for _, include := range m.Include {
for idx, param := range include.Params {
stringElement := param.Value.StringVal
// Matrix Include Params must be of type string
errs = errs.Also(validateStringVariable(stringElement, prefix, paramNames, arrayParamNames, objectParamNameKeys).ViaFieldIndex("", idx).ViaField("matrix.include.params", ""))
}
}
}
if m.HasParams() {
for _, param := range m.Params {
for idx, arrayElement := range param.Value.ArrayVal {
// Matrix Params must be of type array
errs = errs.Also(validateArrayVariable(arrayElement, prefix, paramNames, arrayParamNames, objectParamNameKeys).ViaFieldIndex("value", idx).ViaFieldKey("matrix.params", param.Name))
}
}
}
return errs
} | validatePipelineParametersVariablesInMatrixParameters validates all pipeline parameter variables including Matrix.Params and Matrix.Include.Params
that may contain the reference(s) to other params to make sure those references are used appropriately. | validatePipelineParametersVariablesInMatrixParameters | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/matrix_types.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/matrix_types.go | Apache-2.0 |
func (we *WhenExpression) GetVarSubstitutionExpressions() ([]string, bool) {
var allExpressions []string
allExpressions = append(allExpressions, validateString(we.Input)...)
allExpressions = append(allExpressions, validateString(we.CEL)...)
for _, value := range we.Values {
allExpressions = append(allExpressions, validateString(value)...)
}
return allExpressions, len(allExpressions) != 0
} | GetVarSubstitutionExpressions extracts all the values between "$(" and ")" in a When Expression | GetVarSubstitutionExpressions | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/when_types.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/when_types.go | Apache-2.0 |
func (wes WhenExpressions) AllowsExecution(evaluatedCEL map[string]bool) bool {
for _, we := range wes {
if !we.isTrue() || (we.CEL != "" && !evaluatedCEL[we.CEL]) {
return false
}
}
return true
} | AllowsExecution evaluates an Input's relationship to an array of Values, based on the Operator,
to determine whether all the When Expressions are True. If they are all True, the guarded Task is
executed, otherwise it is skipped.
If CEL expression exists, AllowsExecution will get the evaluated results from evaluatedCEL and determine
if the Task should be skipped. | AllowsExecution | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/when_types.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/when_types.go | Apache-2.0 |
func (wes WhenExpressions) ReplaceVariables(replacements map[string]string, arrayReplacements map[string][]string) WhenExpressions {
replaced := wes
for i := range wes {
replaced[i] = wes[i].applyReplacements(replacements, arrayReplacements)
}
return replaced
} | ReplaceVariables interpolates variables, such as Parameters and Results, in
the Input and Values. | ReplaceVariables | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/when_types.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/when_types.go | Apache-2.0 |
func (r *CustomRun) SupportedVerbs() []admissionregistrationv1.OperationType {
return []admissionregistrationv1.OperationType{admissionregistrationv1.Create, admissionregistrationv1.Update}
} | SupportedVerbs returns the operations that validation should be called for | SupportedVerbs | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/customrun_validation.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/customrun_validation.go | Apache-2.0 |
func (rs *CustomRunSpec) Validate(ctx context.Context) *apis.FieldError {
// this covers the case rs.customRef == nil && rs.customSpec == nil
if equality.Semantic.DeepEqual(rs, &CustomRunSpec{}) {
return apis.ErrMissingField("spec")
}
if rs.CustomRef != nil && rs.CustomSpec != nil {
return apis.ErrMultipleOneOf("spec.customRef", "spec.customSpec")
}
if rs.CustomRef == nil && rs.CustomSpec == nil {
return apis.ErrMissingOneOf("spec.customRef", "spec.customSpec")
}
if rs.CustomRef != nil {
if rs.CustomRef.APIVersion == "" {
return apis.ErrMissingField("spec.customRef.apiVersion")
}
if rs.CustomRef.Kind == "" {
return apis.ErrMissingField("spec.customRef.kind")
}
}
if rs.CustomSpec != nil {
if rs.CustomSpec.APIVersion == "" {
return apis.ErrMissingField("spec.customSpec.apiVersion")
}
if rs.CustomSpec.Kind == "" {
return apis.ErrMissingField("spec.customSpec.kind")
}
}
if rs.Status == "" {
if rs.StatusMessage != "" {
return apis.ErrInvalidValue(fmt.Sprintf("statusMessage should not be set if status is not set, but it is currently set to %s", rs.StatusMessage), "statusMessage")
}
}
if err := ValidateParameters(ctx, rs.Params).ViaField("spec.params"); err != nil {
return err
}
return ValidateWorkspaceBindings(ctx, rs.Workspaces).ViaField("spec.workspaces")
} | Validate CustomRun spec | Validate | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/customrun_validation.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/customrun_validation.go | Apache-2.0 |
func (pr *PipelineRun) GetName() string {
return pr.ObjectMeta.GetName()
} | GetName Returns the name of the PipelineRun | GetName | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipelinerun_types.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipelinerun_types.go | Apache-2.0 |
func (pr *PipelineRun) GetStatusCondition() apis.ConditionAccessor {
return &pr.Status
} | GetStatusCondition returns the task run status as a ConditionAccessor | GetStatusCondition | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipelinerun_types.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipelinerun_types.go | Apache-2.0 |
func (*PipelineRun) GetGroupVersionKind() schema.GroupVersionKind {
return SchemeGroupVersion.WithKind(pipeline.PipelineRunControllerName)
} | GetGroupVersionKind implements kmeta.OwnerRefable. | GetGroupVersionKind | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipelinerun_types.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipelinerun_types.go | Apache-2.0 |
func (pr *PipelineRun) IsDone() bool {
return !pr.Status.GetCondition(apis.ConditionSucceeded).IsUnknown()
} | IsDone returns true if the PipelineRun's status indicates that it is done. | IsDone | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipelinerun_types.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipelinerun_types.go | Apache-2.0 |
func (pr *PipelineRun) HasStarted() bool {
return pr.Status.StartTime != nil && !pr.Status.StartTime.IsZero()
} | HasStarted function check whether pipelinerun has valid start time set in its status | HasStarted | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipelinerun_types.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipelinerun_types.go | Apache-2.0 |
func (pr *PipelineRun) IsCancelled() bool {
return pr.Spec.Status == PipelineRunSpecStatusCancelled
} | IsCancelled returns true if the PipelineRun's spec status is set to Cancelled state | IsCancelled | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipelinerun_types.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipelinerun_types.go | Apache-2.0 |
func (pr *PipelineRun) IsGracefullyCancelled() bool {
return pr.Spec.Status == PipelineRunSpecStatusCancelledRunFinally
} | IsGracefullyCancelled returns true if the PipelineRun's spec status is set to CancelledRunFinally state | IsGracefullyCancelled | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipelinerun_types.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipelinerun_types.go | Apache-2.0 |
func (pr *PipelineRun) IsGracefullyStopped() bool {
return pr.Spec.Status == PipelineRunSpecStatusStoppedRunFinally
} | IsGracefullyStopped returns true if the PipelineRun's spec status is set to StoppedRunFinally state | IsGracefullyStopped | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipelinerun_types.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipelinerun_types.go | Apache-2.0 |
func (pr *PipelineRun) PipelineTimeout(ctx context.Context) time.Duration {
if pr.Spec.Timeout != nil {
return pr.Spec.Timeout.Duration
}
if pr.Spec.Timeouts != nil && pr.Spec.Timeouts.Pipeline != nil {
return pr.Spec.Timeouts.Pipeline.Duration
}
return time.Duration(config.FromContextOrDefaults(ctx).Defaults.DefaultTimeoutMinutes) * time.Minute
} | PipelineTimeout returns the applicable timeout for the PipelineRun | PipelineTimeout | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipelinerun_types.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipelinerun_types.go | Apache-2.0 |
func (pr *PipelineRun) TasksTimeout() *metav1.Duration {
t := pr.Spec.Timeouts
if t == nil {
return nil
}
if t.Tasks != nil {
return t.Tasks
}
if t.Pipeline != nil && t.Finally != nil {
if t.Pipeline.Duration == apisconfig.NoTimeoutDuration || t.Finally.Duration == apisconfig.NoTimeoutDuration {
return nil
}
return &metav1.Duration{Duration: (t.Pipeline.Duration - t.Finally.Duration)}
}
return nil
} | TasksTimeout returns the tasks timeout for the PipelineRun, if set,
or the tasks timeout computed from the Pipeline and Finally timeouts, if those are set. | TasksTimeout | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipelinerun_types.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipelinerun_types.go | Apache-2.0 |
func (pr *PipelineRun) FinallyTimeout() *metav1.Duration {
t := pr.Spec.Timeouts
if t == nil {
return nil
}
if t.Finally != nil {
return t.Finally
}
if t.Pipeline != nil && t.Tasks != nil {
if t.Pipeline.Duration == apisconfig.NoTimeoutDuration || t.Tasks.Duration == apisconfig.NoTimeoutDuration {
return nil
}
return &metav1.Duration{Duration: (t.Pipeline.Duration - t.Tasks.Duration)}
}
return nil
} | FinallyTimeout returns the finally timeout for the PipelineRun, if set,
or the finally timeout computed from the Pipeline and Tasks timeouts, if those are set. | FinallyTimeout | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipelinerun_types.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipelinerun_types.go | Apache-2.0 |
func (pr *PipelineRun) IsPending() bool {
return pr.Spec.Status == PipelineRunSpecStatusPending
} | IsPending returns true if the PipelineRun's spec status is set to Pending state | IsPending | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipelinerun_types.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipelinerun_types.go | Apache-2.0 |
func (pr *PipelineRun) GetNamespacedName() types.NamespacedName {
return types.NamespacedName{Namespace: pr.Namespace, Name: pr.Name}
} | GetNamespacedName returns a k8s namespaced name that identifies this PipelineRun | GetNamespacedName | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipelinerun_types.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipelinerun_types.go | Apache-2.0 |
func (pr *PipelineRun) IsTimeoutConditionSet() bool {
condition := pr.Status.GetCondition(apis.ConditionSucceeded)
return condition.IsFalse() && condition.Reason == PipelineRunReasonTimedOut.String()
} | IsTimeoutConditionSet returns true when the pipelinerun has the pipelinerun timed out reason | IsTimeoutConditionSet | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipelinerun_types.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipelinerun_types.go | Apache-2.0 |
func (pr *PipelineRun) SetTimeoutCondition(ctx context.Context) {
pr.Status.SetCondition(&apis.Condition{
Type: apis.ConditionSucceeded,
Status: corev1.ConditionFalse,
Reason: PipelineRunReasonTimedOut.String(),
Message: fmt.Sprintf("PipelineRun %q failed to finish within %q", pr.Name, pr.PipelineTimeout(ctx).String()),
})
} | SetTimeoutCondition sets the status of the PipelineRun to timed out. | SetTimeoutCondition | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipelinerun_types.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipelinerun_types.go | Apache-2.0 |
func (pr *PipelineRun) HasTimedOut(ctx context.Context, c clock.PassiveClock) bool {
timeout := pr.PipelineTimeout(ctx)
startTime := pr.Status.StartTime
if !startTime.IsZero() {
if timeout == config.NoTimeoutDuration {
return false
}
runtime := c.Since(startTime.Time)
if runtime > timeout {
return true
}
}
return false
} | HasTimedOut returns true if a pipelinerun has exceeded its spec.Timeout based on its status.Timeout | HasTimedOut | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipelinerun_types.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipelinerun_types.go | Apache-2.0 |
func (pr *PipelineRun) HasTimedOutForALongTime(ctx context.Context, c clock.PassiveClock) bool {
if !pr.HasTimedOut(ctx, c) {
return false
}
timeout := pr.PipelineTimeout(ctx)
startTime := pr.Status.StartTime
runtime := c.Since(startTime.Time)
// We are arbitrarily defining large margin as doubling the spec.timeout
return runtime >= 2*timeout
} | HasTimedOutForALongTime returns true if a pipelinerun has exceeed its spec.Timeout based its status.StartTime
by a large margin | HasTimedOutForALongTime | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipelinerun_types.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipelinerun_types.go | Apache-2.0 |
func (pr *PipelineRun) HaveTasksTimedOut(ctx context.Context, c clock.PassiveClock) bool {
timeout := pr.TasksTimeout()
startTime := pr.Status.StartTime
if !startTime.IsZero() && timeout != nil {
if timeout.Duration == config.NoTimeoutDuration {
return false
}
runtime := c.Since(startTime.Time)
if runtime > timeout.Duration {
return true
}
}
return false
} | HaveTasksTimedOut returns true if a pipelinerun has exceeded its spec.Timeouts.Tasks | HaveTasksTimedOut | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipelinerun_types.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipelinerun_types.go | Apache-2.0 |
func (pr *PipelineRun) HasFinallyTimedOut(ctx context.Context, c clock.PassiveClock) bool {
timeout := pr.FinallyTimeout()
startTime := pr.Status.FinallyStartTime
if startTime != nil && !startTime.IsZero() && timeout != nil {
if timeout.Duration == config.NoTimeoutDuration {
return false
}
runtime := c.Since(startTime.Time)
if runtime > timeout.Duration {
return true
}
}
return false
} | HasFinallyTimedOut returns true if a pipelinerun has exceeded its spec.Timeouts.Finally, based on status.FinallyStartTime | HasFinallyTimedOut | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipelinerun_types.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipelinerun_types.go | Apache-2.0 |
func (pr *PipelineRun) HasVolumeClaimTemplate() bool {
for _, ws := range pr.Spec.Workspaces {
if ws.VolumeClaimTemplate != nil {
return true
}
}
return false
} | HasVolumeClaimTemplate returns true if PipelineRun contains volumeClaimTemplates that is
used for creating PersistentVolumeClaims with an OwnerReference for each run | HasVolumeClaimTemplate | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipelinerun_types.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipelinerun_types.go | Apache-2.0 |
func (pr *PipelineRunStatus) GetCondition(t apis.ConditionType) *apis.Condition {
return pipelineRunCondSet.Manage(pr).GetCondition(t)
} | GetCondition returns the Condition matching the given type. | GetCondition | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipelinerun_types.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipelinerun_types.go | Apache-2.0 |
func (pr *PipelineRunStatus) InitializeConditions(c clock.PassiveClock) {
started := false
if pr.StartTime.IsZero() {
pr.StartTime = &metav1.Time{Time: c.Now()}
started = true
}
conditionManager := pipelineRunCondSet.Manage(pr)
conditionManager.InitializeConditions()
// Ensure the started reason is set for the "Succeeded" condition
if started {
initialCondition := conditionManager.GetCondition(apis.ConditionSucceeded)
initialCondition.Reason = PipelineRunReasonStarted.String()
conditionManager.SetCondition(*initialCondition)
}
} | InitializeConditions will set all conditions in pipelineRunCondSet to unknown for the PipelineRun
and set the started time to the current time | InitializeConditions | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipelinerun_types.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipelinerun_types.go | Apache-2.0 |
func (pr *PipelineRunStatus) SetCondition(newCond *apis.Condition) {
if newCond != nil {
pipelineRunCondSet.Manage(pr).SetCondition(*newCond)
}
} | SetCondition sets the condition, unsetting previous conditions with the same
type as necessary. | SetCondition | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipelinerun_types.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipelinerun_types.go | Apache-2.0 |
func (pr *PipelineRunStatus) MarkSucceeded(reason, messageFormat string, messageA ...interface{}) {
pipelineRunCondSet.Manage(pr).MarkTrueWithReason(apis.ConditionSucceeded, reason, messageFormat, messageA...)
succeeded := pr.GetCondition(apis.ConditionSucceeded)
pr.CompletionTime = &succeeded.LastTransitionTime.Inner
} | MarkSucceeded changes the Succeeded condition to True with the provided reason and message. | MarkSucceeded | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipelinerun_types.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipelinerun_types.go | Apache-2.0 |
func (pr *PipelineRunStatus) MarkFailed(reason, messageFormat string, messageA ...interface{}) {
pipelineRunCondSet.Manage(pr).MarkFalse(apis.ConditionSucceeded, reason, messageFormat, messageA...)
succeeded := pr.GetCondition(apis.ConditionSucceeded)
pr.CompletionTime = &succeeded.LastTransitionTime.Inner
} | MarkFailed changes the Succeeded condition to False with the provided reason and message. | MarkFailed | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipelinerun_types.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipelinerun_types.go | Apache-2.0 |
func (pr *PipelineRunStatus) MarkRunning(reason, messageFormat string, messageA ...interface{}) {
pipelineRunCondSet.Manage(pr).MarkUnknown(apis.ConditionSucceeded, reason, messageFormat, messageA...)
} | MarkRunning changes the Succeeded condition to Unknown with the provided reason and message. | MarkRunning | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipelinerun_types.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipelinerun_types.go | Apache-2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.