util: Show choices for volid if all are too long
When we fail to generate a volume ID that fits in 32 characters, the error message should include the options that were considered. It could show that there might be a substitution that could fix the problem. Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
parent
63327e7d88
commit
2bc719a33a
2 changed files with 26 additions and 1 deletions
|
|
@ -366,6 +366,7 @@ def get_volid(compose, arch, variant=None, escape_spaces=False, disc_type=False)
|
|||
else:
|
||||
all_products = products
|
||||
|
||||
tried = set()
|
||||
for i in all_products:
|
||||
if not variant_uid and "%(variant)s" in i:
|
||||
continue
|
||||
|
|
@ -384,9 +385,11 @@ def get_volid(compose, arch, variant=None, escape_spaces=False, disc_type=False)
|
|||
volid = _apply_substitutions(compose, volid)
|
||||
if len(volid) <= 32:
|
||||
break
|
||||
tried.add(volid)
|
||||
|
||||
if volid and len(volid) > 32:
|
||||
raise ValueError("Could not create volume ID <= 32 characters")
|
||||
raise ValueError("Could not create volume ID longer than 32 bytes, options are %r",
|
||||
sorted(tried, key=len))
|
||||
|
||||
if volid and escape_spaces:
|
||||
volid = volid.replace(" ", r"\x20")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue