config: add more validations to task steps

This commit is contained in:
Simone Gotti 2019-05-24 11:57:10 +02:00
parent 7658c44694
commit 42f578a0b5
1 changed files with 26 additions and 0 deletions

View File

@ -776,6 +776,32 @@ func checkConfig(config *Config) error {
}
}
for _, run := range config.Runs {
for _, task := range run.Tasks {
for i, s := range task.Steps {
switch step := s.(type) {
// TODO(sgotti) we could use the run step command as step name but when the
// command is very long or multi line it doesn't makes sense and will
// probably be quite unuseful/confusing from an UI point of view
case *RunStep:
if step.Command == "" {
return errors.Errorf("no command defined for step %d (run) in task %q", i, task.Name)
}
case *SaveCacheStep:
if step.Key == "" {
return errors.Errorf("no key defined for step %d (save_cache) in task %q", i, task.Name)
}
case *RestoreCacheStep:
if len(step.Keys) == 0 {
return errors.Errorf("no keys defined for step %d (restore_cache) in task %q", i, task.Name)
}
}
}
}
}
// Set defaults
for _, registryAuth := range config.DockerRegistriesAuth {
if registryAuth.Type == "" {