Skip to content

Commit

Permalink
adjust validate local test and verify local templates are included in…
Browse files Browse the repository at this point in the history
… pipeline
  • Loading branch information
ecrupper committed Oct 9, 2023
1 parent be6d1a3 commit 1eaa3b6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
16 changes: 16 additions & 0 deletions action/pipeline/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,22 @@ func (c *Config) ValidateLocal(client compiler.Engine) error {
return err
}

// check to see if locally provided templates were included in compilation
for _, tmpl := range c.TemplateFiles {
parts := strings.Split(tmpl, ":")
included := false

for _, pTmpl := range p.Templates {
if strings.EqualFold(parts[0], pTmpl.Name) {
included = true
}
}

if !included {
return fmt.Errorf("local template with name %s not included in pipeline templates", parts[0])
}
}

// output the message in stderr format
//
// https://pkg.go.dev/github.com/go-vela/cli/internal/output?tab=doc#Stderr
Expand Down
3 changes: 1 addition & 2 deletions action/pipeline/validate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,7 @@ func TestPipeline_Config_ValidateLocal(t *testing.T) {
},
},
{
name: "pipeline with multiple template (local overrides) template mismatch",
failure: true,
name: "pipeline with multiple template (local overrides) only one template specified",
config: &Config{
Action: "validate",
File: "default_multi_template.yml",
Expand Down

0 comments on commit 1eaa3b6

Please sign in to comment.