Skip to content

Commit

Permalink
add docs to new types and functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Michalina Kotwica committed Jun 14, 2022
1 parent 317017a commit d9bae7a
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pkg/pod/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,23 @@ func SidecarsReady(podStatus corev1.PodStatus) bool {
return true
}

// GetTaskSpecFromTaskRun is a function used to retrieve Tasks when given TaskRuns.
type GetTaskSpecFromTaskRun func(tr *v1beta1.TaskRun) (*v1beta1.TaskSpec, error)

// GetTaskSpecNoReconciler implements GetTaskSpecFromTaskRun with no task reconciler.
//
// When TaskRun contains TaskSpec, it is returned. Otherwise, it returns an error.
func GetTaskSpecNoReconciler(tr *v1beta1.TaskRun) (*v1beta1.TaskSpec, error) {
if tr.Spec.TaskSpec != nil {
return tr.Spec.TaskSpec, nil
}
return nil, errors.New("TaskSpec not found when no source of TaskRef specified")
}

// GetTaskSpecMappingReconciler implements GetTaskSpecFromTaskRun with a simple reconciling using map.
//
// When TaskRun contains TaskSpec, it is returned. Otherwise, the map entry is returned.
// If it's absent, an error is produced instead.
func GetTaskSpecMappingReconciler(mapping map[string]*v1beta1.TaskSpec) GetTaskSpecFromTaskRun {
return func(tr *v1beta1.TaskRun) (*v1beta1.TaskSpec, error) {
if tr.Spec.TaskSpec != nil {
Expand Down

0 comments on commit d9bae7a

Please sign in to comment.