Skip to content

Commit

Permalink
Add spec version validation
Browse files Browse the repository at this point in the history
Signed-off-by: Evan Lezar <[email protected]>
  • Loading branch information
elezar committed Nov 28, 2022
1 parent 893254c commit 8729204
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pkg/cdi/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,15 @@ func (s *Spec) validate() (map[string]*Device, error) {
if err := validateVersion(s.Version); err != nil {
return nil, err
}

minVersion, err := s.MinimumRequiredVersion()
if err != nil {
return nil, errors.Errorf("could not determine minumum required version: %v", err)
}
if semver.Compare("v"+s.Version, "v"+minVersion) < 0 {
return nil, errors.Errorf("the spec version must be at least v%v", minVersion)
}

if err := ValidateVendorName(s.vendor); err != nil {
return nil, err
}
Expand Down

0 comments on commit 8729204

Please sign in to comment.