fedora-modularity / libmodulemd

C Library for manipulating module metadata files
MIT License
31 stars 52 forks source link

Floaty values need to be converted to strings #586

Closed m10k closed 2 years ago

m10k commented 2 years ago

Hello,

when parsing YAML files generated by libmodulemd, some parsers (yq for example) will mangle floating point values, stripping trailing zeroes. This problem seems to affect mostly stream names when they are not on the right-hand side of a colon, as shown in the two snippets below.

For example, in the following snippet, the profile for ant:1.10 is mangled to ant:1.1.

$ cat <<EOF | yq '.' --yaml-output
---
document: modulemd-defaults
version: 1
data:
  module: ant
  stream: "1.10"
  profiles:
    1.10: [common]
...
EOF
document: modulemd-defaults
version: 1
data:
  module: ant
  stream: '1.10'
  profiles:
    '1.1':
      - common

And another example where perl:5.30 becomes perl:5.3 (I minimized this one to reduce noise):

$ cat <<EOF | yq '.' --yaml-output
data:
  dependencies:
  - buildrequires:
      perl: [5.30]
      perl-DBI: [1.641]
      platform: [el8]
...
EOF
data:
  dependencies:
    - buildrequires:
        perl:
          - 5.3
        perl-DBI:
          - 1.641
        platform:
          - el8

I assume that this behavior is not intended, since #499 addressed part of this problem quite a while back. I will attempt to fix this issue and create a pull request. Is that okay?

m10k commented 2 years ago

I have created pull request #587

ppisar commented 2 years ago

Thanks. The pull request was merged.