api: add error message for package without name RHEL-16006
This commit is contained in:
parent
80f49a526c
commit
99e84abc66
2 changed files with 65 additions and 0 deletions
|
|
@ -101,6 +101,18 @@ func (b *Blueprint) Initialize() error {
|
|||
return fmt.Errorf("Error hashing passwords: %s", err.Error())
|
||||
}
|
||||
|
||||
for i, p := range b.Packages {
|
||||
if len(p.Name) == 0 {
|
||||
var errMsg string
|
||||
if len(p.Version) == 0 {
|
||||
errMsg = fmt.Sprintf("Entry #%d has neither version nor name.", i+1)
|
||||
} else {
|
||||
errMsg = fmt.Sprintf("Entry #%d has version '%v' but no name.", i+1, p.Version)
|
||||
}
|
||||
return fmt.Errorf("All package entries need to contain the name of the package. %s", errMsg)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue