Skip to content

Commit

Permalink
Allow unused resource in Pipelines 🎐
Browse files Browse the repository at this point in the history
We need to make sure the required resources are declared, but we
shouldn't error out in case of extras. A resource could be used only
in variable substitution (e.g. an image for the tag).

Signed-off-by: Vincent Demeester <[email protected]>
  • Loading branch information
vdemeester authored and tekton-robot committed Dec 5, 2019
1 parent fc1658c commit 9389e37
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 12 deletions.
6 changes: 3 additions & 3 deletions pkg/apis/pipeline/v1alpha1/pipeline_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ func validateDeclaredResources(ps *PipelineSpec) error {
for _, resource := range ps.Resources {
provided = append(provided, resource.Name)
}
err := list.IsSame(required, provided)
if err != nil {
return xerrors.Errorf("Pipeline declared resources didn't match usage in Tasks: %w", err)
missing := list.DiffLeft(required, provided)
if len(missing) > 0 {
return xerrors.Errorf("Pipeline declared resources didn't match usage in Tasks: Didn't provide required values: %s", missing)
}
return nil
}
Expand Down
9 changes: 0 additions & 9 deletions pkg/apis/pipeline/v1alpha1/pipeline_validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,15 +194,6 @@ func TestPipelineSpec_Validate(t *testing.T) {
tb.PipelineTaskInputResource("the-resource", "great-resource", tb.From("bar"))),
)),
failureExpected: true,
}, {
name: "unused resources declared",
p: tb.Pipeline("pipeline", "namespace", tb.PipelineSpec(
tb.PipelineDeclaredResource("great-resource", v1alpha1.PipelineResourceTypeGit),
tb.PipelineDeclaredResource("extra-resource", v1alpha1.PipelineResourceTypeImage),
tb.PipelineTask("foo", "foo-task",
tb.PipelineTaskInputResource("the-resource", "great-resource")),
)),
failureExpected: true,
}, {
name: "output resources missing from declaration",
p: tb.Pipeline("pipeline", "namespace", tb.PipelineSpec(
Expand Down

0 comments on commit 9389e37

Please sign in to comment.