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

Anchor syntax incorrectly formatted #43

Open
xnox opened this issue Apr 5, 2024 · 6 comments
Open

Anchor syntax incorrectly formatted #43

xnox opened this issue Apr 5, 2024 · 6 comments

Comments

@xnox
Copy link

xnox commented Apr 5, 2024

yaml files with anchors are not correctly formatted.

@luhring
Copy link
Member

luhring commented Apr 5, 2024

@xnox thanks! any chance you could add an example? Like steps to reproduce and how that differs from what we want it to look like?

@shyim
Copy link

shyim commented Apr 25, 2024

Running yam on following YAML

public: &public_bucket
    type: "amazon-s3"
    url: "%env(CDN_URL)%"
    visibility: "public"
    config:
        bucket: "%env(AWS_PUBLIC_FILESYSTEM_BUCKET)%"
        region: "%env(AWS_REGION)%"
        endpoint: "%env(AWS_ENDPOINT_URL)%"
        use_path_style_endpoint: true

theme: *public_bucket
asset: *public_bucket

generates invalid yaml to:

public:
  type: "amazon-s3"
  url: "%env(CDN_URL)%"
  visibility: "public"
  config:
    bucket: "%env(AWS_PUBLIC_FILESYSTEM_BUCKET)%"
    region: "%env(AWS_REGION)%"
    endpoint: "%env(AWS_ENDPOINT_URL)%"
    use_path_style_endpoint: true
theme:
*public_bucket
asset:
*public_bucket

@luhring
Copy link
Member

luhring commented Apr 27, 2024

Thanks @shyim, that's helpful. 🙏

This is most likely a bug in the underlying YAML library, gopkg.in/yaml.v3. My medium-term plan is to swap that out with a better YAML library.

Any ideas for shorter-term fixes are welcome, too.

@xnox
Copy link
Author

xnox commented Apr 29, 2024

Thanks @shyim, that's helpful. 🙏

This is most likely a bug in the underlying YAML library, gopkg.in/yaml.v3. My medium-term plan is to swap that out with a better YAML library.

Any ideas for shorter-term fixes are welcome, too.

it's difference of parsing expanded yaml versus unexpanded. Note that because it is references, one has to take special care when parsing them "literary" or not. It does have support for anchor types, and how to print them. I haven't looked at yam code if it checks for anchors or not.

None theless, I think @stormqueen1990 mentioned one of the better maintained forks of yam.v3..... was it a hashicorp fork? or something else?

@stormqueen1990
Copy link

None theless, I think @stormqueen1990 mentioned one of the better maintained forks of yam.v3..... was it a hashicorp fork? or something else?

The one I know about is https://github.com/kubernetes-sigs/yaml, though I'm unsure if it would fix the issue at hand 🤔

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

4 participants