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

Validate gossfiles with templates #963

Open
hinricht opened this issue Jul 31, 2024 · 1 comment
Open

Validate gossfiles with templates #963

hinricht opened this issue Jul 31, 2024 · 1 comment

Comments

@hinricht
Copy link

Describe the feature:

The provided schema.yaml is fine for gossfile which don't make use of templates. But when I use templates, my editor (neovim with Goss-file-schema loaded) starts to scream at me becasue it cannot validate the yaml anymore (althogh the gossfile renders fine and tests succeed).

image

I's like to have a way to validate the gossfile that works in the editor but also with tools i.e. check-jsonschema.

$ check-jsonschema -v --schemafile https://raw.githubusercontent.com/goss-org/goss/master/docs/schema.yaml goss.yaml
Several files failed to parse.
  FailedFileLoadError: Failed to parse goss.yaml
    in "/usr/lib/python3.12/site-packages/check_jsonschema/instance_loader.py", line 48
    >>> data: t.Any = self._parsers.parse_data_with_path(

    caused by

    ParserError: while parsing a block mapping
      in "<byte string>", line 3, column 1:
        addr:
        ^ (line: 3)
    expected <block end>, but found '<block mapping start>'
      in "<byte string>", line 14, column 5:
            https://{{.}}:
            ^ (line: 14)
      in "/usr/lib/python3.12/site-packages/check_jsonschema/parsers/__init__.py", line 92
      >>> return loadfunc(data)

Describe the solution you'd like

I don't know how this can be achieved. Maybe I'm just doing it wrong and other editors can deal with this just fine.

Describe alternatives you've considered

None.

@hinricht
Copy link
Author

Hmm, I just found #793 (comment) which is about this:

For templates, unfortunately the goss documents with templates are not valid json/yaml, so the plain json can't do much yet.

#795 should fix this, which is merged, but as I understand it it only handles gossfile validation after beeing rendered, which is no the use case I'm looking for.

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

1 participant