Skip to content

Commit

Permalink
Acc. to scs-0102-v1, os_hash_algo is recommended.
Browse files Browse the repository at this point in the history
So let's not error out, but just display a warning.
Also don't gate using non-recommended names with verbose setting,
but display these warnings as well. Capitalize displayed
suggested name.

Signed-off-by: Kurt Garloff <kurt@garloff.de>
  • Loading branch information
garloff committed Dec 18, 2023
1 parent e983c97 commit 127678e
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions Tests/iaas/image-metadata/image-md-check.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,15 +142,17 @@ def validate_imageMD(imgnm):
return 1
# Now the hard work: Look at properties ....
errors = 0
warnings = 0
# (1) recommended os_* and hw_*
for prop in (*os_props, *arch_props, *hw_props):
if not prop.is_ok(img, imgnm):
errors += 1
constr_name = f"{img.os_distro} {img.os_version}"
# (3) os_hash
if img.hash_algo not in ('sha256', 'sha512'):
print(f'Error: Image "{imgnm}": no valid hash algorithm {img.hash_algo}', file=sys.stderr)
errors += 1
print(f'Warning: Image "{imgnm}": no valid hash algorithm {img.hash_algo}', file=sys.stderr)
# errors += 1
warnings += 1

# (4) image_build_date, image_original_user, image_source (opt image_description)
# (5) maintained_until, provided_until, uuid_validity, update_frequency
Expand Down Expand Up @@ -184,12 +186,15 @@ def validate_imageMD(imgnm):
# (6) tags os:*, managed_by_*
#
# (7) Recommended naming
if verbose and imgnm[:len(constr_name)].casefold() != constr_name.casefold():
print(f'Warning: Image "{imgnm}" does not start with recommended name "{constr_name}"',
if imgnm[:len(constr_name)].casefold() != constr_name.casefold(): # and verbose
# FIXME: There could be a more clever heuristic for displayed recommended names
rec_name = constr_name[0].upper()+constr_name[1:]
print(f'Warning: Image "{imgnm}" does not start with recommended name "{rec_name}"',
file=sys.stderr)
warnings += 1

if not errors and verbose:
print(f'Image "{imgnm}": All good')
print(f'Image "{imgnm}": All good ({warnings} warnings)')
return errors


Expand Down

0 comments on commit 127678e

Please sign in to comment.