SUSE-Enceladus / keg

Kiwi Entwicklungs-Gerät (tool to produce kiwi image descriptions)
GNU General Public License v3.0
8 stars 6 forks source link

keg list-recipes not working #91

Closed t-ru closed 2 years ago

t-ru commented 2 years ago

Hello,

there is a bug in keg "list list-recipes"

image.yaml

image:
  name: sle-15-3.vmware.sap-as
  displayname: sle 15.3 vmware sap-as
  specification: SUSE Linux Enterprise Server Image / SUSE Linux Enterprise Server for SAP Applications Image
  author: xxx
  contact: xxx
  schemaversion: "7.3"
  version: 2022.03

"keg -r /home/admin/os-images/ --list-recipes" results in:

Source                         Name                           Version  Description
Traceback (most recent call last):
  File "/usr/local/bin/keg", line 33, in <module>
    sys.exit(load_entry_point('kiwi-keg==1.1.0', 'console_scripts', 'keg')())
  File "/usr/local/lib/python3.8/site-packages/kiwi_keg-1.1.0-py3.8.egg/kiwi_keg/keg.py", line 132, in main
    print('{:30s} {:30s} {:8s} {}'.format(image, spec['name'], spec['ver'], spec['desc']))
ValueError: Unknown format code 's' for object of type 'float'

Change version to 2022.03.0 ... no error, okay. Change version to 2022.03.build-01 ... no error, okay.

Please change so that the version does not have to consist of 3 parts.

used keg version: 1.1.0 (cloned from github master)

Best regards Thomas

jgleissner commented 2 years ago

This exception isn't really due to enforcing mayor.minor.release but mayor.minor gets dynamically typed to float. I'll cast it to string to fix it. However, kiwi documentation states that version must consist of three parts (https://documentation.suse.com/kiwi/9/html/kiwi/image-description.html#image-description-elements, section 8.1.4.1). Said that, kiwi doesn't reject a version string consisting of two parts only, but I don't know whether there could be any side effects.

jgleissner commented 2 years ago

Actually, casting isn't necessary and wouldn't work properly for a version number like 2022.10 (the trailing 0 would be lost). Simply use version: "2022.03" in your image definition.

t-ru commented 2 years ago

version: 2022.10

results in:

Source                         Name                           Version  Description
Traceback (most recent call last):
  File "/usr/local/bin/keg", line 33, in <module>
    sys.exit(load_entry_point('kiwi-keg==1.1.0', 'console_scripts', 'keg')())
  File "/usr/local/lib/python3.8/site-packages/kiwi_keg-1.1.0-py3.8.egg/kiwi_keg/keg.py", line 132, in main
    print('{:30s} {:30s} {:8s} {}'.format(image, spec['name'], spec['ver'], spec['desc']))
ValueError: Unknown format code 's' for object of type 'float'

version: "2022.10" works.

However, kiwi documentation states that version must consist of three parts (https://documentation.suse.com/kiwi/9/html/kiwi/image-description.html#image-description-elements, section 8.1.4.1). Said that, kiwi doesn't reject a version string consisting of two parts only, but I don't know whether there could be any side effects.

Is keg a tool for SUSE internal use only? Yes or no. If no, suggestions from the community should be taken into account instead of referring to documentation and saying "works as designed". The specification that the version must have 3 digits may sometimes fit. But it does not always fit. The specifications are not perfect. Specifications are living.

Source                         Name                           Version  Description
Traceback (most recent call last):
  File "/usr/local/bin/keg", line 33, in <module>
    sys.exit(load_entry_point('kiwi-keg==1.1.0', 'console_scripts', 'keg')())
  File "/usr/local/lib/python3.8/site-packages/kiwi_keg-1.1.0-py3.8.egg/kiwi_keg/keg.py", line 132, in main
    print('{:30s} {:30s} {:8s} {}'.format(image, spec['name'], spec['ver'], spec['desc']))
ValueError: Unknown format code 's' for object of type 'float'

This Error message says: There is an error. But it says not in wich image definition. please implement an error message with which you can locate the error location in yaml

jgleissner commented 2 years ago

keg is a public project, so everybody's welcome to use it and participate. I quoted the kiwi documentation as a heads-up, to point out that using a format other than x.y.z isn't really supported by kiwi, so using a different scheme would be an use-at-own-risk situation. It may work fine, I honestly don't know.

The error message isn't great. The list functionality needs a bit of an overhaul anyway, since the output isn't all that nice. I'll look into better error handling at that opportunity. However, it doesn't change the fact that if you use a string in a YAML file that the YAML parser could interpret as something else (like 2022.03 as float), you'll have to use quotes.