Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor input resource volume handling to remove a type switch state… #1139

Merged
merged 1 commit into from
Jul 31, 2019

Conversation

dlorenc
Copy link
Contributor

@dlorenc dlorenc commented Jul 31, 2019

…ment.

Changes

This change refactors the way input resources attach volumes to their steps.
Previously, there was a special-cased switch statement for Storage type resources.
This made the logic for resources hard to follow, and spread across the codebase. This
change refactors that by moving it up into the general Resource interface.

This is another follow-on to #1135

Submitter Checklist

These are the criteria that every PR should meet, please check them off as you
review them:

See the contribution guide for more details.

@tekton-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dlorenc

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@googlebot googlebot added the cla: yes Trying to make the CLA bot happy with ppl from different companies work on one commit label Jul 31, 2019
@tekton-robot tekton-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jul 31, 2019
@tekton-robot
Copy link
Collaborator

The following is the coverage report on pkg/.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/pipeline/v1alpha1/build_gcs_resource.go 81.4% 79.5% -1.8
pkg/apis/pipeline/v1alpha1/cluster_resource.go 73.7% 71.8% -1.9
pkg/apis/pipeline/v1alpha1/gcs_resource.go 85.7% 83.3% -2.4
pkg/apis/pipeline/v1alpha1/git_resource.go 70.0% 66.7% -3.3
pkg/apis/pipeline/v1alpha1/pull_request_resource.go 77.3% 73.9% -3.4
pkg/reconciler/v1alpha1/taskrun/resources/input_resources.go 90.0% 74.3% -15.7

…ment.

This change refactors the way input resources attach volumes to their steps.
Previously, there was a special-cased switch statement for Storage type resources.
This made the logic for resources hard to follow, and spread across the codebase. This
change refactors that by moving it up into the general Resource interface.

This is another follow-on to tektoncd#1135
@tekton-robot
Copy link
Collaborator

The following is the coverage report on pkg/.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/pipeline/v1alpha1/build_gcs_resource.go 81.4% 79.5% -1.8
pkg/apis/pipeline/v1alpha1/cluster_resource.go 73.7% 71.8% -1.9
pkg/apis/pipeline/v1alpha1/gcs_resource.go 85.7% 83.3% -2.4
pkg/apis/pipeline/v1alpha1/git_resource.go 70.0% 66.7% -3.3
pkg/apis/pipeline/v1alpha1/pull_request_resource.go 77.3% 73.9% -3.4
pkg/reconciler/v1alpha1/taskrun/resources/input_resources.go 90.0% 91.7% 1.7

@@ -177,3 +177,7 @@ func getArtifactType(val string) (GCSArtifactType, error) {
func (s *BuildGCSResource) GetUploadVolumeSpec(spec *TaskSpec) ([]corev1.Volume, error) {
return getStorageUploadVolumeSpec(s, spec)
}

func (s *BuildGCSResource) GetDownloadVolumeSpec(spec *TaskSpec) ([]corev1.Volume, error) {
return getStorageUploadVolumeSpec(s, spec)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

v minor but would renaming to getStorageTransferVolumeSpec or maybe even just getStorageVolumeSpec or similar make sense given this is now also being used for the download volume?

Copy link
Member

@afrittoli afrittoli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this!
Since this is an extension of the API it shouldn't have any impact on any of the known consumers.

return nil, xerrors.Errorf("task %q invalid resource download spec: %q; error %w", taskName, boundResource.ResourceRef.Name, err)
}
}
resourceContainers, err = resource.GetDownloadContainerSpec()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, I'm not sure why this was part of the addStorageFetchStep to begin with.

@@ -113,25 +112,13 @@ func AddInputResource(
taskSpec.Steps = append(copyStepsFromPrevTasks, taskSpec.Steps...)
taskSpec.Volumes = append(taskSpec.Volumes, as.GetSecretsVolumes()...)
} else {
switch resource.GetType() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So happy to see this switch go away :)

@afrittoli
Copy link
Member

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Jul 31, 2019
@tekton-robot tekton-robot merged commit 520e46a into tektoncd:master Jul 31, 2019
@dlorenc dlorenc deleted the refinputs branch August 15, 2019 19:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cla: yes Trying to make the CLA bot happy with ppl from different companies work on one commit lgtm Indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants