From 84a72d40ab5850bf68877f226e9115957699399b Mon Sep 17 00:00:00 2001 From: kobayashi Date: Mon, 28 Sep 2020 00:36:33 -0400 Subject: [PATCH] Modify unnecessarily exported methods to unexported --- .../pipeline/v1alpha1/conversion_error.go | 4 +- .../pipeline/v1alpha1/pipeline_conversion.go | 2 +- pkg/apis/pipeline/v1beta1/task_validation.go | 4 +- pkg/artifacts/artifact_storage_test.go | 12 +-- pkg/artifacts/artifacts_storage.go | 24 +++--- pkg/contexts/contexts.go | 8 +- pkg/contexts/contexts_test.go | 6 +- pkg/git/git.go | 14 ++-- pkg/git/git_test.go | 2 +- pkg/pod/status.go | 34 ++++---- pkg/pod/status_test.go | 12 +-- .../cloudevent/cloud_event_controller.go | 4 +- .../cloudevent/cloud_event_controller_test.go | 4 +- .../events/cloudevent/cloudevent.go | 22 +++--- .../events/cloudevent/cloudevent_test.go | 8 +- .../cloudevent/cloudeventsfakeclient.go | 6 +- pkg/reconciler/events/event.go | 8 +- .../pipelinerun/pipelinerun_test.go | 78 +++++++++---------- .../resources/conditionresolution.go | 6 +- .../resources/pipelinerunresolution.go | 6 +- 20 files changed, 132 insertions(+), 132 deletions(-) diff --git a/pkg/apis/pipeline/v1alpha1/conversion_error.go b/pkg/apis/pipeline/v1alpha1/conversion_error.go index 5c8a01e588e..9df97adc2d0 100644 --- a/pkg/apis/pipeline/v1alpha1/conversion_error.go +++ b/pkg/apis/pipeline/v1alpha1/conversion_error.go @@ -35,5 +35,5 @@ type CannotConvertError = v1beta1.CannotConvertError var _ error = (*CannotConvertError)(nil) -// ConvertErrorf creates a CannotConvertError from the field name and format string. -var ConvertErrorf = v1beta1.ConvertErrorf +// convertErrorf creates a CannotConvertError from the field name and format string. +var convertErrorf = v1beta1.ConvertErrorf diff --git a/pkg/apis/pipeline/v1alpha1/pipeline_conversion.go b/pkg/apis/pipeline/v1alpha1/pipeline_conversion.go index 7d2b482476f..4ce6ec730c8 100644 --- a/pkg/apis/pipeline/v1alpha1/pipeline_conversion.go +++ b/pkg/apis/pipeline/v1alpha1/pipeline_conversion.go @@ -102,7 +102,7 @@ func (sink *PipelineSpec) ConvertFrom(ctx context.Context, source v1beta1.Pipeli } // finally clause was introduced in v1beta1 and not available in v1alpha1 if len(source.Finally) > 0 { - return ConvertErrorf(FinallyFieldName, ConversionErrorFieldNotAvailableMsg) + return convertErrorf(FinallyFieldName, ConversionErrorFieldNotAvailableMsg) } return nil } diff --git a/pkg/apis/pipeline/v1beta1/task_validation.go b/pkg/apis/pipeline/v1beta1/task_validation.go index 434345cf290..c783903f336 100644 --- a/pkg/apis/pipeline/v1beta1/task_validation.go +++ b/pkg/apis/pipeline/v1beta1/task_validation.go @@ -43,7 +43,7 @@ func (ts *TaskSpec) Validate(ctx context.Context) (errs *apis.FieldError) { errs = errs.Also(apis.ErrMissingField("steps")) } errs = errs.Also(ValidateVolumes(ts.Volumes).ViaField("volumes")) - errs = errs.Also(ValidateDeclaredWorkspaces(ts.Workspaces, ts.Steps, ts.StepTemplate).ViaField("workspaces")) + errs = errs.Also(validateDeclaredWorkspaces(ts.Workspaces, ts.Steps, ts.StepTemplate).ViaField("workspaces")) mergedSteps, err := MergeStepsWithStepTemplate(ts.StepTemplate, ts.Steps) if err != nil { errs = errs.Also(&apis.FieldError{ @@ -79,7 +79,7 @@ func (tr TaskResult) Validate(_ context.Context) *apis.FieldError { // a mount path which conflicts with any other declared workspaces, with the explicitly // declared volume mounts, or with the stepTemplate. The names must also be unique. -func ValidateDeclaredWorkspaces(workspaces []WorkspaceDeclaration, steps []Step, stepTemplate *corev1.Container) (errs *apis.FieldError) { +func validateDeclaredWorkspaces(workspaces []WorkspaceDeclaration, steps []Step, stepTemplate *corev1.Container) (errs *apis.FieldError) { mountPaths := sets.NewString() for _, step := range steps { for _, vm := range step.VolumeMounts { diff --git a/pkg/artifacts/artifact_storage_test.go b/pkg/artifacts/artifact_storage_test.go index 04cf5f3c677..74e76f40191 100644 --- a/pkg/artifacts/artifact_storage_test.go +++ b/pkg/artifacts/artifact_storage_test.go @@ -54,7 +54,7 @@ var ( } defaultStorageClass *string customStorageClass = "custom-storage-class" - persistentVolumeClaim = GetPersistentVolumeClaim(config.DefaultPVCSize, defaultStorageClass) + persistentVolumeClaim = getPersistentVolumeClaim(config.DefaultPVCSize, defaultStorageClass) quantityComparer = cmp.Comparer(func(x, y resource.Quantity) bool { return x.Cmp(y) == 0 }) @@ -99,7 +99,7 @@ var ( } ) -func GetPersistentVolumeClaim(size string, storageClassName *string) *corev1.PersistentVolumeClaim { +func getPersistentVolumeClaim(size string, storageClassName *string) *corev1.PersistentVolumeClaim { pvc := &corev1.PersistentVolumeClaim{ ObjectMeta: metav1.ObjectMeta{Name: "pipelineruntest-pvc", Namespace: pipelinerun.Namespace, OwnerReferences: []metav1.OwnerReference{pipelinerun.GetOwnerReference()}}, Spec: corev1.PersistentVolumeClaimSpec{ @@ -156,7 +156,7 @@ func TestNeedsPVC(t *testing.T) { ArtifactBucket: artifactBucket, } ctx := config.ToContext(context.Background(), &configs) - needed := NeedsPVC(ctx) + needed := needsPVC(ctx) if needed != c.pvcNeeded { t.Fatalf("Expected that ConfigMapNeedsPVC would be %t, but was %t", c.pvcNeeded, needed) } @@ -179,7 +179,7 @@ func TestInitializeArtifactStorage(t *testing.T) { storagetype: "pvc", expectedArtifactStorage: &storage.ArtifactPVC{ Name: "pipelineruntest", - PersistentVolumeClaim: GetPersistentVolumeClaim("10Gi", defaultStorageClass), + PersistentVolumeClaim: getPersistentVolumeClaim("10Gi", defaultStorageClass), ShellImage: "busybox", }, }, { @@ -190,7 +190,7 @@ func TestInitializeArtifactStorage(t *testing.T) { storagetype: "pvc", expectedArtifactStorage: &storage.ArtifactPVC{ Name: "pipelineruntest", - PersistentVolumeClaim: GetPersistentVolumeClaim("5Gi", &customStorageClass), + PersistentVolumeClaim: getPersistentVolumeClaim("5Gi", &customStorageClass), ShellImage: "busybox", }, }, { @@ -445,7 +445,7 @@ func TestCleanupArtifactStorage(t *testing.T) { storageConfig: map[string]string{}, }} { t.Run(c.desc, func(t *testing.T) { - fakekubeclient := fakek8s.NewSimpleClientset(GetPVCSpec(pipelinerun, persistentVolumeClaim.Spec.Resources.Requests["storage"], defaultStorageClass)) + fakekubeclient := fakek8s.NewSimpleClientset(getPVCSpec(pipelinerun, persistentVolumeClaim.Spec.Resources.Requests["storage"], defaultStorageClass)) ab, err := config.NewArtifactBucketFromMap(c.storageConfig) if err != nil { t.Fatalf("Error getting an ArtifactBucket from data %s, %s", c.storageConfig, err) diff --git a/pkg/artifacts/artifacts_storage.go b/pkg/artifacts/artifacts_storage.go index 99b676bdb15..3d811b23675 100644 --- a/pkg/artifacts/artifacts_storage.go +++ b/pkg/artifacts/artifacts_storage.go @@ -104,7 +104,7 @@ func InitializeArtifactStorage(ctx context.Context, images pipeline.Images, pr * return &ArtifactStorageNone{}, nil } - if NeedsPVC(ctx) { + if needsPVC(ctx) { pvc, err := createPVC(ctx, pr, c) if err != nil { return nil, err @@ -112,14 +112,14 @@ func InitializeArtifactStorage(ctx context.Context, images pipeline.Images, pr * return &storage.ArtifactPVC{Name: pr.Name, PersistentVolumeClaim: pvc, ShellImage: images.ShellImage}, nil } - return NewArtifactBucketFromConfig(ctx, images), nil + return newArtifactBucketFromConfig(ctx, images), nil } // CleanupArtifactStorage will delete the PipelineRun's artifact storage PVC if it exists. The PVC is created for using // an output workspace or artifacts from one Task to another Task. No other PVCs will be impacted by this cleanup. func CleanupArtifactStorage(ctx context.Context, pr *v1beta1.PipelineRun, c kubernetes.Interface) error { - if NeedsPVC(ctx) { + if needsPVC(ctx) { err := deletePVC(ctx, pr, c) if err != nil { return err @@ -128,9 +128,9 @@ func CleanupArtifactStorage(ctx context.Context, pr *v1beta1.PipelineRun, c kube return nil } -// NeedsPVC checks if the Tekton is is configured to use a bucket for artifact storage, +// needsPVC checks if the Tekton is is configured to use a bucket for artifact storage, // returning true if instead a PVC is needed. -func NeedsPVC(ctx context.Context) bool { +func needsPVC(ctx context.Context) bool { bucketConfig := config.FromContextOrDefaults(ctx).ArtifactBucket if bucketConfig == nil { return true @@ -145,14 +145,14 @@ func NeedsPVC(ctx context.Context) bool { // GetArtifactStorage returns the storage interface to enable // consumer code to get a container step for copy to/from storage func GetArtifactStorage(ctx context.Context, images pipeline.Images, prName string, c kubernetes.Interface) ArtifactStorageInterface { - if NeedsPVC(ctx) { + if needsPVC(ctx) { return &storage.ArtifactPVC{Name: prName, ShellImage: images.ShellImage} } - return NewArtifactBucketFromConfig(ctx, images) + return newArtifactBucketFromConfig(ctx, images) } -// NewArtifactBucketFromConfig creates a Bucket from the supplied ConfigMap -func NewArtifactBucketFromConfig(ctx context.Context, images pipeline.Images) *storage.ArtifactBucket { +// newArtifactBucketFromConfig creates a Bucket from the supplied ConfigMap +func newArtifactBucketFromConfig(ctx context.Context, images pipeline.Images) *storage.ArtifactBucket { c := &storage.ArtifactBucket{ ShellImage: images.ShellImage, GsutilImage: images.GsutilImage, @@ -191,7 +191,7 @@ func createPVC(ctx context.Context, pr *v1beta1.PipelineRun, c kubernetes.Interf pvcStorageClassName = &pvcConfig.StorageClassName } - pvcSpec := GetPVCSpec(pr, pvcSize, pvcStorageClassName) + pvcSpec := getPVCSpec(pr, pvcSize, pvcStorageClassName) pvc, err := c.CoreV1().PersistentVolumeClaims(pr.Namespace).Create(ctx, pvcSpec, metav1.CreateOptions{}) if err != nil { return nil, fmt.Errorf("failed to claim Persistent Volume %q due to error: %w", pr.Name, err) @@ -214,8 +214,8 @@ func deletePVC(ctx context.Context, pr *v1beta1.PipelineRun, c kubernetes.Interf return nil } -// GetPVCSpec returns the PVC to create for a given PipelineRun -func GetPVCSpec(pr *v1beta1.PipelineRun, pvcSize resource.Quantity, storageClassName *string) *corev1.PersistentVolumeClaim { +// getPVCSpec returns the PVC to create for a given PipelineRun +func getPVCSpec(pr *v1beta1.PipelineRun, pvcSize resource.Quantity, storageClassName *string) *corev1.PersistentVolumeClaim { return &corev1.PersistentVolumeClaim{ ObjectMeta: metav1.ObjectMeta{ Namespace: pr.Namespace, diff --git a/pkg/contexts/contexts.go b/pkg/contexts/contexts.go index 63fad40d814..ac8dfd1722d 100644 --- a/pkg/contexts/contexts.go +++ b/pkg/contexts/contexts.go @@ -22,16 +22,16 @@ import "context" // with a context.Context. type hdcnKey struct{} -// WithDefaultConfigurationName notes on the context for nested validation +// withDefaultConfigurationName notes on the context for nested validation // that there is a default configuration name, which affects how an empty // configurationName is validated. -func WithDefaultConfigurationName(ctx context.Context) context.Context { +func withDefaultConfigurationName(ctx context.Context) context.Context { return context.WithValue(ctx, hdcnKey{}, struct{}{}) } -// HasDefaultConfigurationName checks to see whether the given context has +// hasDefaultConfigurationName checks to see whether the given context has // been marked as having a default configurationName. -func HasDefaultConfigurationName(ctx context.Context) bool { +func hasDefaultConfigurationName(ctx context.Context) bool { return ctx.Value(hdcnKey{}) != nil } diff --git a/pkg/contexts/contexts_test.go b/pkg/contexts/contexts_test.go index 243ba6bf372..73b2f1d40a8 100644 --- a/pkg/contexts/contexts_test.go +++ b/pkg/contexts/contexts_test.go @@ -30,13 +30,13 @@ func TestContexts(t *testing.T) { want bool }{{ name: "has default config name", - ctx: WithDefaultConfigurationName(ctx), - check: HasDefaultConfigurationName, + ctx: withDefaultConfigurationName(ctx), + check: hasDefaultConfigurationName, want: true, }, { name: "doesn't have default config name", ctx: ctx, - check: HasDefaultConfigurationName, + check: hasDefaultConfigurationName, want: false, }, { name: "are upgrading via defaulting", diff --git a/pkg/git/git.go b/pkg/git/git.go index 41c39eaad9f..ad721d26077 100644 --- a/pkg/git/git.go +++ b/pkg/git/git.go @@ -162,13 +162,13 @@ func Fetch(logger *zap.SugaredLogger, spec FetchSpec) error { if err != nil { return err } - ref, err := ShowRef(logger, "HEAD", spec.Path) + ref, err := showRef(logger, "HEAD", spec.Path) if err != nil { return err } logger.Infof("Successfully cloned %s @ %s (%s) in path %s", trimmedURL, commit, ref, spec.Path) if spec.Submodules { - if err := SubmoduleFetch(logger, spec); err != nil { + if err := submoduleFetch(logger, spec); err != nil { return err } } @@ -183,7 +183,7 @@ func ShowCommit(logger *zap.SugaredLogger, revision, path string) (string, error return strings.TrimSuffix(output, "\n"), nil } -func ShowRef(logger *zap.SugaredLogger, revision, path string) (string, error) { +func showRef(logger *zap.SugaredLogger, revision, path string) (string, error) { output, err := run(logger, path, "show", "-q", "--pretty=format:%D", revision) if err != nil { return "", err @@ -191,7 +191,7 @@ func ShowRef(logger *zap.SugaredLogger, revision, path string) (string, error) { return strings.TrimSuffix(output, "\n"), nil } -func SubmoduleFetch(logger *zap.SugaredLogger, spec FetchSpec) error { +func submoduleFetch(logger *zap.SugaredLogger, spec FetchSpec) error { if spec.Path != "" { if err := os.Chdir(spec.Path); err != nil { return fmt.Errorf("failed to change directory with path %s; err: %w", spec.Path, err) @@ -270,7 +270,7 @@ func validateGitAuth(logger *zap.SugaredLogger, credsDir, url string) { if _, err := os.Stat(credsDir + "/.ssh"); os.IsNotExist(err) { sshCred = false } - urlSSHFormat := ValidateGitSSHURLFormat(url) + urlSSHFormat := validateGitSSHURLFormat(url) if sshCred && !urlSSHFormat { logger.Warnf("SSH credentials have been provided but the URL(%q) is not a valid SSH URL. This warning can be safely ignored if the URL is for a public repo or you are using basic auth", url) } else if !sshCred && urlSSHFormat { @@ -278,8 +278,8 @@ func validateGitAuth(logger *zap.SugaredLogger, credsDir, url string) { } } -// ValidateGitSSHURLFormat validates the given URL format is SSH or not -func ValidateGitSSHURLFormat(url string) bool { +// validateGitSSHURLFormat validates the given URL format is SSH or not +func validateGitSSHURLFormat(url string) bool { if sshURLRegexFormat.MatchString(url) { return true } diff --git a/pkg/git/git_test.go b/pkg/git/git_test.go index a7bf9182896..9b7ce3c51bd 100644 --- a/pkg/git/git_test.go +++ b/pkg/git/git_test.go @@ -107,7 +107,7 @@ func TestValidateGitSSHURLFormat(t *testing.T) { } for _, tt := range tests { - got := ValidateGitSSHURLFormat(tt.url) + got := validateGitSSHURLFormat(tt.url) if got != tt.want { t.Errorf("Validate URL(%v)'s SSH format got %v, want %v", tt.url, got, tt.want) } diff --git a/pkg/pod/status.go b/pkg/pod/status.go index b27788add6a..4ede66164b2 100644 --- a/pkg/pod/status.go +++ b/pkg/pod/status.go @@ -61,7 +61,7 @@ const ( ReasonPodCreationFailed = "PodCreationFailed" // ReasonPending indicates that the pod is in corev1.Pending, and the reason is not - // ReasonExceededNodeResources or IsPodHitConfigError + // ReasonExceededNodeResources or isPodHitConfigError ReasonPending = "Pending" //timeFormat is RFC3339 with millisecond @@ -100,7 +100,7 @@ func MakeTaskRunStatus(logger *zap.SugaredLogger, tr v1beta1.TaskRun, pod *corev trs := &tr.Status if trs.GetCondition(apis.ConditionSucceeded) == nil || trs.GetCondition(apis.ConditionSucceeded).Status == corev1.ConditionUnknown { // If the taskRunStatus doesn't exist yet, it's because we just started running - MarkStatusRunning(trs, v1beta1.TaskRunReasonRunning.String(), "Not all Steps in the Task have finished executing") + markStatusRunning(trs, v1beta1.TaskRunReasonRunning.String(), "Not all Steps in the Task have finished executing") } sortPodContainerStatuses(pod.Status.ContainerStatuses, pod.Spec.Containers) @@ -271,9 +271,9 @@ func extractStartedAtTimeFromResults(results []v1beta1.PipelineResourceResult) ( func updateCompletedTaskRunStatus(logger *zap.SugaredLogger, trs *v1beta1.TaskRunStatus, pod *corev1.Pod) { if DidTaskRunFail(pod) { msg := getFailureMessage(logger, pod) - MarkStatusFailure(trs, v1beta1.TaskRunReasonFailed.String(), msg) + markStatusFailure(trs, v1beta1.TaskRunReasonFailed.String(), msg) } else { - MarkStatusSuccess(trs) + markStatusSuccess(trs) } // update tr completed time @@ -283,15 +283,15 @@ func updateCompletedTaskRunStatus(logger *zap.SugaredLogger, trs *v1beta1.TaskRu func updateIncompleteTaskRunStatus(trs *v1beta1.TaskRunStatus, pod *corev1.Pod) { switch pod.Status.Phase { case corev1.PodRunning: - MarkStatusRunning(trs, v1beta1.TaskRunReasonRunning.String(), "Not all Steps in the Task have finished executing") + markStatusRunning(trs, v1beta1.TaskRunReasonRunning.String(), "Not all Steps in the Task have finished executing") case corev1.PodPending: switch { case IsPodExceedingNodeResources(pod): - MarkStatusRunning(trs, ReasonExceededNodeResources, "TaskRun Pod exceeded available resources") - case IsPodHitConfigError(pod): - MarkStatusFailure(trs, ReasonCreateContainerConfigError, "Failed to create pod due to config error") + markStatusRunning(trs, ReasonExceededNodeResources, "TaskRun Pod exceeded available resources") + case isPodHitConfigError(pod): + markStatusFailure(trs, ReasonCreateContainerConfigError, "Failed to create pod due to config error") default: - MarkStatusRunning(trs, ReasonPending, getWaitingMessage(pod)) + markStatusRunning(trs, ReasonPending, getWaitingMessage(pod)) } } } @@ -374,8 +374,8 @@ func IsPodExceedingNodeResources(pod *corev1.Pod) bool { return false } -// IsPodHitConfigError returns true if the Pod's status undicates there are config error raised -func IsPodHitConfigError(pod *corev1.Pod) bool { +// isPodHitConfigError returns true if the Pod's status undicates there are config error raised +func isPodHitConfigError(pod *corev1.Pod) bool { for _, containerStatus := range pod.Status.ContainerStatuses { if containerStatus.State.Waiting != nil && containerStatus.State.Waiting.Reason == ReasonCreateContainerConfigError { return true @@ -411,8 +411,8 @@ func getWaitingMessage(pod *corev1.Pod) string { return "Pending" } -// MarkStatusRunning sets taskrun status to running -func MarkStatusRunning(trs *v1beta1.TaskRunStatus, reason, message string) { +// markStatusRunning sets taskrun status to running +func markStatusRunning(trs *v1beta1.TaskRunStatus, reason, message string) { trs.SetCondition(&apis.Condition{ Type: apis.ConditionSucceeded, Status: corev1.ConditionUnknown, @@ -421,8 +421,8 @@ func MarkStatusRunning(trs *v1beta1.TaskRunStatus, reason, message string) { }) } -// MarkStatusFailure sets taskrun status to failure with specified reason -func MarkStatusFailure(trs *v1beta1.TaskRunStatus, reason string, message string) { +// markStatusFailure sets taskrun status to failure with specified reason +func markStatusFailure(trs *v1beta1.TaskRunStatus, reason string, message string) { trs.SetCondition(&apis.Condition{ Type: apis.ConditionSucceeded, Status: corev1.ConditionFalse, @@ -431,8 +431,8 @@ func MarkStatusFailure(trs *v1beta1.TaskRunStatus, reason string, message string }) } -// MarkStatusSuccess sets taskrun status to success -func MarkStatusSuccess(trs *v1beta1.TaskRunStatus) { +// markStatusSuccess sets taskrun status to success +func markStatusSuccess(trs *v1beta1.TaskRunStatus) { trs.SetCondition(&apis.Condition{ Type: apis.ConditionSucceeded, Status: corev1.ConditionTrue, diff --git a/pkg/pod/status_test.go b/pkg/pod/status_test.go index 70b5e0d3b37..e08e169bc38 100644 --- a/pkg/pod/status_test.go +++ b/pkg/pod/status_test.go @@ -1098,7 +1098,7 @@ func TestSidecarsReady(t *testing.T) { func TestMarkStatusRunning(t *testing.T) { trs := v1beta1.TaskRunStatus{} - MarkStatusRunning(&trs, v1beta1.TaskRunReasonRunning.String(), "Not all Steps in the Task have finished executing") + markStatusRunning(&trs, v1beta1.TaskRunReasonRunning.String(), "Not all Steps in the Task have finished executing") expected := &apis.Condition{ Type: apis.ConditionSucceeded, @@ -1114,7 +1114,7 @@ func TestMarkStatusRunning(t *testing.T) { func TestMarkStatusFailure(t *testing.T) { trs := v1beta1.TaskRunStatus{} - MarkStatusFailure(&trs, v1beta1.TaskRunReasonFailed.String(), "failure message") + markStatusFailure(&trs, v1beta1.TaskRunReasonFailed.String(), "failure message") expected := &apis.Condition{ Type: apis.ConditionSucceeded, @@ -1130,7 +1130,7 @@ func TestMarkStatusFailure(t *testing.T) { func TestMarkStatusSuccess(t *testing.T) { trs := v1beta1.TaskRunStatus{} - MarkStatusSuccess(&trs) + markStatusSuccess(&trs) expected := &apis.Condition{ Type: apis.ConditionSucceeded, @@ -1146,19 +1146,19 @@ func TestMarkStatusSuccess(t *testing.T) { func statusRunning() duckv1beta1.Status { var trs v1beta1.TaskRunStatus - MarkStatusRunning(&trs, v1beta1.TaskRunReasonRunning.String(), "Not all Steps in the Task have finished executing") + markStatusRunning(&trs, v1beta1.TaskRunReasonRunning.String(), "Not all Steps in the Task have finished executing") return trs.Status } func statusFailure(reason, message string) duckv1beta1.Status { var trs v1beta1.TaskRunStatus - MarkStatusFailure(&trs, reason, message) + markStatusFailure(&trs, reason, message) return trs.Status } func statusSuccess() duckv1beta1.Status { var trs v1beta1.TaskRunStatus - MarkStatusSuccess(&trs) + markStatusSuccess(&trs) return trs.Status } diff --git a/pkg/reconciler/events/cloudevent/cloud_event_controller.go b/pkg/reconciler/events/cloudevent/cloud_event_controller.go index 6a5dfa7b962..970c097bd23 100644 --- a/pkg/reconciler/events/cloudevent/cloud_event_controller.go +++ b/pkg/reconciler/events/cloudevent/cloud_event_controller.go @@ -76,7 +76,7 @@ func SendCloudEvents(tr *v1beta1.TaskRun, ceclient CEClient, logger *zap.Sugared logger = logger.With(zap.String("taskrun", tr.Name)) // Make the event we would like to send: - event, err := EventForTaskRun(tr) + event, err := eventForTaskRun(tr) if err != nil || event == nil { logger.With(zap.Error(err)).Error("failed to produce a cloudevent from TaskRun.") return err @@ -132,7 +132,7 @@ func SendCloudEventWithRetries(ctx context.Context, object runtime.Object) error if ceClient == nil { return errors.New("No cloud events client found in the context") } - event, err := EventForObjectWithCondition(o) + event, err := eventForObjectWithCondition(o) if err != nil { return err } diff --git a/pkg/reconciler/events/cloudevent/cloud_event_controller_test.go b/pkg/reconciler/events/cloudevent/cloud_event_controller_test.go index 0822a2914d1..ee078d716e1 100644 --- a/pkg/reconciler/events/cloudevent/cloud_event_controller_test.go +++ b/pkg/reconciler/events/cloudevent/cloud_event_controller_test.go @@ -138,7 +138,7 @@ func TestSendCloudEvents(t *testing.T) { successfulBehaviour := FakeClientBehaviour{ SendSuccessfully: true, } - err := SendCloudEvents(tc.taskRun, NewFakeClient(&successfulBehaviour), logger) + err := SendCloudEvents(tc.taskRun, newFakeClient(&successfulBehaviour), logger) if err != nil { t.Fatalf("Unexpected error sending cloud events: %v", err) } @@ -196,7 +196,7 @@ func TestSendCloudEventsErrors(t *testing.T) { unsuccessfulBehaviour := FakeClientBehaviour{ SendSuccessfully: false, } - err := SendCloudEvents(tc.taskRun, NewFakeClient(&unsuccessfulBehaviour), logger) + err := SendCloudEvents(tc.taskRun, newFakeClient(&unsuccessfulBehaviour), logger) if err == nil { t.Fatalf("Unexpected success sending cloud events: %v", err) } diff --git a/pkg/reconciler/events/cloudevent/cloudevent.go b/pkg/reconciler/events/cloudevent/cloudevent.go index 1ae7ac411db..1982dd72720 100644 --- a/pkg/reconciler/events/cloudevent/cloudevent.go +++ b/pkg/reconciler/events/cloudevent/cloudevent.go @@ -77,8 +77,8 @@ type TektonCloudEventData struct { PipelineRun *v1beta1.PipelineRun `json:"pipelineRun,omitempty"` } -// NewTektonCloudEventData returns a new instance of TektonCloudEventData -func NewTektonCloudEventData(runObject objectWithCondition) TektonCloudEventData { +// newTektonCloudEventData returns a new instance of TektonCloudEventData +func newTektonCloudEventData(runObject objectWithCondition) TektonCloudEventData { tektonCloudEventData := TektonCloudEventData{} switch v := runObject.(type) { case *v1beta1.TaskRun: @@ -89,9 +89,9 @@ func NewTektonCloudEventData(runObject objectWithCondition) TektonCloudEventData return tektonCloudEventData } -// EventForObjectWithCondition creates a new event based for a objectWithCondition, +// eventForObjectWithCondition creates a new event based for a objectWithCondition, // or return an error if not possible. -func EventForObjectWithCondition(runObject objectWithCondition) (*cloudevents.Event, error) { +func eventForObjectWithCondition(runObject objectWithCondition) (*cloudevents.Event, error) { event := cloudevents.NewEvent() event.SetID(uuid.New().String()) event.SetSubject(runObject.GetObjectMeta().GetName()) @@ -116,30 +116,30 @@ func EventForObjectWithCondition(runObject objectWithCondition) (*cloudevents.Ev } event.SetType(eventType.String()) - if err := event.SetData(cloudevents.ApplicationJSON, NewTektonCloudEventData(runObject)); err != nil { + if err := event.SetData(cloudevents.ApplicationJSON, newTektonCloudEventData(runObject)); err != nil { return nil, err } return &event, nil } -// EventForTaskRun will create a new event based on a TaskRun, +// eventForTaskRun will create a new event based on a TaskRun, // or return an error if not possible. -func EventForTaskRun(taskRun *v1beta1.TaskRun) (*cloudevents.Event, error) { +func eventForTaskRun(taskRun *v1beta1.TaskRun) (*cloudevents.Event, error) { // Check if the TaskRun is defined if taskRun == nil { return nil, errors.New("Cannot send an event for an empty TaskRun") } - return EventForObjectWithCondition(taskRun) + return eventForObjectWithCondition(taskRun) } -// EventForPipelineRun will create a new event based on a PipelineRun, +// eventForPipelineRun will create a new event based on a PipelineRun, // or return an error if not possible. -func EventForPipelineRun(pipelineRun *v1beta1.PipelineRun) (*cloudevents.Event, error) { +func eventForPipelineRun(pipelineRun *v1beta1.PipelineRun) (*cloudevents.Event, error) { // Check if the TaskRun is defined if pipelineRun == nil { return nil, errors.New("Cannot send an event for an empty PipelineRun") } - return EventForObjectWithCondition(pipelineRun) + return eventForObjectWithCondition(pipelineRun) } func getEventType(runObject objectWithCondition) (*TektonEventType, error) { diff --git a/pkg/reconciler/events/cloudevent/cloudevent_test.go b/pkg/reconciler/events/cloudevent/cloudevent_test.go index f35af6d1742..610285d4efe 100644 --- a/pkg/reconciler/events/cloudevent/cloudevent_test.go +++ b/pkg/reconciler/events/cloudevent/cloudevent_test.go @@ -123,7 +123,7 @@ func TestEventForTaskRun(t *testing.T) { t.Run(c.desc, func(t *testing.T) { names.TestingSeed() - got, err := EventForTaskRun(c.taskRun) + got, err := eventForTaskRun(c.taskRun) if err != nil { t.Fatalf("I did not expect an error but I got %s", err) } else { @@ -134,7 +134,7 @@ func TestEventForTaskRun(t *testing.T) { if d := cmp.Diff(string(c.wantEventType), got.Type()); d != "" { t.Errorf("Wrong Event Type %s", diff.PrintWantGot(d)) } - wantData := NewTektonCloudEventData(c.taskRun) + wantData := newTektonCloudEventData(c.taskRun) gotData := TektonCloudEventData{} if err := got.DataAs(&gotData); err != nil { t.Errorf("Unexpected error from DataAsl; %s", err) @@ -182,7 +182,7 @@ func TestEventForPipelineRun(t *testing.T) { t.Run(c.desc, func(t *testing.T) { names.TestingSeed() - got, err := EventForPipelineRun(c.pipelineRun) + got, err := eventForPipelineRun(c.pipelineRun) if err != nil { t.Fatalf("I did not expect an error but I got %s", err) } else { @@ -193,7 +193,7 @@ func TestEventForPipelineRun(t *testing.T) { if d := cmp.Diff(string(c.wantEventType), got.Type()); d != "" { t.Errorf("Wrong Event Type %s", diff.PrintWantGot(d)) } - wantData := NewTektonCloudEventData(c.pipelineRun) + wantData := newTektonCloudEventData(c.pipelineRun) gotData := TektonCloudEventData{} if err := got.DataAs(&gotData); err != nil { t.Errorf("Unexpected error from DataAsl; %s", err) diff --git a/pkg/reconciler/events/cloudevent/cloudeventsfakeclient.go b/pkg/reconciler/events/cloudevent/cloudeventsfakeclient.go index 252ba72be7e..b9ef53f7163 100644 --- a/pkg/reconciler/events/cloudevent/cloudeventsfakeclient.go +++ b/pkg/reconciler/events/cloudevent/cloudeventsfakeclient.go @@ -39,8 +39,8 @@ type FakeClient struct { Events chan string } -// NewFakeClient is a FakeClient factory, it returns a client for the target -func NewFakeClient(behaviour *FakeClientBehaviour) cloudevents.Client { +// newFakeClient is a FakeClient factory, it returns a client for the target +func newFakeClient(behaviour *FakeClientBehaviour) cloudevents.Client { return FakeClient{ behaviour: behaviour, Events: make(chan string, bufferSize), @@ -74,5 +74,5 @@ func (c FakeClient) StartReceiver(ctx context.Context, fn interface{}) error { // WithClient adds to the context a fake client with the desired behaviour func WithClient(ctx context.Context, behaviour *FakeClientBehaviour) context.Context { - return context.WithValue(ctx, CECKey{}, NewFakeClient(behaviour)) + return context.WithValue(ctx, CECKey{}, newFakeClient(behaviour)) } diff --git a/pkg/reconciler/events/event.go b/pkg/reconciler/events/event.go index 05d7b1f65e7..9c0e4b106eb 100644 --- a/pkg/reconciler/events/event.go +++ b/pkg/reconciler/events/event.go @@ -106,7 +106,7 @@ func EmitError(c record.EventRecorder, err error, object runtime.Object) { } } -// EmitEvent emits an event for object if afterCondition is different from beforeCondition +// emitEvent emits an event for object if afterCondition is different from beforeCondition // // Status "ConditionUnknown": // beforeCondition == nil, emit EventReasonStarted @@ -115,12 +115,12 @@ func EmitError(c record.EventRecorder, err error, object runtime.Object) { // Status "ConditionTrue": emit EventReasonSucceded // Status "ConditionFalse": emit EventReasonFailed // Deprecated: use Emit -func EmitEvent(ctx context.Context, beforeCondition *apis.Condition, afterCondition *apis.Condition, object runtime.Object) { +func emitEvent(ctx context.Context, beforeCondition *apis.Condition, afterCondition *apis.Condition, object runtime.Object) { Emit(ctx, beforeCondition, afterCondition, object) } -// EmitErrorEvent emits a failure associated to an error +// emitErrorEvent emits a failure associated to an error // Deprecated: use EmitError instead -func EmitErrorEvent(c record.EventRecorder, err error, object runtime.Object) { +func emitErrorEvent(c record.EventRecorder, err error, object runtime.Object) { EmitError(c, err, object) } diff --git a/pkg/reconciler/pipelinerun/pipelinerun_test.go b/pkg/reconciler/pipelinerun/pipelinerun_test.go index 5886a1b64dc..df40b77ad78 100644 --- a/pkg/reconciler/pipelinerun/pipelinerun_test.go +++ b/pkg/reconciler/pipelinerun/pipelinerun_test.go @@ -370,7 +370,7 @@ func TestReconcile(t *testing.T) { ClusterTasks: clusterTasks, PipelineResources: rs, } - prt := NewPipelineRunTest(d, t) + prt := newPipelineRunTest(d, t) defer prt.Cancel() wantEvents := []string{ @@ -608,7 +608,7 @@ func TestReconcile_CustomTask(t *testing.T) { PipelineRuns: []*v1beta1.PipelineRun{tc.pr}, ConfigMaps: cms, } - prt := NewPipelineRunTest(d, t) + prt := newPipelineRunTest(d, t) defer prt.Cancel() wantEvents := []string{ @@ -675,7 +675,7 @@ func TestReconcile_PipelineSpecTaskSpec(t *testing.T) { PipelineRuns: prs, Pipelines: ps, } - prt := NewPipelineRunTest(d, t) + prt := newPipelineRunTest(d, t) defer prt.Cancel() wantEvents := []string{ @@ -916,7 +916,7 @@ func TestReconcile_InvalidPipelineRuns(t *testing.T) { Pipelines: ps, Tasks: ts, } - prt := NewPipelineRunTest(d, t) + prt := newPipelineRunTest(d, t) defer prt.Cancel() wantEvents := append(tc.wantEvents, "Warning InternalError 1 error occurred") @@ -1323,7 +1323,7 @@ func TestReconcileOnCompletedPipelineRun(t *testing.T) { Tasks: ts, TaskRuns: trs, } - prt := NewPipelineRunTest(d, t) + prt := newPipelineRunTest(d, t) defer prt.Cancel() wantEvents := []string{ @@ -1407,7 +1407,7 @@ func TestReconcileOnCancelledPipelineRun(t *testing.T) { Tasks: ts, TaskRuns: trs, } - prt := NewPipelineRunTest(d, t) + prt := newPipelineRunTest(d, t) defer prt.Cancel() wantEvents := []string{ @@ -1446,7 +1446,7 @@ func TestReconcileOnPendingPipelineRun(t *testing.T) { Tasks: ts, TaskRuns: trs, } - prt := NewPipelineRunTest(d, t) + prt := newPipelineRunTest(d, t) defer prt.Cancel() wantEvents := []string{} @@ -1484,7 +1484,7 @@ func TestReconcileWithTimeout(t *testing.T) { Pipelines: ps, Tasks: ts, } - prt := NewPipelineRunTest(d, t) + prt := newPipelineRunTest(d, t) defer prt.Cancel() wantEvents := []string{ @@ -1533,7 +1533,7 @@ func TestReconcileWithoutPVC(t *testing.T) { Pipelines: ps, Tasks: ts, } - prt := NewPipelineRunTest(d, t) + prt := newPipelineRunTest(d, t) defer prt.Cancel() reconciledRun, clients := prt.reconcileRun("foo", "test-pipeline-run", []string{}, false) @@ -1648,7 +1648,7 @@ func TestReconcileCancelledPipelineRun(t *testing.T) { Pipelines: ps, Tasks: ts, } - prt := NewPipelineRunTest(d, t) + prt := newPipelineRunTest(d, t) defer prt.Cancel() wantEvents := []string{ @@ -1708,7 +1708,7 @@ func TestReconcilePropagateLabels(t *testing.T) { Pipelines: ps, Tasks: ts, } - prt := NewPipelineRunTest(d, t) + prt := newPipelineRunTest(d, t) defer prt.Cancel() _, clients := prt.reconcileRun("foo", "test-pipeline-run-with-labels", []string{}, false) @@ -1746,7 +1746,7 @@ func TestReconcileWithDifferentServiceAccounts(t *testing.T) { Pipelines: ps, Tasks: ts, } - prt := NewPipelineRunTest(d, t) + prt := newPipelineRunTest(d, t) defer prt.Cancel() _, clients := prt.reconcileRun("foo", "test-pipeline-run-different-service-accs", []string{}, false) @@ -1828,7 +1828,7 @@ func TestReconcileCustomTasksWithDifferentServiceAccounts(t *testing.T) { Pipelines: ps, ConfigMaps: cms, } - prt := NewPipelineRunTest(d, t) + prt := newPipelineRunTest(d, t) defer prt.Cancel() _, clients := prt.reconcileRun("foo", "test-pipeline-run-different-service-accs", []string{}, false) @@ -1922,7 +1922,7 @@ func TestReconcileWithTimeoutAndRetry(t *testing.T) { Tasks: ts, TaskRuns: trs, } - prt := NewPipelineRunTest(d, t) + prt := newPipelineRunTest(d, t) defer prt.Cancel() reconciledRun, _ := prt.reconcileRun("foo", "test-pipeline-retry-run-with-timeout", []string{}, false) @@ -1957,7 +1957,7 @@ func TestReconcilePropagateAnnotations(t *testing.T) { Pipelines: ps, Tasks: ts, } - prt := NewPipelineRunTest(d, t) + prt := newPipelineRunTest(d, t) defer prt.Cancel() _, clients := prt.reconcileRun("foo", "test-pipeline-run-with-annotations", []string{}, false) @@ -2112,7 +2112,7 @@ func TestReconcileAndPropagateCustomPipelineTaskRunSpec(t *testing.T) { Pipelines: ps, Tasks: ts, } - prt := NewPipelineRunTest(d, t) + prt := newPipelineRunTest(d, t) defer prt.Cancel() _, clients := prt.reconcileRun("foo", prName, []string{}, false) @@ -2190,7 +2190,7 @@ func TestReconcileCustomTasksWithTaskRunSpec(t *testing.T) { Pipelines: ps, ConfigMaps: cms, } - prt := NewPipelineRunTest(d, t) + prt := newPipelineRunTest(d, t) defer prt.Cancel() _, clients := prt.reconcileRun("foo", prName, []string{}, false) @@ -2261,7 +2261,7 @@ func TestReconcileWithConditionChecks(t *testing.T) { Tasks: ts, Conditions: conditions, } - prt := NewPipelineRunTest(d, t) + prt := newPipelineRunTest(d, t) defer prt.Cancel() wantEvents := []string{ @@ -2373,7 +2373,7 @@ func TestReconcileWithFailingConditionChecks(t *testing.T) { TaskRuns: trs, Conditions: conditions, } - prt := NewPipelineRunTest(d, t) + prt := newPipelineRunTest(d, t) defer prt.Cancel() wantEvents := []string{ @@ -2479,7 +2479,7 @@ func TestReconcileWithWhenExpressionsWithParameters(t *testing.T) { Pipelines: ps, Tasks: ts, } - prt := NewPipelineRunTest(d, t) + prt := newPipelineRunTest(d, t) defer prt.Cancel() wantEvents := []string{ @@ -2619,7 +2619,7 @@ func TestReconcileWithWhenExpressionsWithTaskResults(t *testing.T) { Tasks: ts, TaskRuns: trs, } - prt := NewPipelineRunTest(d, t) + prt := newPipelineRunTest(d, t) defer prt.Cancel() wantEvents := []string{ @@ -2734,7 +2734,7 @@ func TestReconcileWithAffinityAssistantStatefulSet(t *testing.T) { Pipelines: ps, Tasks: ts, } - prt := NewPipelineRunTest(d, t) + prt := newPipelineRunTest(d, t) defer prt.Cancel() reconciledRun, clients := prt.reconcileRun("foo", pipelineRunName, []string{}, false) @@ -2826,7 +2826,7 @@ func TestReconcileWithVolumeClaimTemplateWorkspace(t *testing.T) { Pipelines: ps, Tasks: ts, } - prt := NewPipelineRunTest(d, t) + prt := newPipelineRunTest(d, t) defer prt.Cancel() reconciledRun, clients := prt.reconcileRun("foo", pipelineRunName, []string{}, false) @@ -2902,7 +2902,7 @@ func TestReconcileWithVolumeClaimTemplateWorkspaceUsingSubPaths(t *testing.T) { Pipelines: ps, Tasks: ts, } - prt := NewPipelineRunTest(d, t) + prt := newPipelineRunTest(d, t) defer prt.Cancel() reconciledRun, clients := prt.reconcileRun("foo", "test-pipeline-run", []string{}, false) @@ -3028,7 +3028,7 @@ func TestReconcileWithTaskResults(t *testing.T) { Tasks: ts, TaskRuns: trs, } - prt := NewPipelineRunTest(d, t) + prt := newPipelineRunTest(d, t) defer prt.Cancel() _, clients := prt.reconcileRun("foo", "test-pipeline-run-different-service-accs", []string{}, false) @@ -3099,7 +3099,7 @@ func TestReconcileWithTaskResultsEmbeddedNoneStarted(t *testing.T) { PipelineRuns: prs, Tasks: ts, } - prt := NewPipelineRunTest(d, t) + prt := newPipelineRunTest(d, t) defer prt.Cancel() reconciledRun, clients := prt.reconcileRun("foo", "test-pipeline-run-different-service-accs", []string{}, false) @@ -3207,7 +3207,7 @@ func TestReconcileWithPipelineResults(t *testing.T) { Tasks: ts, TaskRuns: trs, } - prt := NewPipelineRunTest(d, t) + prt := newPipelineRunTest(d, t) defer prt.Cancel() reconciledRun, _ := prt.reconcileRun("foo", "test-pipeline-run-different-service-accs", []string{}, false) @@ -3464,7 +3464,7 @@ func TestReconcileOutOfSyncPipelineRun(t *testing.T) { Runs: runs, ConfigMaps: cms, } - prt := NewPipelineRunTest(d, t) + prt := newPipelineRunTest(d, t) defer prt.Cancel() reconciledRun, clients := prt.reconcileRun("foo", prOutOfSync.Name, []string{}, false) @@ -3606,7 +3606,7 @@ func TestUpdatePipelineRunStatusFromInformer(t *testing.T) { d := test.Data{ PipelineRuns: []*v1beta1.PipelineRun{pr}, } - prt := NewPipelineRunTest(d, t) + prt := newPipelineRunTest(d, t) defer prt.Cancel() wantEvents := []string{ @@ -4310,7 +4310,7 @@ func TestReconcilePipeline_FinalTasks(t *testing.T) { Tasks: tt.ts, TaskRuns: tt.trs, } - prt := NewPipelineRunTest(d, t) + prt := newPipelineRunTest(d, t) defer prt.Cancel() reconciledRun, clients := prt.reconcileRun("foo", tt.pipelineRunName, []string{}, false) @@ -4461,7 +4461,7 @@ func TestReconcile_CloudEvents(t *testing.T) { Tasks: ts, ConfigMaps: cms, } - prt := NewPipelineRunTest(d, t) + prt := newPipelineRunTest(d, t) defer prt.Cancel() wantEvents := []string{ @@ -4532,7 +4532,7 @@ func TestReconcilePipeline_TaskSpecMetadata(t *testing.T) { PipelineRuns: prs, Pipelines: ps, } - prt := NewPipelineRunTest(d, t) + prt := newPipelineRunTest(d, t) defer prt.Cancel() reconciledRun, clients := prt.reconcileRun("foo", "test-pipeline-run-success", []string{}, false) @@ -4641,7 +4641,7 @@ func TestReconciler_ReconcileKind_PipelineTaskContext(t *testing.T) { Tasks: ts, TaskRuns: trs, } - prt := NewPipelineRunTest(d, t) + prt := newPipelineRunTest(d, t) defer prt.Cancel() _, clients := prt.reconcileRun("foo", pipelineRunName, []string{}, false) @@ -4868,7 +4868,7 @@ func TestReconcileWithTaskResultsInFinalTasks(t *testing.T) { Tasks: ts, TaskRuns: trs, } - prt := NewPipelineRunTest(d, t) + prt := newPipelineRunTest(d, t) defer prt.Cancel() reconciledRun, clients := prt.reconcileRun("foo", "test-pipeline-run-final-task-results", []string{}, false) @@ -4937,9 +4937,9 @@ func TestReconcileWithTaskResultsInFinalTasks(t *testing.T) { } } -// NewPipelineRunTest returns PipelineRunTest with a new PipelineRun controller created with specified state through data +// newPipelineRunTest returns PipelineRunTest with a new PipelineRun controller created with specified state through data // This PipelineRunTest can be reused for multiple PipelineRuns by calling reconcileRun for each pipelineRun -func NewPipelineRunTest(data test.Data, t *testing.T) *PipelineRunTest { +func newPipelineRunTest(data test.Data, t *testing.T) *PipelineRunTest { t.Helper() testAssets, cancel := getPipelineRunController(t, data) return &PipelineRunTest{ @@ -5051,7 +5051,7 @@ func TestReconcile_RemotePipelineRef(t *testing.T) { ConfigMaps: cms, } - prt := NewPipelineRunTest(d, t) + prt := newPipelineRunTest(d, t) defer prt.Cancel() wantEvents := []string{ @@ -5165,7 +5165,7 @@ func TestReconcile_OptionalWorkspacesOmitted(t *testing.T) { }}, } - prt := NewPipelineRunTest(d, t) + prt := newPipelineRunTest(d, t) defer prt.Cancel() reconciledRun, clients := prt.reconcileRun("foo", "test-pipeline-run-success", nil, false) @@ -5345,7 +5345,7 @@ func TestReconcile_DependencyValidationsImmediatelyFailPipelineRun(t *testing.T) }}, } - prt := NewPipelineRunTest(d, t) + prt := newPipelineRunTest(d, t) defer prt.Cancel() run1, _ := prt.reconcileRun("foo", "pipelinerun-param-invalid-result-variable", nil, true) diff --git a/pkg/reconciler/pipelinerun/resources/conditionresolution.go b/pkg/reconciler/pipelinerun/resources/conditionresolution.go index a73cd247c3b..66775ba46bd 100644 --- a/pkg/reconciler/pipelinerun/resources/conditionresolution.go +++ b/pkg/reconciler/pipelinerun/resources/conditionresolution.go @@ -115,7 +115,7 @@ func (rcc *ResolvedConditionCheck) ConditionToTaskSpec() (*v1beta1.TaskSpec, err } convertParamTemplates(&t.Steps[0], rcc.Condition.Spec.Params) - err := ApplyResourceSubstitution(&t.Steps[0], rcc.ResolvedResources, rcc.Condition.Spec.Resources, rcc.images) + err := applyResourceSubstitution(&t.Steps[0], rcc.ResolvedResources, rcc.Condition.Spec.Resources, rcc.images) if err != nil { return nil, fmt.Errorf("failed to replace resource template strings %w", err) @@ -135,9 +135,9 @@ func convertParamTemplates(step *v1beta1.Step, params []v1beta1.ParamSpec) { v1beta1.ApplyStepReplacements(step, replacements, map[string][]string{}) } -// ApplyResourceSubstitution applies the substitution from values in resources which are referenced +// applyResourceSubstitution applies the substitution from values in resources which are referenced // in spec as subitems of the replacementStr. -func ApplyResourceSubstitution(step *v1beta1.Step, resolvedResources map[string]*resourcev1alpha1.PipelineResource, conditionResources []v1beta1.ResourceDeclaration, images pipeline.Images) error { +func applyResourceSubstitution(step *v1beta1.Step, resolvedResources map[string]*resourcev1alpha1.PipelineResource, conditionResources []v1beta1.ResourceDeclaration, images pipeline.Images) error { replacements := make(map[string]string) for _, cr := range conditionResources { if rSpec, ok := resolvedResources[cr.Name]; ok { diff --git a/pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go b/pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go index 3cb080fb588..d8e0393c2c3 100644 --- a/pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go +++ b/pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go @@ -396,7 +396,7 @@ func ResolvePipelineRunTask( spec = task.TaskSpec.TaskSpec } spec.SetDefaults(contexts.WithUpgradeViaDefaulting(ctx)) - rtr, err := ResolvePipelineTaskResources(task, &spec, taskName, kind, providedResources) + rtr, err := resolvePipelineTaskResources(task, &spec, taskName, kind, providedResources) if err != nil { return nil, fmt.Errorf("couldn't match referenced resources with declared resources: %w", err) } @@ -510,9 +510,9 @@ func resolveConditionChecks(pt *v1beta1.PipelineTask, taskRunStatus map[string]* return rccs, nil } -// ResolvePipelineTaskResources matches PipelineResources referenced by pt inputs and outputs with the +// resolvePipelineTaskResources matches PipelineResources referenced by pt inputs and outputs with the // providedResources and returns an instance of ResolvedTaskResources. -func ResolvePipelineTaskResources(pt v1beta1.PipelineTask, ts *v1beta1.TaskSpec, taskName string, kind v1beta1.TaskKind, providedResources map[string]*resourcev1alpha1.PipelineResource) (*resources.ResolvedTaskResources, error) { +func resolvePipelineTaskResources(pt v1beta1.PipelineTask, ts *v1beta1.TaskSpec, taskName string, kind v1beta1.TaskKind, providedResources map[string]*resourcev1alpha1.PipelineResource) (*resources.ResolvedTaskResources, error) { rtr := resources.ResolvedTaskResources{ TaskName: taskName, TaskSpec: ts,