Skip to content

Commit

Permalink
disallow uses: with a nested pipeline
Browse files Browse the repository at this point in the history
Signed-off-by: Jason Hall <jason@chainguard.dev>
  • Loading branch information
imjasonh committed Jan 22, 2025
1 parent 6613c1b commit 58b175e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -1526,6 +1526,10 @@ func validatePipelines(ps []Pipeline) error {
return fmt.Errorf("pipeline cannot contain both uses %q and runs", p.Uses)
}

if p.Uses != "" && len(p.Pipeline) > 0 {
return fmt.Errorf("pipeline cannot contain both uses %q and a pipeline", p.Uses)
}

if len(p.With) > 0 && p.Runs != "" {
return fmt.Errorf("pipeline cannot contain both with and runs")
}
Expand Down
8 changes: 8 additions & 0 deletions pkg/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,14 @@ func TestValidatePipelines(t *testing.T) {
},
wantErr: true,
},

{
name: "invalid pipeline with both uses and pipeline",
p: []Pipeline{
{Uses: "deploy", Pipeline: []Pipeline{{Runs: "somescript.sh"}}},
},
wantErr: true,
},
}

for _, tt := range tests {
Expand Down

0 comments on commit 58b175e

Please sign in to comment.