Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Acc. to scs-0102-v1, os_hash_algo is recommended. #410

Merged
merged 1 commit into from
Dec 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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