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

Support for custom YAML tags #76

Closed
akaRem opened this issue Mar 25, 2018 · 14 comments
Closed

Support for custom YAML tags #76

akaRem opened this issue Mar 25, 2018 · 14 comments

Comments

@akaRem
Copy link

akaRem commented Mar 25, 2018

Some utilities extend YAML syntax with custom tags. For example JJB introduces "include" tags, http://jenkins-job-builder.readthedocs.io/en/latest/definition.html?highlight=!include-raw#module-jenkins_jobs.local_yaml

YAML linter fails on provided examples.
Eg here

- job:
  name: test-job-1
  builders:
    !include: include001.yaml.inc

it says unknown tag <!include:> at: '4,5'.

According to documentation, currently there is no way

  • to ignore some warnings, or
  • to extend YAML schema with additional tags.

But custom tags are language feature, see http://www.yaml.org/spec/1.2/spec.html#id2761292 , Example 2.24. Global Tags. This document causes errors too:

%TAG ! tag:clarkevans.com,2002:
--- !shape
  # Use the ! handle for presenting
  # tag:clarkevans.com,2002:circle
- !circle
  center: &ORIGIN {x: 73, y: 129}
  radius: 7
- !line
  start: *ORIGIN
  finish: { x: 89, y: 102 }
- !label
  start: *ORIGIN
  color: 0xFFEEBB
  text: Pretty vector drawing.

Could you implement this spec or add some workaround?

@sanyer
Copy link

sanyer commented Mar 28, 2018

Facing the same problem for CloudFormation templates which have tags like !Ref, !GetAtt etc.

@JPinkney
Copy link
Contributor

JPinkney commented Apr 4, 2018

Currently as far as I can tell the underlying parser doesn't support custom tags. I'm not sure if that is something that could be easily added to that parser or if its worth changing parsers.

@riemers
Copy link

riemers commented Apr 4, 2018

Having the same issue db_url: !secret db_url when using secrets variables in home assistant.

@sanyer
Copy link

sanyer commented Apr 4, 2018

@JPinkney right, it has only built-in support for !include tag. Project also seems to be a bit small and lonely.
Can't you use https://github.com/nodeca/js-yaml as underlying parser? It seems to support custom tags. I'm just asking, not an expert in js and don't really now how stuff works in this extension.

@JPinkney
Copy link
Contributor

JPinkney commented Apr 4, 2018

@sanyer I'm going to look into it and compare a few of the options

@sanyer
Copy link

sanyer commented Apr 4, 2018

@JPinkney cool, thanks :-)

@akaRem
Copy link
Author

akaRem commented Apr 4, 2018

I realized that the same problem is with Ansible playbooks. It has custom !vault tag for inlining encrypted secrets.

BTW, there is a plugin for atom https://atom.io/packages/linter-js-yaml where this option is supported.

@gorkem
Copy link
Collaborator

gorkem commented Apr 8, 2018

Does js-yaml provide an AST? Last time I have checked there was only one YAML parser that provided AST. Without an AST we can not provide code assist.

@gorkem
Copy link
Collaborator

gorkem commented Apr 8, 2018

Related to redhat-developer/yaml-language-server#59

@JPinkney
Copy link
Contributor

JPinkney commented Apr 8, 2018

There is a new one that provides an AST that I've been looking into. I haven't done a full evaluation yet but it could potentially help resolve this and #75

@sanyer
Copy link

sanyer commented Apr 10, 2018

@JPinkney awesome, great that there are suitable alternatives

@steve28
Copy link

steve28 commented May 13, 2018

Is this still being considered? I work with YAML which includes custom tags as well and my files show tons of errors that aren't real.

@JPinkney
Copy link
Contributor

It will be added in the release tomorrow.

@JPinkney
Copy link
Contributor

Added in 0.0.12 release.

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

No branches or pull requests

6 participants