Skip to content

Commit

Permalink
Fix capitalization inconsistency in reconciler
Browse files Browse the repository at this point in the history
Fix the first task in #7266

Update error messages returned in pkg/reconciler to begin with lowercase.

Update error logs in pkg/reconciler to begin with uppercase.
  • Loading branch information
mlschmithorst authored and tekton-robot committed Nov 9, 2023
1 parent f08add9 commit e570f36
Show file tree
Hide file tree
Showing 13 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion pkg/reconciler/events/cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func EventKey(event *cloudevents.Event) (string, error) {
return "", err
}
if data.CustomRun == nil {
return "", fmt.Errorf("Invalid CustomRun data in %v", event)
return "", fmt.Errorf("invalid CustomRun data in %v", event)
}
resourceName = data.CustomRun.Name
resourceNamespace = data.CustomRun.Namespace
Expand Down
2 changes: 1 addition & 1 deletion pkg/reconciler/events/cloudevent/cloud_event_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func SendCloudEventWithRetries(ctx context.Context, object runtime.Object) error
if isCustomRun {
cloudEventSent, err := cache.ContainsOrAddCloudEvent(cacheClient, event)
if err != nil {
logger.Errorf("error while checking cache: %s", err)
logger.Errorf("Error while checking cache: %s", err)
}
if cloudEventSent {
logger.Infof("cloudevent %v already sent", event)
Expand Down
2 changes: 1 addition & 1 deletion pkg/reconciler/events/k8sevent/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func eventsFromChannel(c chan string, wantEvents []string) error {
for {
select {
case event := <-c:
return fmt.Errorf("Unexpected event: %q", event)
return fmt.Errorf("unexpected event: %q", event)
default:
return nil
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/reconciler/pipelinerun/cancel.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ func cancelPipelineTaskRunsForTaskNames(ctx context.Context, logger *zap.Sugared
logger.Infof("cancelling TaskRun %s", taskRunName)

if err := cancelTaskRun(ctx, taskRunName, pr.Namespace, clientSet); err != nil {
errs = append(errs, fmt.Errorf("Failed to patch TaskRun `%s` with cancellation: %w", taskRunName, err).Error())
errs = append(errs, fmt.Errorf("failed to patch TaskRun `%s` with cancellation: %w", taskRunName, err).Error())
continue
}
}
Expand All @@ -148,7 +148,7 @@ func cancelPipelineTaskRunsForTaskNames(ctx context.Context, logger *zap.Sugared
logger.Infof("cancelling CustomRun %s", runName)

if err := cancelCustomRun(ctx, runName, pr.Namespace, clientSet); err != nil {
errs = append(errs, fmt.Errorf("Failed to patch CustomRun `%s` with cancellation: %w", runName, err).Error())
errs = append(errs, fmt.Errorf("failed to patch CustomRun `%s` with cancellation: %w", runName, err).Error())
continue
}
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/reconciler/pipelinerun/pipelinerun.go
Original file line number Diff line number Diff line change
Expand Up @@ -1371,13 +1371,13 @@ func (c *Reconciler) updatePipelineRunStatusFromInformer(ctx context.Context, pr
pipelineRunLabels := getTaskrunLabels(pr, "", false)
taskRuns, err := c.taskRunLister.TaskRuns(pr.Namespace).List(k8slabels.SelectorFromSet(pipelineRunLabels))
if err != nil {
logger.Errorf("could not list TaskRuns %#v", err)
logger.Errorf("Could not list TaskRuns %#v", err)
return err
}

customRuns, err := c.customRunLister.CustomRuns(pr.Namespace).List(k8slabels.SelectorFromSet(pipelineRunLabels))
if err != nil {
logger.Errorf("could not list CustomRuns %#v", err)
logger.Errorf("Could not list CustomRuns %#v", err)
return err
}
return updatePipelineRunStatusFromChildObjects(ctx, logger, pr, taskRuns, customRuns)
Expand Down Expand Up @@ -1525,7 +1525,7 @@ func conditionFromVerificationResult(verificationResult *trustedresources.Verifi
var err error
switch verificationResult.VerificationResultType {
case trustedresources.VerificationError:
err = fmt.Errorf("PipelineRun %s/%s referred resource %s failed signature verification: %w", pr.Namespace, pr.Name, resourceName, verificationResult.Err)
err = fmt.Errorf("pipelineRun %s/%s referred resource %s failed signature verification: %w", pr.Namespace, pr.Name, resourceName, verificationResult.Err)
condition = &apis.Condition{
Type: trustedresources.ConditionTrustedResourcesVerified,
Status: corev1.ConditionFalse,
Expand Down
4 changes: 2 additions & 2 deletions pkg/reconciler/pipelinerun/pipelinerun_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -879,7 +879,7 @@ spec:
permanentError: true,
wantEvents: []string{
"Normal Started",
"Warning Failed PipelineRun foo/pipeline-missing-object-param-keys parameters is missing object keys required by Pipeline foo/a-pipeline-with-object-params's parameters: PipelineRun missing object keys for parameters",
"Warning Failed PipelineRun foo/pipeline-missing-object-param-keys parameters is missing object keys required by Pipeline foo/a-pipeline-with-object-params's parameters: pipelineRun missing object keys for parameters",
},
}, {
name: "invalid-pipeline-array-index-out-of-bound",
Expand Down Expand Up @@ -12264,7 +12264,7 @@ spec:
wantEvents :=
[]string{
"Normal Started",
"Warning Failed PipelineRun foo/pr can't be Run; couldn't resolve all references: Array Result Index 3 for Task pt-with-result Result platforms is out of bound of size 3",
"Warning Failed PipelineRun foo/pr can't be Run; couldn't resolve all references: array Result Index 3 for Task pt-with-result Result platforms is out of bound of size 3",
"Warning InternalError 1 error occurred:",
}
prt := newPipelineRunTest(t, d)
Expand Down
2 changes: 1 addition & 1 deletion pkg/reconciler/pipelinerun/resources/pipelineref.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ type LocalPipelineRefResolver struct {
func (l *LocalPipelineRefResolver) GetPipeline(ctx context.Context, name string) (*v1.Pipeline, *v1.RefSource, *trustedresources.VerificationResult, error) {
// If we are going to resolve this reference locally, we need a namespace scope.
if l.Namespace == "" {
return nil, nil, nil, fmt.Errorf("Must specify namespace to resolve reference to pipeline %s", name)
return nil, nil, nil, fmt.Errorf("must specify namespace to resolve reference to pipeline %s", name)
}

pipeline, err := l.Tektonclient.TektonV1().Pipelines(l.Namespace).Get(ctx, name, metav1.GetOptions{})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ func ValidateTaskRunSpecs(p *v1.PipelineSpec, pr *v1.PipelineRun) error {

for _, taskrunSpec := range pr.Spec.TaskRunSpecs {
if _, ok := pipelineTasks[taskrunSpec.PipelineTaskName]; !ok {
return fmt.Errorf("PipelineRun's taskrunSpecs defined wrong taskName: %q, does not exist in Pipeline", taskrunSpec.PipelineTaskName)
return fmt.Errorf("pipelineRun's taskrunSpecs defined wrong taskName: %q, does not exist in Pipeline", taskrunSpec.PipelineTaskName)
}
}
return nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func validateArrayResultsIndex(allResolvedResultRefs ResolvedResultRefs) error {
for _, r := range allResolvedResultRefs {
if r.Value.Type == v1.ParamTypeArray {
if r.ResultReference.ResultsIndex >= len(r.Value.ArrayVal) {
return fmt.Errorf("Array Result Index %d for Task %s Result %s is out of bound of size %d", r.ResultReference.ResultsIndex, r.ResultReference.PipelineTask, r.ResultReference.Result, len(r.Value.ArrayVal))
return fmt.Errorf("array Result Index %d for Task %s Result %s is out of bound of size %d", r.ResultReference.ResultsIndex, r.ResultReference.PipelineTask, r.ResultReference.Result, len(r.Value.ArrayVal))
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -757,7 +757,7 @@ func TestValidateArrayResultsIndex(t *testing.T) {
},
FromTaskRun: "aTaskRun",
}},
wantErr: "Array Result Index 1 for Task aTask Result aResult is out of bound of size 0",
wantErr: "array Result Index 1 for Task aTask Result aResult is out of bound of size 0",
}, {
name: "In Bounds Array",
refs: ResolvedResultRefs{{
Expand Down Expand Up @@ -787,7 +787,7 @@ func TestValidateArrayResultsIndex(t *testing.T) {
},
FromTaskRun: "aTaskRun",
}},
wantErr: "Array Result Index 3 for Task aTask Result aResult is out of bound of size 3",
wantErr: "array Result Index 3 for Task aTask Result aResult is out of bound of size 3",
}, {
name: "In Bounds and Out of Bounds Array",
refs: ResolvedResultRefs{{
Expand All @@ -813,7 +813,7 @@ func TestValidateArrayResultsIndex(t *testing.T) {
},
FromTaskRun: "aTaskRun",
}},
wantErr: "Array Result Index 3 for Task aTask Result aResult is out of bound of size 3",
wantErr: "array Result Index 3 for Task aTask Result aResult is out of bound of size 3",
}} {
t.Run(tt.name, func(t *testing.T) {
err := validateArrayResultsIndex(tt.refs)
Expand Down
4 changes: 2 additions & 2 deletions pkg/reconciler/pipelinerun/resources/validate_params.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func ValidateRequiredParametersProvided(pipelineParameters *v1.ParamSpecs, pipel

// Return an error with the missing parameters' names, or return nil if there are none.
if len(missingParams) != 0 {
return fmt.Errorf("PipelineRun missing parameters: %s", missingParams)
return fmt.Errorf("pipelineRun missing parameters: %s", missingParams)
}
return nil
}
Expand All @@ -80,7 +80,7 @@ func ValidateRequiredParametersProvided(pipelineParameters *v1.ParamSpecs, pipel
func ValidateObjectParamRequiredKeys(pipelineParameters []v1.ParamSpec, pipelineRunParameters []v1.Param) error {
missings := taskrun.MissingKeysObjectParamNames(pipelineParameters, pipelineRunParameters)
if len(missings) != 0 {
return fmt.Errorf("PipelineRun missing object keys for parameters: %v", missings)
return fmt.Errorf("pipelineRun missing object keys for parameters: %v", missings)
}

return nil
Expand Down
4 changes: 2 additions & 2 deletions pkg/reconciler/pipelinerun/timeout.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func timeoutPipelineTasksForTaskNames(ctx context.Context, logger *zap.SugaredLo
logger.Infof("cancelling TaskRun %s for timeout", taskRunName)

if _, err := clientSet.TektonV1().TaskRuns(pr.Namespace).Patch(ctx, taskRunName, types.JSONPatchType, timeoutTaskRunPatchBytes, metav1.PatchOptions{}, ""); err != nil {
errs = append(errs, fmt.Errorf("Failed to patch TaskRun `%s` with cancellation: %w", taskRunName, err).Error())
errs = append(errs, fmt.Errorf("failed to patch TaskRun `%s` with cancellation: %w", taskRunName, err).Error())
continue
}
}
Expand All @@ -122,7 +122,7 @@ func timeoutPipelineTasksForTaskNames(ctx context.Context, logger *zap.SugaredLo
logger.Infof("cancelling CustomRun %s for timeout", custonRunName)

if err := timeoutCustomRun(ctx, custonRunName, pr.Namespace, clientSet); err != nil {
errs = append(errs, fmt.Errorf("Failed to patch CustomRun `%s` with cancellation: %w", custonRunName, err).Error())
errs = append(errs, fmt.Errorf("failed to patch CustomRun `%s` with cancellation: %w", custonRunName, err).Error())
continue
}
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/reconciler/taskrun/validate_taskrun.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,13 +211,13 @@ func validateTaskSpecRequestResources(taskSpec *v1.TaskSpec) error {
// First validate the limit in step
if limit, ok := step.ComputeResources.Limits[k]; ok {
if (&limit).Cmp(request) == -1 {
return fmt.Errorf("Invalid request resource value: %v must be less or equal to limit %v", request.String(), limit.String())
return fmt.Errorf("invalid request resource value: %v must be less or equal to limit %v", request.String(), limit.String())
}
} else if taskSpec.StepTemplate != nil {
// If step doesn't configure the limit, validate the limit in stepTemplate
if limit, ok := taskSpec.StepTemplate.ComputeResources.Limits[k]; ok {
if (&limit).Cmp(request) == -1 {
return fmt.Errorf("Invalid request resource value: %v must be less or equal to limit %v", request.String(), limit.String())
return fmt.Errorf("invalid request resource value: %v must be less or equal to limit %v", request.String(), limit.String())
}
}
}
Expand Down

0 comments on commit e570f36

Please sign in to comment.