osbuild2: LVM2Metadata: only validate CreationTime if not empty

It is ok to not pass the creation time to osbuild, i.e. it can be
empty. If so, don't validate it.

Co-Authored-By: Achilleas Koutsou <achilleas@koutsou.net>
This commit is contained in:
Christian Kellner 2022-02-11 11:53:48 +00:00 committed by Tom Gundersen
parent 2314ca37d7
commit 3c6e34aeb3

View file

@ -27,8 +27,10 @@ func (o LVM2MetadataStageOptions) validate() error {
return fmt.Errorf("volume group name %q doesn't conform to schema (%s)", o.VGName, nameRegex.String())
}
if _, err := strconv.ParseUint(o.CreationTime, 10, 64); err != nil {
return fmt.Errorf("invalid volume creation time: %s", o.CreationTime)
if o.CreationTime != "" {
if _, err := strconv.ParseUint(o.CreationTime, 10, 64); err != nil {
return fmt.Errorf("invalid volume creation time: %s", o.CreationTime)
}
}
return nil
}