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

Please supported mixed mode values #73

Open
xnox opened this issue Oct 6, 2024 · 2 comments
Open

Please supported mixed mode values #73

xnox opened this issue Oct 6, 2024 · 2 comments

Comments

@xnox
Copy link

xnox commented Oct 6, 2024

If one specifies that something should be a string, please encode it in the most natural and deterministic way.

Example for something desired to be formatted as a list of strings please ensure that all form of canonical integer and floating point numbers are encoded as strings.

https://yaml.org/spec/1.2.2/#24-tags

Lists

canonical: 12345
decimal: +12345
octal: 0o14
hexadecimal: 0xC
canonical: 1.23015e+3
exponential: 12.3015e+02
fixed: 1230.15
negative infinity: -.inf
not a number: .nan

As valid representations of numbers, which upon parsing will not be strings. And thus need to be quoted to be strings.

For the purpose of melange, we can encounter something like "1.23015e+3" as a string value represetting package version or text git tag. But most commonly it is software with single major or single minor version only that can get miss-parsed.

@luhring
Copy link
Collaborator

luhring commented Nov 6, 2024

I'm not sure I'm following what this issue is asking for yet... Are you saying that yam is mishandling YAML tags then they're specified? Are you saying that yam should define its own default behavior for when no tag is present in the input?

An example input and expected output would go a long way here! Thanks!

@xnox
Copy link
Author

xnox commented Nov 7, 2024

@luhring

When doing yam on glibc.yaml I would like it to convert

package:
  name: glibc
  version: 2.40
  epoch: 3
  description: "the GNU C library"
  copyright:
    - license: LGPL-2.1-or-later
  resources:
    cpu: 16
    memory: 16Gi

to

package:
  name: glibc
  version: "2.40"
  epoch: 3
  description: "the GNU C library"
  copyright:
    - license: LGPL-2.1-or-later
  resources:
    cpu: 16
    memory: 16Gi

As version is a string, epoch is an integer, and cpu is an integer, and memory is unambiguous string.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants