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 (pr *PipelineRun) GetTaskRunSpec(pipelineTaskName string) PipelineTaskRunSpec { s := PipelineTaskRunSpec{ PipelineTaskName: pipelineTaskName, TaskServiceAccountName: pr.Spec.ServiceAccountName, TaskPodTemplate: pr.Spec.PodTemplate, } for _, task := range pr.Spec.TaskRunSpecs { if task.PipelineTaskName == pipelineTaskName { // merge podTemplates specified in pipelineRun.spec.taskRunSpecs[].podTemplate and pipelineRun.spec.podTemplate // with taskRunSpecs taking higher precedence s.TaskPodTemplate = pod.MergePodTemplateWithDefault(task.TaskPodTemplate, s.TaskPodTemplate) if task.TaskServiceAccountName != "" { s.TaskServiceAccountName = task.TaskServiceAccountName } s.StepOverrides = task.StepOverrides s.SidecarOverrides = task.SidecarOverrides s.Metadata = task.Metadata s.ComputeResources = task.ComputeResources } } return s }
GetTaskRunSpec returns the task specific spec for a given PipelineTask if configured, otherwise it returns the PipelineRun's default.
GetTaskRunSpec
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 (t *Task) ConvertTo(ctx context.Context, to apis.Convertible) error { if apis.IsInDelete(ctx) { return nil } switch sink := to.(type) { case *v1.Task: sink.ObjectMeta = t.ObjectMeta if err := serializeResources(&sink.ObjectMeta, &t.Spec); err != nil { return err } return t.Spec.ConvertTo(ctx, &sink.Spec, &sink.ObjectMeta, t.Name) default: return fmt.Errorf("unknown version, got: %T", sink) }
ConvertTo implements apis.Convertible
ConvertTo
go
tektoncd/cli
vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/task_conversion.go
https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/task_conversion.go
Apache-2.0
func serializeTaskDeprecations(meta *metav1.ObjectMeta, spec *TaskSpec, taskName string) error { var taskDeprecation *taskDeprecation if spec.HasDeprecatedFields() { taskDeprecation = retrieveTaskDeprecation(spec) } existingDeprecations := taskDeprecations{} if str, ok := meta.Annotations[TaskDeprecationsAnnotationKey]; ok { if err := json.Unmarshal([]byte(str), &existingDeprecations); err != nil { return fmt.Errorf("error serializing key %s from metadata: %w", TaskDeprecationsAnnotationKey, err) } } if taskDeprecation != nil { existingDeprecations[taskName] = *taskDeprecation return version.SerializeToMetadata(meta, existingDeprecations, TaskDeprecationsAnnotationKey) } return nil }
serializeTaskDeprecations appends the current Task's deprecation info to annotation of the object. The object could be Task, TaskRun, Pipeline or PipelineRun
serializeTaskDeprecations
go
tektoncd/cli
vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/task_conversion.go
https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/task_conversion.go
Apache-2.0
func deserializeTaskDeprecations(meta *metav1.ObjectMeta, spec *TaskSpec, taskName string) error { existingDeprecations := taskDeprecations{} if meta == nil || meta.Annotations == nil { return nil } if str, ok := meta.Annotations[TaskDeprecationsAnnotationKey]; ok { if err := json.Unmarshal([]byte(str), &existingDeprecations); err != nil { return fmt.Errorf("error deserializing key %s from metadata: %w", TaskDeprecationsAnnotationKey, err) } } if td, ok := existingDeprecations[taskName]; ok { if len(spec.Steps) != len(td.DeprecatedSteps) { return errors.New("length of deserialized steps mismatch the length of target steps") } for i := range len(spec.Steps) { spec.Steps[i].DeprecatedPorts = td.DeprecatedSteps[i].DeprecatedPorts spec.Steps[i].DeprecatedLivenessProbe = td.DeprecatedSteps[i].DeprecatedLivenessProbe spec.Steps[i].DeprecatedReadinessProbe = td.DeprecatedSteps[i].DeprecatedReadinessProbe spec.Steps[i].DeprecatedStartupProbe = td.DeprecatedSteps[i].DeprecatedStartupProbe spec.Steps[i].DeprecatedLifecycle = td.DeprecatedSteps[i].DeprecatedLifecycle spec.Steps[i].DeprecatedTerminationMessagePath = td.DeprecatedSteps[i].DeprecatedTerminationMessagePath spec.Steps[i].DeprecatedTerminationMessagePolicy = td.DeprecatedSteps[i].DeprecatedTerminationMessagePolicy spec.Steps[i].DeprecatedStdin = td.DeprecatedSteps[i].DeprecatedStdin spec.Steps[i].DeprecatedStdinOnce = td.DeprecatedSteps[i].DeprecatedStdinOnce spec.Steps[i].DeprecatedTTY = td.DeprecatedSteps[i].DeprecatedTTY } if td.DeprecatedStepTemplate != nil { if spec.StepTemplate == nil { spec.StepTemplate = &StepTemplate{} } spec.StepTemplate.DeprecatedName = td.DeprecatedStepTemplate.DeprecatedName spec.StepTemplate.DeprecatedPorts = td.DeprecatedStepTemplate.DeprecatedPorts spec.StepTemplate.DeprecatedLivenessProbe = td.DeprecatedStepTemplate.DeprecatedLivenessProbe spec.StepTemplate.DeprecatedReadinessProbe = td.DeprecatedStepTemplate.DeprecatedReadinessProbe spec.StepTemplate.DeprecatedStartupProbe = td.DeprecatedStepTemplate.DeprecatedStartupProbe spec.StepTemplate.DeprecatedLifecycle = td.DeprecatedStepTemplate.DeprecatedLifecycle spec.StepTemplate.DeprecatedTerminationMessagePath = td.DeprecatedStepTemplate.DeprecatedTerminationMessagePath spec.StepTemplate.DeprecatedTerminationMessagePolicy = td.DeprecatedStepTemplate.DeprecatedTerminationMessagePolicy spec.StepTemplate.DeprecatedStdin = td.DeprecatedStepTemplate.DeprecatedStdin spec.StepTemplate.DeprecatedStdinOnce = td.DeprecatedStepTemplate.DeprecatedStdinOnce spec.StepTemplate.DeprecatedTTY = td.DeprecatedStepTemplate.DeprecatedTTY } delete(existingDeprecations, taskName) if len(existingDeprecations) == 0 { delete(meta.Annotations, TaskDeprecationsAnnotationKey) } else { updatedDeprecations, err := json.Marshal(existingDeprecations) if err != nil { return err } meta.Annotations[TaskDeprecationsAnnotationKey] = string(updatedDeprecations) } if len(meta.Annotations) == 0 { meta.Annotations = nil } } return nil }
deserializeTaskDeprecations retrieves deprecation info of the Task from object annotation. The object could be Task, TaskRun, Pipeline or PipelineRun.
deserializeTaskDeprecations
go
tektoncd/cli
vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/task_conversion.go
https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/task_conversion.go
Apache-2.0
func (tr *TaskResult) SetDefaults(context.Context) { if tr == nil { return } if tr.Type == "" { if tr.Properties != nil { // Set type to object if `properties` is given tr.Type = ResultsTypeObject } else { // ResultsTypeString is the default value tr.Type = ResultsTypeString } } // Set default type of object values to string for key, propertySpec := range tr.Properties { if propertySpec.Type == "" { tr.Properties[key] = PropertySpec{Type: ParamType(ResultsTypeString)} } } }
SetDefaults set the default type for TaskResult
SetDefaults
go
tektoncd/cli
vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/result_defaults.go
https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/result_defaults.go
Apache-2.0
func (ref *TaskRef) 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 TaskRef field is populated correctly. No errors are returned for a nil TaskRef.
Validate
go
tektoncd/cli
vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/taskref_validation.go
https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/taskref_validation.go
Apache-2.0
func (tr *TaskRun) SetDefaults(ctx context.Context) { ctx = apis.WithinParent(ctx, tr.ObjectMeta) tr.Spec.SetDefaults(ctx) // Silently filtering out Tekton Reserved annotations at creation if apis.IsInCreate(ctx) { tr.ObjectMeta.Annotations = kmap.Filter(tr.ObjectMeta.Annotations, func(s string) bool { return filterReservedAnnotationRegexp.MatchString(s) }) } // If the TaskRun doesn't have a managed-by label, apply the default // specified in the config. cfg := config.FromContextOrDefaults(ctx) if tr.ObjectMeta.Labels == nil { tr.ObjectMeta.Labels = map[string]string{} } if _, found := tr.ObjectMeta.Labels[ManagedByLabelKey]; !found { tr.ObjectMeta.Labels[ManagedByLabelKey] = cfg.Defaults.DefaultManagedByLabelValue } }
SetDefaults implements apis.Defaultable
SetDefaults
go
tektoncd/cli
vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/taskrun_defaults.go
https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/taskrun_defaults.go
Apache-2.0
func (trs *TaskRunSpec) SetDefaults(ctx context.Context) { cfg := config.FromContextOrDefaults(ctx) if trs.TaskRef != nil { if trs.TaskRef.Name == "" && trs.TaskRef.Resolver == "" { trs.TaskRef.Resolver = ResolverName(cfg.Defaults.DefaultResolverType) } if trs.TaskRef.Kind == "" && trs.TaskRef.Resolver == "" { trs.TaskRef.Kind = NamespacedTaskKind } } if trs.Timeout == nil { trs.Timeout = &metav1.Duration{Duration: time.Duration(cfg.Defaults.DefaultTimeoutMinutes) * time.Minute} } defaultSA := cfg.Defaults.DefaultServiceAccount if trs.ServiceAccountName == "" && defaultSA != "" { trs.ServiceAccountName = defaultSA } defaultPodTemplate := cfg.Defaults.DefaultPodTemplate trs.PodTemplate = pod.MergePodTemplateWithDefault(trs.PodTemplate, defaultPodTemplate) // If this taskrun has an embedded task, apply the usual task defaults if trs.TaskSpec != nil { trs.TaskSpec.SetDefaults(ctx) } }
SetDefaults implements apis.Defaultable
SetDefaults
go
tektoncd/cli
vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/taskrun_defaults.go
https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/taskrun_defaults.go
Apache-2.0
func (rs CustomRunSpec) GetParam(name string) *Param { for _, p := range rs.Params { if p.Name == name { return &p } } return nil }
GetParam gets the Param from the CustomRunSpec with the given name TODO(jasonhall): Move this to a Params type so other code can use it?
GetParam
go
tektoncd/cli
vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/customrun_types.go
https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/customrun_types.go
Apache-2.0
func (r *CustomRun) GetConditionSet() apis.ConditionSet { return customrunCondSet }
GetConditionSet retrieves the condition set for this resource. Implements the KRShaped interface.
GetConditionSet
go
tektoncd/cli
vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/customrun_types.go
https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/customrun_types.go
Apache-2.0
func (r *CustomRun) GetStatus() *duckv1.Status { return &r.Status.Status }
GetStatus retrieves the status of the Parallel. Implements the KRShaped interface.
GetStatus
go
tektoncd/cli
vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/customrun_types.go
https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/customrun_types.go
Apache-2.0
func (r *CustomRun) GetStatusCondition() apis.ConditionAccessor { return &r.Status }
GetStatusCondition returns the task run status as a ConditionAccessor
GetStatusCondition
go
tektoncd/cli
vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/customrun_types.go
https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/customrun_types.go
Apache-2.0
func (*CustomRun) GetGroupVersionKind() schema.GroupVersionKind { return SchemeGroupVersion.WithKind(pipeline.CustomRunControllerName) }
GetGroupVersionKind implements kmeta.OwnerRefable.
GetGroupVersionKind
go
tektoncd/cli
vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/customrun_types.go
https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/customrun_types.go
Apache-2.0
func (r *CustomRun) HasPipelineRunOwnerReference() bool { for _, ref := range r.GetOwnerReferences() { if ref.Kind == pipeline.PipelineRunControllerName { return true } } return false }
HasPipelineRunOwnerReference returns true of CustomRun has owner reference of type PipelineRun
HasPipelineRunOwnerReference
go
tektoncd/cli
vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/customrun_types.go
https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/customrun_types.go
Apache-2.0
func (r *CustomRun) IsCancelled() bool { return r.Spec.Status == CustomRunSpecStatusCancelled }
IsCancelled returns true if the CustomRun's spec status is set to Cancelled state
IsCancelled
go
tektoncd/cli
vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/customrun_types.go
https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/customrun_types.go
Apache-2.0
func (r *CustomRun) IsDone() bool { return !r.Status.GetCondition(apis.ConditionSucceeded).IsUnknown() }
IsDone returns true if the CustomRun's status indicates that it is done.
IsDone
go
tektoncd/cli
vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/customrun_types.go
https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/customrun_types.go
Apache-2.0
func (r *CustomRun) HasStarted() bool { return r.Status.StartTime != nil && !r.Status.StartTime.IsZero() }
HasStarted function check whether taskrun has valid start time set in its status
HasStarted
go
tektoncd/cli
vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/customrun_types.go
https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/customrun_types.go
Apache-2.0
func (r *CustomRun) IsSuccessful() bool { return r != nil && r.Status.GetCondition(apis.ConditionSucceeded).IsTrue() }
IsSuccessful returns true if the CustomRun's status indicates that it has succeeded.
IsSuccessful
go
tektoncd/cli
vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/customrun_types.go
https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/customrun_types.go
Apache-2.0
func (r *CustomRun) IsFailure() bool { return r != nil && r.Status.GetCondition(apis.ConditionSucceeded).IsFalse() }
IsFailure returns true if the CustomRun's status indicates that it has failed.
IsFailure
go
tektoncd/cli
vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/customrun_types.go
https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/customrun_types.go
Apache-2.0
func (r *CustomRun) GetCustomRunKey() string { // The address of the pointer is a threadsafe unique identifier for the customrun return fmt.Sprintf("%s/%p", "CustomRun", r) }
GetCustomRunKey return the customrun's key for timeout handler map
GetCustomRunKey
go
tektoncd/cli
vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/customrun_types.go
https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/customrun_types.go
Apache-2.0
func (r *CustomRun) HasTimedOut(c clock.PassiveClock) bool { if r.Status.StartTime == nil || r.Status.StartTime.IsZero() { return false } timeout := r.GetTimeout() // If timeout is set to 0 or defaulted to 0, there is no timeout. if timeout == apisconfig.NoTimeoutDuration { return false } runtime := c.Since(r.Status.StartTime.Time) return runtime > timeout }
HasTimedOut returns true if the CustomRun's running time is beyond the allowed timeout
HasTimedOut
go
tektoncd/cli
vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/customrun_types.go
https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/customrun_types.go
Apache-2.0
func (r *CustomRun) GetTimeout() time.Duration { // Use the platform default if no timeout is set if r.Spec.Timeout == nil { return apisconfig.DefaultTimeoutMinutes * time.Minute } return r.Spec.Timeout.Duration }
GetTimeout returns the timeout for this customrun, or the default if not configured
GetTimeout
go
tektoncd/cli
vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/customrun_types.go
https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/customrun_types.go
Apache-2.0
func (r *CustomRun) GetRetryCount() int { return len(r.Status.RetriesStatus) }
GetRetryCount returns the number of times this CustomRun has already been retried
GetRetryCount
go
tektoncd/cli
vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/customrun_types.go
https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/customrun_types.go
Apache-2.0
func MergeStepsWithStepTemplate(template *StepTemplate, steps []Step) ([]Step, error) { if template == nil { return steps, nil } md, err := getMergeData(template.ToK8sContainer(), &corev1.Container{}) if err != nil { return nil, err } for i, s := range steps { // If the stepaction has not been fetched yet then do not merge. // Skip over to the next one if s.Ref != nil { continue } merged := corev1.Container{} err := mergeObjWithTemplateBytes(md, s.ToK8sContainer(), &merged) if err != nil { return nil, err } // If the container's args is nil, reset it to empty instead if merged.Args == nil && s.Args != nil { merged.Args = []string{} } amendConflictingContainerFields(&merged, s) // Pass through original step Script, for later conversion. newStep := Step{Script: s.Script, OnError: s.OnError, Timeout: s.Timeout, StdoutConfig: s.StdoutConfig, StderrConfig: s.StderrConfig, When: s.When} newStep.SetContainerFields(merged) steps[i] = newStep } return steps, nil }
MergeStepsWithStepTemplate takes a possibly nil container template and a list of steps, merging each of the steps with the container template, if it's not nil, and returning the resulting list.
MergeStepsWithStepTemplate
go
tektoncd/cli
vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/merge.go
https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/merge.go
Apache-2.0
func MergeStepsWithOverrides(steps []Step, overrides []TaskRunStepOverride) ([]Step, error) { stepNameToOverride := make(map[string]TaskRunStepOverride, len(overrides)) for _, o := range overrides { stepNameToOverride[o.Name] = o } for i, s := range steps { o, found := stepNameToOverride[s.Name] if !found { continue } merged := v1.ResourceRequirements{} err := mergeObjWithTemplate(&s.Resources, &o.Resources, &merged) if err != nil { return nil, err } steps[i].Resources = merged } return steps, nil }
MergeStepsWithOverrides takes a possibly nil list of overrides and a list of steps, merging each of the steps with the overrides' resource requirements, if it's not nil, and returning the resulting list.
MergeStepsWithOverrides
go
tektoncd/cli
vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/merge.go
https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/merge.go
Apache-2.0
func MergeSidecarsWithOverrides(sidecars []Sidecar, overrides []TaskRunSidecarOverride) ([]Sidecar, error) { if len(overrides) == 0 { return sidecars, nil } sidecarNameToOverride := make(map[string]TaskRunSidecarOverride, len(overrides)) for _, o := range overrides { sidecarNameToOverride[o.Name] = o } for i, s := range sidecars { o, found := sidecarNameToOverride[s.Name] if !found { continue } merged := v1.ResourceRequirements{} err := mergeObjWithTemplate(&s.Resources, &o.Resources, &merged) if err != nil { return nil, err } sidecars[i].Resources = merged } return sidecars, nil }
MergeSidecarsWithOverrides takes a possibly nil list of overrides and a list of sidecars, merging each of the sidecars with the overrides' resource requirements, if it's not nil, and returning the resulting list.
MergeSidecarsWithOverrides
go
tektoncd/cli
vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/merge.go
https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/merge.go
Apache-2.0
func mergeObjWithTemplate(template, obj, out interface{}) error { md, err := getMergeData(template, out) if err != nil { return err } return mergeObjWithTemplateBytes(md, obj, out) }
mergeObjWithTemplate merges obj with template and updates out to reflect the merged result. template, obj, and out should point to the same type. out points to the zero value of that type.
mergeObjWithTemplate
go
tektoncd/cli
vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/merge.go
https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/merge.go
Apache-2.0
func getMergeData(template, empty interface{}) (*mergeData, error) { // We need JSON bytes to generate a patch to merge the object // onto the template, so marshal the template. templateJSON, err := json.Marshal(template) if err != nil { return nil, err } // We need to do a three-way merge to actually merge the template and // object, so we need an empty object as the "original" emptyJSON, err := json.Marshal(empty) if err != nil { return nil, err } // Get the patch meta, which is needed for generating and applying the merge patch. patchSchema, err := strategicpatch.NewPatchMetaFromStruct(template) if err != nil { return nil, err } return &mergeData{templateJSON: templateJSON, emptyJSON: emptyJSON, patchSchema: patchSchema}, nil }
getMergeData serializes the template and empty object to get the intermediate results necessary for merging an object of the same type with this template. This function is provided to avoid repeatedly serializing an identical template.
getMergeData
go
tektoncd/cli
vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/merge.go
https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/merge.go
Apache-2.0
func mergeObjWithTemplateBytes(md *mergeData, obj, out interface{}) error { // Marshal the object to JSON objAsJSON, err := json.Marshal(obj) if err != nil { return err } // Create a merge patch, with the empty JSON as the original, the object JSON as the modified, and the template // JSON as the current - this lets us do a deep merge of the template and object, with awareness of // the "patchMerge" tags. patch, err := strategicpatch.CreateThreeWayMergePatch(md.emptyJSON, objAsJSON, md.templateJSON, md.patchSchema, true) if err != nil { return err } // Actually apply the merge patch to the template JSON. mergedAsJSON, err := strategicpatch.StrategicMergePatchUsingLookupPatchMeta(md.templateJSON, patch, md.patchSchema) if err != nil { return err } // Unmarshal the merged JSON to a pointer, and return it. return json.Unmarshal(mergedAsJSON, out) }
mergeObjWithTemplateBytes merges obj with md's template JSON and updates out to reflect the merged result. out is a pointer to the zero value of obj's type. This function is provided to avoid repeatedly serializing an identical template.
mergeObjWithTemplateBytes
go
tektoncd/cli
vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/merge.go
https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/merge.go
Apache-2.0
func amendConflictingContainerFields(container *corev1.Container, step Step) { if container == nil || len(step.Env) == 0 { return } envNameToStepEnv := make(map[string]corev1.EnvVar, len(step.Env)) for _, e := range step.Env { envNameToStepEnv[e.Name] = e } for index, env := range container.Env { if env.ValueFrom != nil && len(env.Value) > 0 { if e, ok := envNameToStepEnv[env.Name]; ok { container.Env[index] = e } } } }
amendConflictingContainerFields amends conflicting container fields after merge, and overrides conflicting fields by fields in step.
amendConflictingContainerFields
go
tektoncd/cli
vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/merge.go
https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/merge.go
Apache-2.0
func ResultsArrayReference(a string) string { return strings.TrimSuffix(strings.TrimSuffix(strings.TrimPrefix(a, "$("), ")"), "[*]") }
ResultsArrayReference returns the reference of the result. e.g. results.resultname from $(results.resultname[*])
ResultsArrayReference
go
tektoncd/cli
vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/result_types.go
https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/result_types.go
Apache-2.0
func (p *Pipeline) 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/pipeline_validation.go
https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipeline_validation.go
Apache-2.0
func (p *Pipeline) Validate(ctx context.Context) *apis.FieldError { errs := validate.ObjectMetadata(p.GetObjectMeta()).ViaField("metadata") errs = errs.Also(p.Spec.Validate(apis.WithinSpec(ctx)).ViaField("spec")) // When a Pipeline is created directly, instead of declared inline in a PipelineRun, // we do not support propagated parameters and workspaces. // Validate that all params and workspaces it uses are declared. errs = errs.Also(p.Spec.validatePipelineParameterUsage(ctx).ViaField("spec")) return errs.Also(p.Spec.validatePipelineWorkspacesUsage().ViaField("spec")) }
Validate checks that the Pipeline structure is valid but does not validate that any references resources exist, that is done at run time.
Validate
go
tektoncd/cli
vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipeline_validation.go
https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipeline_validation.go
Apache-2.0
func (ps *PipelineSpec) Validate(ctx context.Context) (errs *apis.FieldError) { errs = errs.Also(ps.ValidateBetaFields(ctx)) if equality.Semantic.DeepEqual(ps, &PipelineSpec{}) { errs = errs.Also(apis.ErrGeneric("expected at least one, got none", "description", "params", "resources", "tasks", "workspaces")) } // PipelineTask must have a valid unique label and at least one of taskRef or taskSpec should be specified errs = errs.Also(ValidatePipelineTasks(ctx, ps.Tasks, ps.Finally)) if len(ps.Resources) > 0 { errs = errs.Also(apis.ErrDisallowedFields("resources")) } // Validate the pipeline task graph errs = errs.Also(validateGraph(ps.Tasks)) // The parameter variables should be valid errs = errs.Also(ValidatePipelineParameterVariables(ctx, ps.Tasks, ps.Params).ViaField("tasks")) errs = errs.Also(ValidatePipelineParameterVariables(ctx, ps.Finally, ps.Params).ViaField("finally")) errs = errs.Also(validatePipelineContextVariables(ps.Tasks).ViaField("tasks")) errs = errs.Also(validatePipelineContextVariables(ps.Finally).ViaField("finally")) errs = errs.Also(validateExecutionStatusVariables(ps.Tasks, ps.Finally)) // Validate the pipeline's workspaces. errs = errs.Also(validatePipelineWorkspacesDeclarations(ps.Workspaces)) // Validate the pipeline's results errs = errs.Also(validatePipelineResults(ps.Results, ps.Tasks, ps.Finally)) errs = errs.Also(validateTasksAndFinallySection(ps)) errs = errs.Also(validateFinalTasks(ps.Tasks, ps.Finally)) errs = errs.Also(validateWhenExpressions(ctx, ps.Tasks, ps.Finally)) errs = errs.Also(validateArtifactReference(ctx, ps.Tasks, ps.Finally)) errs = errs.Also(validateMatrix(ctx, ps.Tasks).ViaField("tasks")) errs = errs.Also(validateMatrix(ctx, ps.Finally).ViaField("finally")) return errs }
Validate checks that taskNames in the Pipeline are valid and that the graph of Tasks expressed in the Pipeline makes sense.
Validate
go
tektoncd/cli
vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipeline_validation.go
https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipeline_validation.go
Apache-2.0
func (ps *PipelineSpec) ValidateBetaFields(ctx context.Context) *apis.FieldError { var errs *apis.FieldError for i, pt := range ps.Tasks { errs = errs.Also(pt.validateBetaFields(ctx).ViaFieldIndex("tasks", i)) } for i, pt := range ps.Finally { errs = errs.Also(pt.validateBetaFields(ctx).ViaFieldIndex("finally", i)) } return errs }
ValidateBetaFields returns an error if the PipelineSpec uses beta specifications governed by `enable-api-fields` but does not have "enable-api-fields" set to "alpha" or "beta".
ValidateBetaFields
go
tektoncd/cli
vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipeline_validation.go
https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipeline_validation.go
Apache-2.0
func (pt *PipelineTask) validateBetaFields(ctx context.Context) *apis.FieldError { var errs *apis.FieldError if pt.TaskRef != nil { // Resolvers if pt.TaskRef.Resolver != "" { errs = errs.Also(config.ValidateEnabledAPIFields(ctx, "taskref.resolver", config.BetaAPIFields)) } if len(pt.TaskRef.Params) > 0 { errs = errs.Also(config.ValidateEnabledAPIFields(ctx, "taskref.params", config.BetaAPIFields)) } } return errs }
validateBetaFields returns an error if the PipelineTask uses beta features but does not have "enable-api-fields" set to "alpha" or "beta".
validateBetaFields
go
tektoncd/cli
vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipeline_validation.go
https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipeline_validation.go
Apache-2.0
func ValidatePipelineTasks(ctx context.Context, tasks []PipelineTask, finalTasks []PipelineTask) *apis.FieldError { taskNames := sets.NewString() var errs *apis.FieldError errs = errs.Also(PipelineTaskList(tasks).Validate(ctx, taskNames, "tasks")) errs = errs.Also(PipelineTaskList(finalTasks).Validate(ctx, taskNames, "finally")) return errs }
ValidatePipelineTasks ensures that pipeline tasks has unique label, pipeline tasks has specified one of taskRef or taskSpec, and in case of a pipeline task with taskRef, it has a reference to a valid task (task name)
ValidatePipelineTasks
go
tektoncd/cli
vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipeline_validation.go
https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipeline_validation.go
Apache-2.0
func (l PipelineTaskList) Validate(ctx context.Context, taskNames sets.String, path string) (errs *apis.FieldError) { for i, t := range l { // validate pipeline task name errs = errs.Also(t.ValidateName().ViaFieldIndex(path, i)) // names cannot be duplicated - checking that pipelineTask names are unique if _, ok := taskNames[t.Name]; ok { errs = errs.Also(apis.ErrMultipleOneOf("name").ViaFieldIndex(path, i)) } taskNames.Insert(t.Name) // validate custom task, bundle, dag, or final task errs = errs.Also(t.Validate(ctx).ViaFieldIndex(path, i)) } return errs }
Validate a list of pipeline tasks including custom task and bundles
Validate
go
tektoncd/cli
vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipeline_validation.go
https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipeline_validation.go
Apache-2.0
func (l PipelineTaskList) validateUsageOfDeclaredPipelineTaskParameters(ctx context.Context, additionalParams []ParamSpec, path string) (errs *apis.FieldError) { for i, t := range l { if t.TaskSpec != nil { errs = errs.Also(ValidateUsageOfDeclaredParameters(ctx, t.TaskSpec.Steps, append(t.TaskSpec.Params, additionalParams...)).ViaFieldIndex(path, i)) } } return errs }
validateUsageOfDeclaredPipelineTaskParameters validates that all parameters referenced in the pipeline Task are declared by the pipeline Task.
validateUsageOfDeclaredPipelineTaskParameters
go
tektoncd/cli
vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipeline_validation.go
https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipeline_validation.go
Apache-2.0
func (pt PipelineTask) ValidateName() *apis.FieldError { if err := validation.IsDNS1123Label(pt.Name); len(err) > 0 { return &apis.FieldError{ Message: fmt.Sprintf("invalid value %q", pt.Name), Paths: []string{"name"}, Details: "Pipeline Task name must be a valid DNS Label." + "For more info refer to https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names", } } return nil }
ValidateName checks whether the PipelineTask's name is a valid DNS label
ValidateName
go
tektoncd/cli
vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipeline_validation.go
https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipeline_validation.go
Apache-2.0
func (pt PipelineTask) Validate(ctx context.Context) (errs *apis.FieldError) { errs = errs.Also(pt.validateRefOrSpec(ctx)) errs = errs.Also(pt.validateEnabledInlineSpec(ctx)) errs = errs.Also(pt.validateEmbeddedOrType()) if pt.Resources != nil { errs = errs.Also(apis.ErrDisallowedFields("resources")) } // taskKinds contains the kinds when the apiVersion is not set, they are not custom tasks, // if apiVersion is set they are custom tasks. taskKinds := map[TaskKind]bool{ "": true, NamespacedTaskKind: true, ClusterTaskKind: true, } if pt.OnError != "" { errs = errs.Also(config.ValidateEnabledAPIFields(ctx, "OnError", config.BetaAPIFields)) if pt.OnError != PipelineTaskContinue && pt.OnError != PipelineTaskStopAndFail { errs = errs.Also(apis.ErrInvalidValue(pt.OnError, "OnError", "PipelineTask OnError must be either \"continue\" or \"stopAndFail\"")) } if pt.OnError == PipelineTaskContinue && pt.Retries > 0 { errs = errs.Also(apis.ErrGeneric("PipelineTask OnError cannot be set to \"continue\" when Retries is greater than 0")) } } // Pipeline task having taskRef/taskSpec with APIVersion is classified as custom task switch { case pt.TaskRef != nil && !taskKinds[pt.TaskRef.Kind]: errs = errs.Also(pt.validateCustomTask()) case pt.TaskRef != nil && pt.TaskRef.APIVersion != "": errs = errs.Also(pt.validateCustomTask()) case pt.TaskSpec != nil && !taskKinds[TaskKind(pt.TaskSpec.Kind)]: errs = errs.Also(pt.validateCustomTask()) case pt.TaskSpec != nil && pt.TaskSpec.APIVersion != "": errs = errs.Also(pt.validateCustomTask()) default: errs = errs.Also(pt.validateTask(ctx)) } return //nolint:nakedret }
Validate classifies whether a task is a custom task, bundle, or a regular task(dag/final) calls the validation routine based on the type of the task
Validate
go
tektoncd/cli
vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipeline_validation.go
https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipeline_validation.go
Apache-2.0
func (pt PipelineTask) validateEnabledInlineSpec(ctx context.Context) (errs *apis.FieldError) { if pt.TaskSpec != nil { if slices.Contains(strings.Split( config.FromContextOrDefaults(ctx).FeatureFlags.DisableInlineSpec, ","), "pipeline") { errs = errs.Also(apis.ErrDisallowedFields("taskSpec")) } } if pt.PipelineSpec != nil { if slices.Contains(strings.Split( config.FromContextOrDefaults(ctx).FeatureFlags.DisableInlineSpec, ","), "pipeline") { errs = errs.Also(apis.ErrDisallowedFields("pipelineSpec")) } } return errs }
validateEnabledInlineSpec validates that pipelineSpec or taskSpec is allowed by checking disable-inline-spec field
validateEnabledInlineSpec
go
tektoncd/cli
vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipeline_validation.go
https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipeline_validation.go
Apache-2.0
func (pt PipelineTask) validateRefOrSpec(ctx context.Context) (errs *apis.FieldError) { // collect all the specified specifications nonNilFields := []string{} if pt.TaskRef != nil { nonNilFields = append(nonNilFields, taskRef) } if pt.TaskSpec != nil { nonNilFields = append(nonNilFields, taskSpec) } if pt.PipelineRef != nil { errs = errs.Also(config.ValidateEnabledAPIFields(ctx, pipelineRef, config.AlphaAPIFields)) nonNilFields = append(nonNilFields, pipelineRef) } if pt.PipelineSpec != nil { errs = errs.Also(config.ValidateEnabledAPIFields(ctx, pipelineSpec, config.AlphaAPIFields)) nonNilFields = append(nonNilFields, pipelineSpec) } // check the length of nonNilFields // if one of taskRef or taskSpec or pipelineRef or pipelineSpec is specified, // the length of nonNilFields should exactly be 1 if len(nonNilFields) > 1 { errs = errs.Also(apis.ErrGeneric("expected exactly one, got multiple", nonNilFields...)) } else if len(nonNilFields) == 0 { cfg := config.FromContextOrDefaults(ctx) // check for TaskRef or TaskSpec or PipelineRef or PipelineSpec with alpha feature flag if cfg.FeatureFlags.EnableAPIFields == config.AlphaAPIFields { errs = errs.Also(apis.ErrMissingOneOf(taskRef, taskSpec, pipelineRef, pipelineSpec)) } else { // check for taskRef and taskSpec with beta/stable feature flag errs = errs.Also(apis.ErrMissingOneOf(taskRef, taskSpec)) } } return errs }
validateRefOrSpec validates at least one of taskRef or taskSpec or pipelineRef or pipelineSpec is specified
validateRefOrSpec
go
tektoncd/cli
vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipeline_validation.go
https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipeline_validation.go
Apache-2.0
func (pt PipelineTask) validateCustomTask() (errs *apis.FieldError) { if pt.TaskRef != nil && pt.TaskRef.Kind == "" { errs = errs.Also(apis.ErrInvalidValue("custom task ref must specify kind", "taskRef.kind")) } if pt.TaskSpec != nil && pt.TaskSpec.Kind == "" { errs = errs.Also(apis.ErrInvalidValue("custom task spec must specify kind", "taskSpec.kind")) } if pt.TaskRef != nil && pt.TaskRef.APIVersion == "" { errs = errs.Also(apis.ErrInvalidValue("custom task ref must specify apiVersion", "taskRef.apiVersion")) } if pt.TaskSpec != nil && pt.TaskSpec.APIVersion == "" { errs = errs.Also(apis.ErrInvalidValue("custom task spec must specify apiVersion", "taskSpec.apiVersion")) } return errs }
validateCustomTask validates custom task specifications - checking kind and fail if not yet supported features specified
validateCustomTask
go
tektoncd/cli
vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipeline_validation.go
https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipeline_validation.go
Apache-2.0
func (pt PipelineTask) validateTask(ctx context.Context) (errs *apis.FieldError) { if pt.TaskSpec != nil { errs = errs.Also(pt.TaskSpec.Validate(ctx).ViaField("taskSpec")) } if pt.TaskRef != nil { errs = errs.Also(pt.TaskRef.Validate(ctx).ViaField("taskRef")) } return errs }
validateTask validates a pipeline task or a final task for taskRef and taskSpec
validateTask
go
tektoncd/cli
vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipeline_validation.go
https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipeline_validation.go
Apache-2.0
func validatePipelineWorkspacesDeclarations(wss []PipelineWorkspaceDeclaration) (errs *apis.FieldError) { // Workspace names must be non-empty and unique. wsTable := sets.NewString() for i, ws := range wss { if ws.Name == "" { errs = errs.Also(apis.ErrInvalidValue(fmt.Sprintf("workspace %d has empty name", i), "").ViaFieldIndex("workspaces", i)) } if wsTable.Has(ws.Name) { errs = errs.Also(apis.ErrInvalidValue(fmt.Sprintf("workspace with name %q appears more than once", ws.Name), "").ViaFieldIndex("workspaces", i)) } wsTable.Insert(ws.Name) } return errs }
validatePipelineWorkspacesDeclarations validates the specified workspaces, ensuring having unique name without any empty string,
validatePipelineWorkspacesDeclarations
go
tektoncd/cli
vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipeline_validation.go
https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipeline_validation.go
Apache-2.0
func (ps *PipelineSpec) validatePipelineParameterUsage(ctx context.Context) (errs *apis.FieldError) { errs = errs.Also(PipelineTaskList(ps.Tasks).validateUsageOfDeclaredPipelineTaskParameters(ctx, ps.Params, "tasks")) errs = errs.Also(PipelineTaskList(ps.Finally).validateUsageOfDeclaredPipelineTaskParameters(ctx, ps.Params, "finally")) errs = errs.Also(validatePipelineTaskParameterUsage(ps.Tasks, ps.Params).ViaField("tasks")) errs = errs.Also(validatePipelineTaskParameterUsage(ps.Finally, ps.Params).ViaField("finally")) return errs }
validatePipelineParameterUsage validates that parameters referenced in the Pipeline are declared by the Pipeline
validatePipelineParameterUsage
go
tektoncd/cli
vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipeline_validation.go
https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipeline_validation.go
Apache-2.0
func validatePipelineTaskParameterUsage(tasks []PipelineTask, params ParamSpecs) (errs *apis.FieldError) { allParamNames := sets.NewString(params.getNames()...) _, arrayParams, objectParams := params.sortByType() arrayParamNames := sets.NewString(arrayParams.getNames()...) objectParameterNameKeys := map[string][]string{} for _, p := range objectParams { for k := range p.Properties { objectParameterNameKeys[p.Name] = append(objectParameterNameKeys[p.Name], k) } } errs = errs.Also(validatePipelineParametersVariables(tasks, "params", allParamNames, arrayParamNames, objectParameterNameKeys)) for i, task := range tasks { errs = errs.Also(task.Params.validateDuplicateParameters().ViaField("params").ViaIndex(i)) } return errs }
validatePipelineTaskParameterUsage validates that parameters referenced in the Pipeline Tasks are declared by the Pipeline
validatePipelineTaskParameterUsage
go
tektoncd/cli
vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipeline_validation.go
https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipeline_validation.go
Apache-2.0
func (ps *PipelineSpec) validatePipelineWorkspacesUsage() (errs *apis.FieldError) { errs = errs.Also(validatePipelineTasksWorkspacesUsage(ps.Workspaces, ps.Tasks).ViaField("tasks")) errs = errs.Also(validatePipelineTasksWorkspacesUsage(ps.Workspaces, ps.Finally).ViaField("finally")) return errs }
validatePipelineWorkspacesUsage validates that Workspaces referenced in the Pipeline are declared by the Pipeline
validatePipelineWorkspacesUsage
go
tektoncd/cli
vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipeline_validation.go
https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipeline_validation.go
Apache-2.0
func validatePipelineTasksWorkspacesUsage(wss []PipelineWorkspaceDeclaration, pts []PipelineTask) (errs *apis.FieldError) { workspaceNames := sets.NewString() for _, ws := range wss { workspaceNames.Insert(ws.Name) } // Any workspaces used in PipelineTasks should have their name declared in the Pipeline's Workspaces list. for i, pt := range pts { errs = errs.Also(pt.validateWorkspaces(workspaceNames).ViaIndex(i)) } return errs }
validatePipelineTasksWorkspacesUsage validates that all the referenced workspaces (by pipeline tasks) are specified in the pipeline
validatePipelineTasksWorkspacesUsage
go
tektoncd/cli
vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipeline_validation.go
https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipeline_validation.go
Apache-2.0
func ValidatePipelineParameterVariables(ctx context.Context, tasks []PipelineTask, params ParamSpecs) (errs *apis.FieldError) { // validates all the types within a slice of ParamSpecs errs = errs.Also(ValidateParameterTypes(ctx, params).ViaField("params")) errs = errs.Also(params.validateNoDuplicateNames()) errs = errs.Also(params.validateParamEnums(ctx).ViaField("params")) for i, task := range tasks { errs = errs.Also(task.Params.validateDuplicateParameters().ViaField("params").ViaIndex(i)) } return errs }
ValidatePipelineParameterVariables validates parameters with those specified by each pipeline task, (1) it validates the type of parameter is either string or array (2) parameter default value matches with the type of that param (3) no duplication, feature flag and allowed param type when using param enum
ValidatePipelineParameterVariables
go
tektoncd/cli
vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipeline_validation.go
https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipeline_validation.go
Apache-2.0
func (pt *PipelineTask) extractAllParams() Params { allParams := pt.Params if pt.Matrix.HasParams() { allParams = append(allParams, pt.Matrix.Params...) } if pt.Matrix.HasInclude() { for _, include := range pt.Matrix.Include { allParams = append(allParams, include.Params...) } } return allParams }
extractAllParams extracts all the parameters in a PipelineTask: - pt.Params - pt.Matrix.Params - pt.Matrix.Include.Params
extractAllParams
go
tektoncd/cli
vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipeline_validation.go
https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipeline_validation.go
Apache-2.0
func containsExecutionStatusRef(p string) bool { if strings.HasPrefix(p, "tasks.") { if strings.HasSuffix(p, ".status") || strings.HasSuffix(p, ".reason") { return true } } return false }
containsExecutionStatusRef checks if a specified param has a reference to execution status or reason $(tasks.<task-name>.status), $(tasks.status), or $(tasks.<task-name>.reason)
containsExecutionStatusRef
go
tektoncd/cli
vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipeline_validation.go
https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipeline_validation.go
Apache-2.0
func validateExecutionStatusVariablesInTasks(tasks []PipelineTask) (errs *apis.FieldError) { for idx, t := range tasks { errs = errs.Also(t.validateExecutionStatusVariablesDisallowed().ViaIndex(idx)) } return errs }
validate dag pipeline tasks, task params can not access execution status of any other task dag tasks cannot have param value as $(tasks.pipelineTask.status)
validateExecutionStatusVariablesInTasks
go
tektoncd/cli
vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipeline_validation.go
https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipeline_validation.go
Apache-2.0
func validateExecutionStatusVariablesInFinally(tasksNames sets.String, finally []PipelineTask) (errs *apis.FieldError) { for idx, t := range finally { errs = errs.Also(t.validateExecutionStatusVariablesAllowed(tasksNames).ViaIndex(idx)) } return errs }
validate finally tasks accessing execution status of a dag task specified in the pipeline $(tasks.pipelineTask.status) is invalid if pipelineTask is not defined as a dag task
validateExecutionStatusVariablesInFinally
go
tektoncd/cli
vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipeline_validation.go
https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipeline_validation.go
Apache-2.0
func validatePipelineResults(results []PipelineResult, tasks []PipelineTask, finally []PipelineTask) (errs *apis.FieldError) { pipelineTaskNames := getPipelineTasksNames(tasks) pipelineFinallyTaskNames := getPipelineTasksNames(finally) for idx, result := range results { expressions, ok := GetVarSubstitutionExpressionsForPipelineResult(result) if !ok { errs = errs.Also(apis.ErrInvalidValue("expected pipeline results to be task result expressions but no expressions were found", "value").ViaFieldIndex("results", idx)) } if !LooksLikeContainsResultRefs(expressions) { errs = errs.Also(apis.ErrInvalidValue("expected pipeline results to be task result expressions but an invalid expressions was found", "value").ViaFieldIndex("results", idx)) } expressions = filter(expressions, resultref.LooksLikeResultRef) resultRefs := NewResultRefs(expressions) if len(expressions) != len(resultRefs) { errs = errs.Also(apis.ErrInvalidValue(fmt.Sprintf("expected all of the expressions %v to be result expressions but only %v were", expressions, resultRefs), "value").ViaFieldIndex("results", idx)) } if !taskContainsResult(result.Value.StringVal, pipelineTaskNames, pipelineFinallyTaskNames) { errs = errs.Also(apis.ErrInvalidValue("referencing a nonexistent task", "value").ViaFieldIndex("results", idx)) } } return errs }
validatePipelineResults ensure that pipeline result variables are properly configured
validatePipelineResults
go
tektoncd/cli
vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipeline_validation.go
https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipeline_validation.go
Apache-2.0
func getPipelineTasksNames(pipelineTasks []PipelineTask) sets.String { pipelineTaskNames := make(sets.String) for _, pipelineTask := range pipelineTasks { pipelineTaskNames.Insert(pipelineTask.Name) } return pipelineTaskNames }
put task names in a set
getPipelineTasksNames
go
tektoncd/cli
vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipeline_validation.go
https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipeline_validation.go
Apache-2.0
func taskContainsResult(resultExpression string, pipelineTaskNames sets.String, pipelineFinallyTaskNames sets.String) bool { // split incase of multiple resultExpressions in the same result.Value string // i.e "$(task.<task-name).result.<result-name>) - $(task2.<task2-name).result2.<result2-name>)" split := strings.Split(resultExpression, "$") for _, expression := range split { if expression != "" { value := stripVarSubExpression("$" + expression) pr, err := resultref.ParseTaskExpression(value) if err != nil { return false } if strings.HasPrefix(value, "tasks") && !pipelineTaskNames.Has(pr.ResourceName) { return false } if strings.HasPrefix(value, "finally") && !pipelineFinallyTaskNames.Has(pr.ResourceName) { return false } } } return true }
taskContainsResult ensures the result value is referenced within the task names
taskContainsResult
go
tektoncd/cli
vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipeline_validation.go
https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipeline_validation.go
Apache-2.0
func validateGraph(tasks []PipelineTask) (errs *apis.FieldError) { if _, err := dag.Build(PipelineTaskList(tasks), PipelineTaskList(tasks).Deps()); err != nil { errs = errs.Also(apis.ErrInvalidValue(err.Error(), "tasks")) } return errs }
validateGraph ensures the Pipeline's dependency Graph (DAG) make sense: that there is no dependency cycle or that they rely on values from Tasks that ran previously, and that the PipelineResource is actually an output of the Task it should come from.
validateGraph
go
tektoncd/cli
vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipeline_validation.go
https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipeline_validation.go
Apache-2.0
func findAndValidateResultRefsForMatrix(tasks []PipelineTask, taskMapping map[string]PipelineTask) (resultRefs []*ResultRef, errs *apis.FieldError) { for _, t := range tasks { for _, p := range t.Params { if expressions, ok := GetVarSubstitutionExpressionsForParam(p); ok { if LooksLikeContainsResultRefs(expressions) { resultRefs, errs = validateMatrixedPipelineTaskConsumed(expressions, taskMapping) if errs != nil { return nil, errs } } } } } return resultRefs, errs }
findAndValidateResultRefsForMatrix checks that any result references to Matrixed PipelineTasks if consumed by another PipelineTask that the entire array of results produced by a matrix is consumed in aggregate since consuming a singular result produced by a matrix is currently not supported
findAndValidateResultRefsForMatrix
go
tektoncd/cli
vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipeline_validation.go
https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipeline_validation.go
Apache-2.0
func validateMatrixedPipelineTaskConsumed(expressions []string, taskMapping map[string]PipelineTask) (resultRefs []*ResultRef, errs *apis.FieldError) { var filteredExpressions []string for _, expression := range expressions { // ie. "tasks.<pipelineTaskName>.results.<resultName>[*]" subExpressions := strings.Split(expression, ".") pipelineTask := subExpressions[1] // pipelineTaskName taskConsumed := taskMapping[pipelineTask] if taskConsumed.IsMatrixed() { if !strings.HasSuffix(expression, "[*]") { errs = errs.Also(apis.ErrGeneric("A matrixed pipelineTask can only be consumed in aggregate using [*] notation, but is currently set to " + expression)) } filteredExpressions = append(filteredExpressions, expression) } } return NewResultRefs(filteredExpressions), errs }
validateMatrixedPipelineTaskConsumed checks that any Matrixed Pipeline Task that the is being consumed is consumed in aggregate [*] since consuming a singular result produced by a matrix is currently not supported
validateMatrixedPipelineTaskConsumed
go
tektoncd/cli
vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipeline_validation.go
https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipeline_validation.go
Apache-2.0
func validateTaskResultsFromMatrixedPipelineTasksConsumed(tasks []PipelineTask) (errs *apis.FieldError) { taskMapping := createTaskMapping(tasks) resultRefs, errs := findAndValidateResultRefsForMatrix(tasks, taskMapping) if errs != nil { return errs } errs = errs.Also(validateMatrixEmittingStringResults(resultRefs, taskMapping)) return errs }
validateTaskResultsFromMatrixedPipelineTasksConsumed checks that any Matrixed Pipeline Task that the is being consumed is consumed in aggregate [*] since consuming a singular result produced by a matrix is currently not supported. It also validates that a matrix emitting results can only emit results with the underlying type string if those results are being consumed by another PipelineTask.
validateTaskResultsFromMatrixedPipelineTasksConsumed
go
tektoncd/cli
vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipeline_validation.go
https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipeline_validation.go
Apache-2.0
func createTaskMapping(tasks []PipelineTask) (taskMap map[string]PipelineTask) { taskMapping := make(map[string]PipelineTask) for _, task := range tasks { taskMapping[task.Name] = task } return taskMapping }
createTaskMapping maps the PipelineTaskName to the PipelineTask to easily access the pipelineTask by Name
createTaskMapping
go
tektoncd/cli
vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipeline_validation.go
https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipeline_validation.go
Apache-2.0
func validateMatrixEmittingStringResults(resultRefs []*ResultRef, taskMapping map[string]PipelineTask) (errs *apis.FieldError) { for _, resultRef := range resultRefs { task := taskMapping[resultRef.PipelineTask] resultName := resultRef.Result if task.TaskRef != nil { referencedTaskName := task.TaskRef.Name referencedTask := taskMapping[referencedTaskName] if referencedTask.TaskSpec != nil { errs = errs.Also(validateStringResults(referencedTask.TaskSpec.Results, resultName)) } } else if task.TaskSpec != nil { errs = errs.Also(validateStringResults(task.TaskSpec.Results, resultName)) } } return errs }
validateMatrixEmittingStringResults checks a matrix emitting results can only emit results with the underlying type string if those results are being consumed by another PipelineTask.
validateMatrixEmittingStringResults
go
tektoncd/cli
vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipeline_validation.go
https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipeline_validation.go
Apache-2.0
func validateStringResults(results []TaskResult, resultName string) (errs *apis.FieldError) { for _, result := range results { if result.Name == resultName { if result.Type != ResultsTypeString { errs = errs.Also(apis.ErrInvalidValue( fmt.Sprintf("Matrixed PipelineTasks emitting results must have an underlying type string, but result %s has type %s in pipelineTask", resultName, string(result.Type)), "", )) } } } return errs }
validateStringResults ensure that the result type is string
validateStringResults
go
tektoncd/cli
vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipeline_validation.go
https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipeline_validation.go
Apache-2.0
func validateArtifactReference(ctx context.Context, tasks []PipelineTask, finalTasks []PipelineTask) (errs *apis.FieldError) { if config.FromContextOrDefaults(ctx).FeatureFlags.EnableArtifacts { return errs } for i, t := range tasks { for _, v := range t.Params.extractValues() { if len(artifactref.TaskArtifactRegex.FindAllStringSubmatch(v, -1)) > 0 { return errs.Also(apis.ErrGeneric(fmt.Sprintf("feature flag %s should be set to true to use artifacts feature.", config.EnableArtifacts), "").ViaField("params").ViaFieldIndex("tasks", i)) } } } for i, t := range finalTasks { for _, v := range t.Params.extractValues() { if len(artifactref.TaskArtifactRegex.FindAllStringSubmatch(v, -1)) > 0 { return errs.Also(apis.ErrGeneric(fmt.Sprintf("feature flag %s should be set to true to use artifacts feature.", config.EnableArtifacts), "").ViaField("params").ViaFieldIndex("finally", i)) } } } return errs }
validateArtifactReference ensure that the feature flag enableArtifacts is set to true when using artifacts
validateArtifactReference
go
tektoncd/cli
vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipeline_validation.go
https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipeline_validation.go
Apache-2.0
func (ps *PipelineSpec) GetIndexingReferencesToArrayParams() sets.String { paramsRefs := []string{} for i := range ps.Tasks { paramsRefs = append(paramsRefs, ps.Tasks[i].Params.extractValues()...) if ps.Tasks[i].IsMatrixed() { paramsRefs = append(paramsRefs, ps.Tasks[i].Matrix.Params.extractValues()...) } for j := range ps.Tasks[i].Workspaces { paramsRefs = append(paramsRefs, ps.Tasks[i].Workspaces[j].SubPath) } for _, wes := range ps.Tasks[i].WhenExpressions { paramsRefs = append(paramsRefs, wes.Input) paramsRefs = append(paramsRefs, wes.Values...) } } for i := range ps.Finally { paramsRefs = append(paramsRefs, ps.Finally[i].Params.extractValues()...) if ps.Finally[i].IsMatrixed() { paramsRefs = append(paramsRefs, ps.Finally[i].Matrix.Params.extractValues()...) } for _, wes := range ps.Finally[i].WhenExpressions { paramsRefs = append(paramsRefs, wes.Input) paramsRefs = append(paramsRefs, wes.Values...) } } // extract all array indexing references, for example []{"$(params.array-params[1])"} arrayIndexParamRefs := []string{} for _, p := range paramsRefs { arrayIndexParamRefs = append(arrayIndexParamRefs, extractArrayIndexingParamRefs(p)...) } return sets.NewString(arrayIndexParamRefs...) }
GetIndexingReferencesToArrayParams returns all strings referencing indices of PipelineRun array parameters from parameters, workspaces, and when expressions defined in the Pipeline's Tasks and Finally Tasks. For example, if a Task in the Pipeline has a parameter with a value "$(params.array-param-name[1])", this would be one of the strings returned.
GetIndexingReferencesToArrayParams
go
tektoncd/cli
vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipeline_validation.go
https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipeline_validation.go
Apache-2.0
func (tr *TaskRun) 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/taskrun_validation.go
https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/taskrun_validation.go
Apache-2.0
func (ts *TaskRunSpec) Validate(ctx context.Context) (errs *apis.FieldError) { // Validate the spec changes errs = errs.Also(ts.ValidateUpdate(ctx)) // Must have exactly one of taskRef and taskSpec. if ts.TaskRef == nil && ts.TaskSpec == nil { errs = errs.Also(apis.ErrMissingOneOf("taskRef", "taskSpec")) } if ts.TaskRef != nil && ts.TaskSpec != nil { errs = errs.Also(apis.ErrMultipleOneOf("taskRef", "taskSpec")) } // Validate TaskRef if it's present. if ts.TaskRef != nil { errs = errs.Also(ts.TaskRef.Validate(ctx).ViaField("taskRef")) } // Validate TaskSpec if it's present. if ts.TaskSpec != nil { if slices.Contains(strings.Split( config.FromContextOrDefaults(ctx).FeatureFlags.DisableInlineSpec, ","), "taskrun") { errs = errs.Also(apis.ErrDisallowedFields("taskSpec")) } errs = errs.Also(ts.TaskSpec.Validate(ctx).ViaField("taskSpec")) } errs = errs.Also(ValidateParameters(ctx, ts.Params).ViaField("params")) // Validate propagated parameters errs = errs.Also(ts.validateInlineParameters(ctx)) errs = errs.Also(ValidateWorkspaceBindings(ctx, ts.Workspaces).ViaField("workspaces")) if ts.Debug != nil { errs = errs.Also(config.ValidateEnabledAPIFields(ctx, "debug", config.AlphaAPIFields).ViaField("debug")) errs = errs.Also(validateDebug(ts.Debug).ViaField("debug")) } if ts.StepOverrides != nil { errs = errs.Also(config.ValidateEnabledAPIFields(ctx, "stepOverrides", config.BetaAPIFields).ViaField("stepOverrides")) errs = errs.Also(validateStepOverrides(ts.StepOverrides).ViaField("stepOverrides")) } if ts.SidecarOverrides != nil { errs = errs.Also(config.ValidateEnabledAPIFields(ctx, "sidecarOverrides", config.BetaAPIFields).ViaField("sidecarOverrides")) errs = errs.Also(validateSidecarOverrides(ts.SidecarOverrides).ViaField("sidecarOverrides")) } if ts.ComputeResources != nil { errs = errs.Also(config.ValidateEnabledAPIFields(ctx, "computeResources", config.BetaAPIFields).ViaField("computeResources")) errs = errs.Also(validateTaskRunComputeResources(ts.ComputeResources, ts.StepOverrides)) } if ts.Status != "" { if ts.Status != TaskRunSpecStatusCancelled { errs = errs.Also(apis.ErrInvalidValue(fmt.Sprintf("%s should be %s", ts.Status, TaskRunSpecStatusCancelled), "status")) } } if ts.Status == "" { if ts.StatusMessage != "" { errs = errs.Also(apis.ErrInvalidValue(fmt.Sprintf("statusMessage should not be set if status is not set, but it is currently set to %s", ts.StatusMessage), "statusMessage")) } } if ts.Timeout != nil { // timeout should be a valid duration of at least 0. if ts.Timeout.Duration < 0 { errs = errs.Also(apis.ErrInvalidValue(ts.Timeout.Duration.String()+" should be >= 0", "timeout")) } } if ts.PodTemplate != nil { errs = errs.Also(validatePodTemplateEnv(ctx, *ts.PodTemplate)) } if ts.Resources != nil { errs = errs.Also(apis.ErrDisallowedFields("resources")) } return errs }
Validate taskrun spec
Validate
go
tektoncd/cli
vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/taskrun_validation.go
https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/taskrun_validation.go
Apache-2.0
func (ts *TaskRunSpec) ValidateUpdate(ctx context.Context) (errs *apis.FieldError) { if !apis.IsInUpdate(ctx) { return } oldObj, ok := apis.GetBaseline(ctx).(*TaskRun) if !ok || oldObj == nil { return } old := &oldObj.Spec // If already in the done state, the spec cannot be modified. // Otherwise, only the status, statusMessage field can be modified. tips := "Once the TaskRun is complete, no updates are allowed" if !oldObj.IsDone() { old = old.DeepCopy() old.Status = ts.Status old.StatusMessage = ts.StatusMessage tips = "Once the TaskRun has started, only status and statusMessage updates are allowed" } if !equality.Semantic.DeepEqual(old, ts) { errs = errs.Also(apis.ErrInvalidValue(tips, "")) } return }
ValidateUpdate validates the update of a TaskRunSpec
ValidateUpdate
go
tektoncd/cli
vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/taskrun_validation.go
https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/taskrun_validation.go
Apache-2.0
func (ts *TaskRunSpec) validateInlineParameters(ctx context.Context) (errs *apis.FieldError) { if ts.TaskSpec == nil { return errs } paramSpecForValidation := make(map[string]ParamSpec) for _, p := range ts.Params { paramSpecForValidation = createParamSpecFromParam(p, paramSpecForValidation) } for _, p := range ts.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 ts.TaskSpec != nil && ts.TaskSpec.Steps != nil { errs = errs.Also(ValidateParameterTypes(ctx, paramSpec)) errs = errs.Also(ValidateParameterVariables(ctx, ts.TaskSpec.Steps, paramSpec)) errs = errs.Also(ValidateUsageOfDeclaredParameters(ctx, ts.TaskSpec.Steps, paramSpec)) } return errs }
validateInlineParameters validates that any parameters called in the Task spec are declared in the TaskRun. This is crucial for propagated parameters because the parameters could be defined under taskRun and then called directly in the task steps. In this case, parameters cannot be validated by the underlying 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/taskrun_validation.go
https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/taskrun_validation.go
Apache-2.0
func validateDebug(db *TaskRunDebug) (errs *apis.FieldError) { if db == nil || db.Breakpoints == nil { return errs } if db.Breakpoints.OnFailure == "" { errs = errs.Also(apis.ErrInvalidValue("onFailure breakpoint is empty, it is only allowed to be set as enabled", "breakpoints.onFailure")) } if db.Breakpoints.OnFailure != "" && db.Breakpoints.OnFailure != EnabledOnFailureBreakpoint { errs = errs.Also(apis.ErrInvalidValue(db.Breakpoints.OnFailure+" is not a valid onFailure breakpoint value, onFailure breakpoint is only allowed to be set as enabled", "breakpoints.onFailure")) } beforeSteps := sets.NewString() for i, step := range db.Breakpoints.BeforeSteps { if beforeSteps.Has(step) { errs = errs.Also(apis.ErrGeneric(fmt.Sprintf("before step must be unique, the same step: %s is defined multiple times at", step), fmt.Sprintf("breakpoints.beforeSteps[%d]", i))) } beforeSteps.Insert(step) } return errs }
validateDebug validates the debug section of the TaskRun. if set, onFailure breakpoint must be "enabled"
validateDebug
go
tektoncd/cli
vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/taskrun_validation.go
https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/taskrun_validation.go
Apache-2.0
func ValidateWorkspaceBindings(ctx context.Context, wb []WorkspaceBinding) (errs *apis.FieldError) { var names []string for idx, w := range wb { names = append(names, w.Name) errs = errs.Also(w.Validate(ctx).ViaIndex(idx)) } errs = errs.Also(validateNoDuplicateNames(names, true)) return errs }
ValidateWorkspaceBindings makes sure the volumes provided for the Task's declared workspaces make sense.
ValidateWorkspaceBindings
go
tektoncd/cli
vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/taskrun_validation.go
https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/taskrun_validation.go
Apache-2.0
func ValidateParameters(ctx context.Context, params Params) (errs *apis.FieldError) { var names []string for _, p := range params { names = append(names, p.Name) } return errs.Also(validateNoDuplicateNames(names, false)) }
ValidateParameters makes sure the params for the Task are valid.
ValidateParameters
go
tektoncd/cli
vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/taskrun_validation.go
https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/taskrun_validation.go
Apache-2.0
func validateTaskRunComputeResources(computeResources *corev1.ResourceRequirements, overrides []TaskRunStepOverride) (errs *apis.FieldError) { for _, override := range overrides { if override.Resources.Size() != 0 && computeResources != nil { return apis.ErrMultipleOneOf( "stepOverrides.resources", "computeResources", ) } } return nil }
validateTaskRunComputeResources ensures that compute resources are not configured at both the step level and the task level
validateTaskRunComputeResources
go
tektoncd/cli
vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/taskrun_validation.go
https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/taskrun_validation.go
Apache-2.0
func validateNoDuplicateNames(names []string, byIndex bool) (errs *apis.FieldError) { seen := sets.NewString() for i, n := range names { if seen.Has(strings.ToLower(n)) { if byIndex { errs = errs.Also(apis.ErrMultipleOneOf("name").ViaIndex(i)) } else { errs = errs.Also(apis.ErrMultipleOneOf("name").ViaKey(n)) } } seen.Insert(strings.ToLower(n)) } return errs }
validateNoDuplicateNames returns an error for each name that is repeated in names. Case insensitive. If byIndex is true, the error will be reported by index instead of by key.
validateNoDuplicateNames
go
tektoncd/cli
vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/taskrun_validation.go
https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/taskrun_validation.go
Apache-2.0
func (t *Task) TaskSpec() TaskSpec { return t.Spec }
TaskSpec returns the task's spec
TaskSpec
go
tektoncd/cli
vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/task_types.go
https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/task_types.go
Apache-2.0
func (t *Task) TaskMetadata() metav1.ObjectMeta { return t.ObjectMeta }
TaskMetadata returns the task's ObjectMeta
TaskMetadata
go
tektoncd/cli
vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/task_types.go
https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/task_types.go
Apache-2.0
func (t *Task) Copy() TaskObject { return t.DeepCopy() }
Copy returns a deep copy of the task
Copy
go
tektoncd/cli
vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/task_types.go
https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/task_types.go
Apache-2.0
func (*Task) GetGroupVersionKind() schema.GroupVersionKind { return SchemeGroupVersion.WithKind(pipeline.TaskControllerName) }
GetGroupVersionKind implements kmeta.OwnerRefable.
GetGroupVersionKind
go
tektoncd/cli
vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/task_types.go
https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/task_types.go
Apache-2.0
func (t *Task) Checksum() ([]byte, error) { objectMeta := checksum.PrepareObjectMeta(t) preprocessedTask := Task{ TypeMeta: metav1.TypeMeta{ APIVersion: "tekton.dev/v1beta1", Kind: "Task"}, ObjectMeta: objectMeta, Spec: t.Spec, } sha256Checksum, err := checksum.ComputeSha256Checksum(preprocessedTask) if err != nil { return nil, err } return sha256Checksum, nil }
Checksum computes the sha256 checksum of the task object. Prior to computing the checksum, it performs some preprocessing on the metadata of the object where it removes system provided annotations. Only the name, namespace, generateName, user-provided labels and annotations and the taskSpec are included for the checksum computation.
Checksum
go
tektoncd/cli
vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/task_types.go
https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/task_types.go
Apache-2.0
func (ts *TaskSpec) HasDeprecatedFields() bool { if ts == nil { return false } if len(ts.Steps) > 0 { for _, s := range ts.Steps { if len(s.DeprecatedPorts) > 0 || s.DeprecatedLivenessProbe != nil || s.DeprecatedReadinessProbe != nil || s.DeprecatedStartupProbe != nil || s.DeprecatedLifecycle != nil || s.DeprecatedTerminationMessagePath != "" || s.DeprecatedTerminationMessagePolicy != "" || s.DeprecatedStdin || s.DeprecatedStdinOnce || s.DeprecatedTTY { return true } } } if ts.StepTemplate != nil { if len(ts.StepTemplate.DeprecatedPorts) > 0 || ts.StepTemplate.DeprecatedName != "" || ts.StepTemplate.DeprecatedReadinessProbe != nil || ts.StepTemplate.DeprecatedStartupProbe != nil || ts.StepTemplate.DeprecatedLifecycle != nil || ts.StepTemplate.DeprecatedTerminationMessagePath != "" || ts.StepTemplate.DeprecatedTerminationMessagePolicy != "" || ts.StepTemplate.DeprecatedStdin || ts.StepTemplate.DeprecatedStdinOnce || ts.StepTemplate.DeprecatedTTY { return true } } return false }
HasDeprecatedFields returns true if the TaskSpec has deprecated field specified.
HasDeprecatedFields
go
tektoncd/cli
vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/task_types.go
https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/task_types.go
Apache-2.0
func (tr *TaskRef) ConvertFrom(ctx context.Context, source v1.TaskRef) { tr.Name = source.Name tr.Kind = TaskKind(source.Kind) tr.APIVersion = source.APIVersion new := ResolverRef{} new.convertFrom(ctx, source.ResolverRef) tr.ResolverRef = new }
ConvertFrom converts v1beta1 TaskRef from v1 TaskRef
ConvertFrom
go
tektoncd/cli
vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/taskref_conversion.go
https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/taskref_conversion.go
Apache-2.0
func (pr *PipelineRun) ConvertTo(ctx context.Context, to apis.Convertible) error { if apis.IsInDelete(ctx) { return nil } switch sink := to.(type) { case *v1.PipelineRun: sink.ObjectMeta = pr.ObjectMeta if err := serializePipelineRunResources(&sink.ObjectMeta, &pr.Spec); err != nil { return err } if err := pr.Status.convertTo(ctx, &sink.Status, &sink.ObjectMeta); err != nil { return err } return pr.Spec.ConvertTo(ctx, &sink.Spec, &sink.ObjectMeta) default: return fmt.Errorf("unknown version, got: %T", sink) }
ConvertTo implements apis.Convertible
ConvertTo
go
tektoncd/cli
vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipelinerun_conversion.go
https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipelinerun_conversion.go
Apache-2.0
func (e *UserError) Error() string { return e.Original.Error() }
Error returns the original error message. This implements the error.Error interface.
Error
go
tektoncd/cli
vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/errors/errors.go
https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/errors/errors.go
Apache-2.0
func (e *UserError) Unwrap() error { return e.Original }
Unwrap returns the original error without the Reason annotation. This is intended to support usage of errors.Is and errors.As with Errors.
Unwrap
go
tektoncd/cli
vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/errors/errors.go
https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/errors/errors.go
Apache-2.0
func newUserError(reason string, err error) *UserError { return &UserError{ Reason: reason, Original: err, } }
newUserError returns a UserError with the given reason and underlying original error.
newUserError
go
tektoncd/cli
vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/errors/errors.go
https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/errors/errors.go
Apache-2.0
func WrapUserError(err error) error { return newUserError(UserErrorLabel, err) }
WrapUserError wraps the original error with the user error label
WrapUserError
go
tektoncd/cli
vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/errors/errors.go
https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/errors/errors.go
Apache-2.0
func LabelUserError(messageFormat string, messageA []interface{}) string { for _, message := range messageA { if ue, ok := message.(*UserError); ok { return ue.Reason + messageFormat } } return messageFormat }
LabelUserError labels the failure RunStatus message if any of its error messages has been wrapped as an UserError. It indicates that the user is responsible for an error. See github.com/tektoncd/pipeline/blob/main/docs/pipelineruns.md#marking-off-user-errors for more details.
LabelUserError
go
tektoncd/cli
vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/errors/errors.go
https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/errors/errors.go
Apache-2.0
func GetErrorMessage(err error) string { var ue *UserError if errors.As(err, &ue) { return ue.Reason + err.Error() } return err.Error() }
GetErrorMessage returns the error message with the user error label if it is of type user error
GetErrorMessage
go
tektoncd/cli
vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/errors/errors.go
https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/errors/errors.go
Apache-2.0
func IsImmutableTaskRunSpecError(err error) bool { // The TaskRun may have completed and the spec field is immutable. // validation code: https://github.com/tektoncd/pipeline/blob/v0.62.0/pkg/apis/pipeline/v1/taskrun_validation.go#L136-L138 return apierrors.IsBadRequest(err) && strings.Contains(err.Error(), "no updates are allowed") }
IsImmutableTaskRunSpecError returns true if the error is the taskrun spec is immutable
IsImmutableTaskRunSpecError
go
tektoncd/cli
vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/errors/errors.go
https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/errors/errors.go
Apache-2.0
func (p *Pipeline) ConvertTo(ctx context.Context, sink apis.Convertible) error { if apis.IsInDelete(ctx) { return nil } return fmt.Errorf("v1 is the highest known version, got: %T", sink) }
ConvertTo implements apis.Convertible
ConvertTo
go
tektoncd/cli
vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1/pipeline_conversion.go
https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1/pipeline_conversion.go
Apache-2.0
func (p *Pipeline) ConvertFrom(ctx context.Context, source apis.Convertible) error { if apis.IsInDelete(ctx) { return nil } return fmt.Errorf("v1 is the highest known version, got: %T", source) }
ConvertFrom implements apis.Convertible
ConvertFrom
go
tektoncd/cli
vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1/pipeline_conversion.go
https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1/pipeline_conversion.go
Apache-2.0
func (tr *TaskRef) IsCustomTask() bool { // Note that if `apiVersion` is set to `"tekton.dev/v1beta1"` and `kind` is set to `"Task"`, // the reference will be considered a Custom Task - https://github.com/tektoncd/pipeline/issues/6457 return tr != nil && tr.APIVersion != "" && tr.Kind != "" }
IsCustomTask checks whether the reference is to a Custom Task
IsCustomTask
go
tektoncd/cli
vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1/taskref_types.go
https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1/taskref_types.go
Apache-2.0
func (pp *ParamSpec) SetDefaults(context.Context) { if pp == nil { return } // Propagate inferred type to the parent ParamSpec's type, and default type to the PropertySpec's type // The sequence to look at is type in ParamSpec -> properties -> type in default -> array/string/object value in default // If neither `properties` or `default` section is provided, ParamTypeString will be the default type. switch { case pp.Type != "": // If param type is provided by the author, do nothing but just set default type for PropertySpec in case `properties` section is provided. pp.setDefaultsForProperties() case pp.Properties != nil: pp.Type = ParamTypeObject // Also set default type for PropertySpec pp.setDefaultsForProperties() case pp.Default == nil: // ParamTypeString is the default value (when no type can be inferred from the default value) pp.Type = ParamTypeString case pp.Default.Type != "": pp.Type = pp.Default.Type case pp.Default.ArrayVal != nil: pp.Type = ParamTypeArray case pp.Default.ObjectVal != nil: pp.Type = ParamTypeObject default: pp.Type = ParamTypeString } }
SetDefaults set the default type
SetDefaults
go
tektoncd/cli
vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1/param_types.go
https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1/param_types.go
Apache-2.0
func (pp *ParamSpec) setDefaultsForProperties() { for key, propertySpec := range pp.Properties { if propertySpec.Type == "" { pp.Properties[key] = PropertySpec{Type: ParamTypeString} } } }
setDefaultsForProperties sets default type for PropertySpec (string) if it's not specified
setDefaultsForProperties
go
tektoncd/cli
vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1/param_types.go
https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1/param_types.go
Apache-2.0
func (ps ParamSpecs) GetNames() []string { var names []string for _, p := range ps { names = append(names, p.Name) } return names }
GetNames returns all the names of the declared parameters
GetNames
go
tektoncd/cli
vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1/param_types.go
https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1/param_types.go
Apache-2.0
func (ps ParamSpecs) SortByType() (ParamSpecs, ParamSpecs, ParamSpecs) { var stringParams, arrayParams, objectParams ParamSpecs for _, p := range ps { switch p.Type { case ParamTypeArray: arrayParams = append(arrayParams, p) case ParamTypeObject: objectParams = append(objectParams, p) case ParamTypeString: fallthrough default: stringParams = append(stringParams, p) } } return stringParams, arrayParams, objectParams }
SortByType splits the input params into string params, array params, and object params, in that order
SortByType
go
tektoncd/cli
vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1/param_types.go
https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1/param_types.go
Apache-2.0
func (ps ParamSpecs) ValidateNoDuplicateNames() *apis.FieldError { var errs *apis.FieldError names := ps.GetNames() for dup := range findDups(names) { errs = errs.Also(apis.ErrGeneric("parameter appears more than once", "").ViaFieldKey("params", dup)) } return errs }
ValidateNoDuplicateNames returns an error if any of the params have the same name
ValidateNoDuplicateNames
go
tektoncd/cli
vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1/param_types.go
https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1/param_types.go
Apache-2.0
func (ps ParamSpecs) validateParamEnums(ctx context.Context) *apis.FieldError { var errs *apis.FieldError for _, p := range ps { if len(p.Enum) == 0 { continue } if !config.FromContextOrDefaults(ctx).FeatureFlags.EnableParamEnum { errs = errs.Also(errs, apis.ErrGeneric(fmt.Sprintf("feature flag `%s` should be set to true to use Enum", config.EnableParamEnum), "").ViaKey(p.Name)) } if p.Type != ParamTypeString { errs = errs.Also(apis.ErrGeneric("enum can only be set with string type param", "").ViaKey(p.Name)) } for dup := range findDups(p.Enum) { errs = errs.Also(apis.ErrGeneric(fmt.Sprintf("parameter enum value %v appears more than once", dup), "").ViaKey(p.Name)) } if p.Default != nil && p.Default.StringVal != "" { if !slices.Contains(p.Enum, p.Default.StringVal) { errs = errs.Also(apis.ErrGeneric(fmt.Sprintf("param default value %v not in the enum list", p.Default.StringVal), "").ViaKey(p.Name)) } } } return errs }
validateParamEnums validates feature flag, duplication and allowed types for Param Enum
validateParamEnums
go
tektoncd/cli
vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1/param_types.go
https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1/param_types.go
Apache-2.0