Open jbergstroem opened 6 years ago
I agree it could be cool. But I'd rather have a YAML-formatted config, like for the -d
option.
By the way, did you know you can already use this?
YAMLLINT_CONFIG="{extends: relaxed, rules: {line-length: {max: 81}}}"
yamllint -d "$YAMLLINT_CONFIG" foo.yaml
@adrienverge said: did you know you can already pass config as env?
Didn't. Thanks!
@adrienverge said:
YAMLLINT_CONFIG=..
I considered format as well; suggested something different than YAML in my original comment because I felt a simpler dot notation was closer to your average bash experience. I guess it doesn't scale as well, but the idea was to have the option of changing "just the one thing"; not really passing a full config.
I guess there are two minor opportunities for improvements here. Consider a use case similar to:
# Override while calling this docker instance in your CI pipeline
ENV YAML_ARGS=""
# ...
CMD ["yamllint", "-d '${YAML_ARGS}'"]
..and overriding this from your ci script.
Allowing "empty" configs by assuming they default:
$ docker run --rm -v $(PWD):/yaml sdesbure/yamllint yamllint -d "" .gitlab-ci.yml
invalid config: not a dict
Avoiding -d
by reading a defined environment variable
I guess both can be handled in wrappers but I thought it be worth bringing it up. Feel free to close this issue unless you feel we should make either improvement actionable.
Hey,
Both 1. and 2. make sense! Contributions are welcome (they need to come with tests).
@adrienverge When I have config in file and want just to override one rule, can I do it with existing mechanism somehow ?
@grzesuav you can do this:
YAMLLINT_CONFIG="{extends: /my/config/file.yaml, rules: {line-length: {max: 20}}}"
yamllint -d "$YAMLLINT_CONFIG" foo.yaml
ok, thanks :)
anyway I think overriding specific setting with env variable would be useful in this case. Do you have any preference around the behavior ?
When playing with dockerfiles and multiple repos (main usecase for me is part of CI) it would be nice to be able to override specific config settings via environment; for instance
YAMLLINT_CONFIG="line-length.max=81" yamllint foo.yaml
. This makes it easier to override a few settings without having to check in a config in each repo you're testing against.