Skip to content

Commit

Permalink
add tekton types
Browse files Browse the repository at this point in the history
  • Loading branch information
Richard87 committed Jan 11, 2024
1 parent ad489cb commit 123a78c
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 5 deletions.
6 changes: 3 additions & 3 deletions api/jobs/job_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,13 +238,13 @@ func buildPipelineRunTaskStepModels(taskRun *pipelinev1.TaskRun) []jobModels.Pip
if stepStatus.Terminated != nil {
stepModel.Started = radixutils.FormatTime(&stepStatus.Terminated.StartedAt)
stepModel.Ended = radixutils.FormatTime(&stepStatus.Terminated.FinishedAt)
stepModel.Status = stepStatus.Terminated.Reason
stepModel.Status = jobModels.TaskRunReason(stepStatus.Terminated.Reason)
stepModel.StatusMessage = stepStatus.Terminated.Message
} else if stepStatus.Running != nil {
stepModel.Started = radixutils.FormatTime(&stepStatus.Running.StartedAt)
stepModel.Status = jobModels.Running.String()
stepModel.Status = jobModels.TaskRunReason(jobModels.Running.String())
} else if stepStatus.Waiting != nil {
stepModel.Status = stepStatus.Waiting.Reason
stepModel.Status = jobModels.TaskRunReason(stepStatus.Waiting.Reason)
stepModel.StatusMessage = stepStatus.Waiting.Message
}
stepsModels = append(stepsModels, stepModel)
Expand Down
54 changes: 53 additions & 1 deletion api/jobs/models/pipeline_run_task_step.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package models

import v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1"

// PipelineRunTaskStep holds general information about pipeline run task steps
// swagger:model PipelineRunTaskStep
type PipelineRunTaskStep struct {
Expand All @@ -13,7 +15,7 @@ type PipelineRunTaskStep struct {
//
// required: false
// example: Completed
Status string `json:"status"`
Status TaskRunReason `json:"status"`

// StatusMessage of the task
//
Expand All @@ -32,3 +34,53 @@ type PipelineRunTaskStep struct {
// example: 2006-01-02T15:04:05Z
Ended string `json:"ended"`
}

// TaskRunReason copies the fields from github.com/tektoncd/pipeline so go-swagger can map the enums
// swagger:enum TaskRunReason
type TaskRunReason v1.TaskRunReason

const (
// TaskRunReasonStarted is the reason set when the TaskRun has just started
TaskRunReasonStarted TaskRunReason = "Started"
// TaskRunReasonRunning is the reason set when the TaskRun is running
TaskRunReasonRunning TaskRunReason = "Running"
// TaskRunReasonSuccessful is the reason set when the TaskRun completed successfully
TaskRunReasonSuccessful TaskRunReason = "Succeeded"
// TaskRunReasonFailed is the reason set when the TaskRun completed with a failure
TaskRunReasonFailed TaskRunReason = "Failed"
// TaskRunReasonToBeRetried is the reason set when the last TaskRun execution failed, and will be retried
TaskRunReasonToBeRetried TaskRunReason = "ToBeRetried"
// TaskRunReasonCancelled is the reason set when the TaskRun is cancelled by the user
TaskRunReasonCancelled TaskRunReason = "TaskRunCancelled"
// TaskRunReasonTimedOut is the reason set when one TaskRun execution has timed out
TaskRunReasonTimedOut TaskRunReason = "TaskRunTimeout"
// TaskRunReasonResolvingTaskRef indicates that the TaskRun is waiting for
// its taskRef to be asynchronously resolved.
TaskRunReasonResolvingTaskRef = "ResolvingTaskRef"
// TaskRunReasonResolvingStepActionRef indicates that the TaskRun is waiting for
// its StepAction's Ref to be asynchronously resolved.
TaskRunReasonResolvingStepActionRef = "ResolvingStepActionRef"
// TaskRunReasonImagePullFailed is the reason set when the step of a task fails due to image not being pulled
TaskRunReasonImagePullFailed TaskRunReason = "TaskRunImagePullFailed"
// TaskRunReasonResultLargerThanAllowedLimit is the reason set when one of the results exceeds its maximum allowed limit of 1 KB
TaskRunReasonResultLargerThanAllowedLimit TaskRunReason = "TaskRunResultLargerThanAllowedLimit"
// TaskRunReasonStopSidecarFailed indicates that the sidecar is not properly stopped.
TaskRunReasonStopSidecarFailed TaskRunReason = "TaskRunStopSidecarFailed"
// TaskRunReasonInvalidParamValue indicates that the TaskRun Param input value is not allowed.
TaskRunReasonInvalidParamValue TaskRunReason = "InvalidParamValue"
// TaskRunReasonFailedResolution indicated that the reason for failure status is
// that references within the TaskRun could not be resolved
TaskRunReasonFailedResolution TaskRunReason = "TaskRunResolutionFailed"
// TaskRunReasonFailedValidation indicated that the reason for failure status is
// that taskrun failed runtime validation
TaskRunReasonFailedValidation TaskRunReason = "TaskRunValidationFailed"
// TaskRunReasonTaskFailedValidation indicated that the reason for failure status is
// that task failed runtime validation
TaskRunReasonTaskFailedValidation TaskRunReason = "TaskValidationFailed"
// TaskRunReasonResourceVerificationFailed indicates that the task fails the trusted resource verification,
// it could be the content has changed, signature is invalid or public key is invalid
TaskRunReasonResourceVerificationFailed TaskRunReason = "ResourceVerificationFailed"
// TaskRunReasonFailureIgnored is the reason set when the Taskrun has failed due to pod execution error and the failure is ignored for the owning PipelineRun.
// TaskRuns failed due to reconciler/validation error should not use this reason.
TaskRunReasonFailureIgnored TaskRunReason = "FailureIgnored"
)
21 changes: 20 additions & 1 deletion swaggerui/html/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -6707,8 +6707,27 @@
"example": "2006-01-02T15:04:05Z"
},
"status": {
"description": "Status of the task",
"description": "Status of the task\nStarted TaskRunReasonStarted TaskRunReasonStarted is the reason set when the TaskRun has just started\nRunning TaskRunReasonRunning TaskRunReasonRunning is the reason set when the TaskRun is running\nSucceeded TaskRunReasonSuccessful TaskRunReasonSuccessful is the reason set when the TaskRun completed successfully\nFailed TaskRunReasonFailed TaskRunReasonFailed is the reason set when the TaskRun completed with a failure\nToBeRetried TaskRunReasonToBeRetried TaskRunReasonToBeRetried is the reason set when the last TaskRun execution failed, and will be retried\nTaskRunCancelled TaskRunReasonCancelled TaskRunReasonCancelled is the reason set when the TaskRun is cancelled by the user\nTaskRunTimeout TaskRunReasonTimedOut TaskRunReasonTimedOut is the reason set when one TaskRun execution has timed out\nTaskRunImagePullFailed TaskRunReasonImagePullFailed TaskRunReasonImagePullFailed is the reason set when the step of a task fails due to image not being pulled\nTaskRunResultLargerThanAllowedLimit TaskRunReasonResultLargerThanAllowedLimit TaskRunReasonResultLargerThanAllowedLimit is the reason set when one of the results exceeds its maximum allowed limit of 1 KB\nTaskRunStopSidecarFailed TaskRunReasonStopSidecarFailed TaskRunReasonStopSidecarFailed indicates that the sidecar is not properly stopped.\nInvalidParamValue TaskRunReasonInvalidParamValue TaskRunReasonInvalidParamValue indicates that the TaskRun Param input value is not allowed.\nTaskRunResolutionFailed TaskRunReasonFailedResolution TaskRunReasonFailedResolution indicated that the reason for failure status is that references within the TaskRun could not be resolved\nTaskRunValidationFailed TaskRunReasonFailedValidation TaskRunReasonFailedValidation indicated that the reason for failure status is that taskrun failed runtime validation\nTaskValidationFailed TaskRunReasonTaskFailedValidation TaskRunReasonTaskFailedValidation indicated that the reason for failure status is that task failed runtime validation\nResourceVerificationFailed TaskRunReasonResourceVerificationFailed TaskRunReasonResourceVerificationFailed indicates that the task fails the trusted resource verification, it could be the content has changed, signature is invalid or public key is invalid\nFailureIgnored TaskRunReasonFailureIgnored TaskRunReasonFailureIgnored is the reason set when the Taskrun has failed due to pod execution error and the failure is ignored for the owning PipelineRun. TaskRuns failed due to reconciler/validation error should not use this reason.",
"type": "string",
"enum": [
"Started",
"Running",
"Succeeded",
"Failed",
"ToBeRetried",
"TaskRunCancelled",
"TaskRunTimeout",
"TaskRunImagePullFailed",
"TaskRunResultLargerThanAllowedLimit",
"TaskRunStopSidecarFailed",
"InvalidParamValue",
"TaskRunResolutionFailed",
"TaskRunValidationFailed",
"TaskValidationFailed",
"ResourceVerificationFailed",
"FailureIgnored"
],
"x-go-enum-desc": "Started TaskRunReasonStarted TaskRunReasonStarted is the reason set when the TaskRun has just started\nRunning TaskRunReasonRunning TaskRunReasonRunning is the reason set when the TaskRun is running\nSucceeded TaskRunReasonSuccessful TaskRunReasonSuccessful is the reason set when the TaskRun completed successfully\nFailed TaskRunReasonFailed TaskRunReasonFailed is the reason set when the TaskRun completed with a failure\nToBeRetried TaskRunReasonToBeRetried TaskRunReasonToBeRetried is the reason set when the last TaskRun execution failed, and will be retried\nTaskRunCancelled TaskRunReasonCancelled TaskRunReasonCancelled is the reason set when the TaskRun is cancelled by the user\nTaskRunTimeout TaskRunReasonTimedOut TaskRunReasonTimedOut is the reason set when one TaskRun execution has timed out\nTaskRunImagePullFailed TaskRunReasonImagePullFailed TaskRunReasonImagePullFailed is the reason set when the step of a task fails due to image not being pulled\nTaskRunResultLargerThanAllowedLimit TaskRunReasonResultLargerThanAllowedLimit TaskRunReasonResultLargerThanAllowedLimit is the reason set when one of the results exceeds its maximum allowed limit of 1 KB\nTaskRunStopSidecarFailed TaskRunReasonStopSidecarFailed TaskRunReasonStopSidecarFailed indicates that the sidecar is not properly stopped.\nInvalidParamValue TaskRunReasonInvalidParamValue TaskRunReasonInvalidParamValue indicates that the TaskRun Param input value is not allowed.\nTaskRunResolutionFailed TaskRunReasonFailedResolution TaskRunReasonFailedResolution indicated that the reason for failure status is that references within the TaskRun could not be resolved\nTaskRunValidationFailed TaskRunReasonFailedValidation TaskRunReasonFailedValidation indicated that the reason for failure status is that taskrun failed runtime validation\nTaskValidationFailed TaskRunReasonTaskFailedValidation TaskRunReasonTaskFailedValidation indicated that the reason for failure status is that task failed runtime validation\nResourceVerificationFailed TaskRunReasonResourceVerificationFailed TaskRunReasonResourceVerificationFailed indicates that the task fails the trusted resource verification, it could be the content has changed, signature is invalid or public key is invalid\nFailureIgnored TaskRunReasonFailureIgnored TaskRunReasonFailureIgnored is the reason set when the Taskrun has failed due to pod execution error and the failure is ignored for the owning PipelineRun. TaskRuns failed due to reconciler/validation error should not use this reason.",
"x-go-name": "Status",
"example": "Completed"
},
Expand Down

0 comments on commit 123a78c

Please sign in to comment.