Skip to content

Improve fileMatch patterns to allow more granular use #422

@ssbarnea

Description

@ssbarnea

Is your enhancement related to a problem? Please describe.

At this moment fileMatch pattern is suffering from several limitations that make it impossible to write patterns that correctly identify Ansible file types.

Describe the solution you would like

To see a full list o patterns that can reliably be used to identify Ansible file types, look at https://github.com/ansible-community/ansible-lint/blob/master/src/ansiblelint/config.py#L14-L33

There are two missing feature that prevent that:

  • * expands as anything instead of current file. foo/*.yml currently also matching foo/bar/*.yml when instead it should not. The correct way to do it would be with foo/**/*.yml or foo/*/*.yml, where the second one requires one sublevel folder but the first one allows none, one or many subfolders feel (aka the recursive one).
  • There is no support for {...}, so a pattern like "**/{host_vars,group_vars,vars,defaults}/**/*.{yaml,yml}"} must be exploded to 8 different patterns in order to work with current fileMatch. You can easily see how we can endup with very long and hard to maintain patterns.

Describe alternatives you have considered

While for the second missing feature we can probable live with the extra inconvenience, there is no solution for the first one. That is directly affecting Ansible because Ansible has a layout where nested patterns are needed and we must be able to control the matching to a single folder depth

Additional context

The given examples of patterns are based on https://facelessuser.github.io/wcmatch/ which is a python matching library but they are not unique to them. At least the globstar (**) is part of the extended glob syntax. Based on https://en.wikipedia.org/wiki/Glob_(programming)#cite_note-bashpat-10 it seems that there are at least two popular JavaScript implementation that should support it: minimatch (npm) and micromatch (babel/yarn).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions