Skip to content

Commit

Permalink
Onpy copy output resource to PVC for storage/git output
Browse files Browse the repository at this point in the history
At the moment the output_resource module unconditionally adds a
copy step for every output resource in the taskrun.
However not every output resource will generate content to be
copied. Limit the copy to Storage and Git outoputs for now.

This is meant as a hotfix for bug #401 until an implementation
of the image output resource is available via #216. Until
image resource output is implemented, any consumer won't
have guarantee that the image has been actually built and pushed,
and won't know the hash of the created image.
  • Loading branch information
afrittoli committed Jan 21, 2019
1 parent 41d513b commit 7412699
Showing 1 changed file with 28 additions and 21 deletions.
49 changes: 28 additions & 21 deletions pkg/reconciler/v1alpha1/taskrun/resources/output_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,27 +105,34 @@ func AddOutputResources(
}
}

// copy to pvc if pvc is present
if pipelineRunpvcName != "" {
var newSteps []corev1.Container
for _, dPath := range boundResource.Paths {
newSteps = append(newSteps, []corev1.Container{{
Name: fmt.Sprintf("source-mkdir-%s", resource.GetName()),
Image: *bashNoopImage,
Args: []string{
"-args", strings.Join([]string{"mkdir", "-p", dPath}, " "),
},
VolumeMounts: []corev1.VolumeMount{getPvcMount(pipelineRunpvcName)},
}, {
Name: fmt.Sprintf("source-copy-%s", resource.GetName()),
Image: *bashNoopImage,
Args: []string{
"-args", strings.Join([]string{"cp", "-r", fmt.Sprintf("%s/.", sourcePath), dPath}, " "),
},
VolumeMounts: []corev1.VolumeMount{getPvcMount(pipelineRunpvcName)},
}}...)
}
b.Spec.Steps = append(b.Spec.Steps, newSteps...)
// Workaround for issue #401. Unless all resource types are implemented as
// outputs, or until we have metadata on the resource that declares whether
// the output should be copied to the PVC, only copy git and storage output
// resources.
if (resource.Spec.Type == v1alpha1.PipelineResourceTypeStorage ||
resource.Spec.Type == v1alpha1.PipelineResourceTypeGit) {
// copy to pvc if pvc is present
if pipelineRunpvcName != "" {
var newSteps []corev1.Container
for _, dPath := range boundResource.Paths {
newSteps = append(newSteps, []corev1.Container{{
Name: fmt.Sprintf("source-mkdir-%s", resource.GetName()),
Image: *bashNoopImage,
Args: []string{
"-args", strings.Join([]string{"mkdir", "-p", dPath}, " "),
},
VolumeMounts: []corev1.VolumeMount{getPvcMount(pipelineRunpvcName)},
}, {
Name: fmt.Sprintf("source-copy-%s", resource.GetName()),
Image: *bashNoopImage,
Args: []string{
"-args", strings.Join([]string{"cp", "-r", fmt.Sprintf("%s/.", sourcePath), dPath}, " "),
},
VolumeMounts: []corev1.VolumeMount{getPvcMount(pipelineRunpvcName)},
}}...)
}
b.Spec.Steps = append(b.Spec.Steps, newSteps...)
}
}
}

Expand Down

0 comments on commit 7412699

Please sign in to comment.