Skip to content

Commit

Permalink
Allow user to extend kinds without overriding defaults
Browse files Browse the repository at this point in the history
Instead of overriding all defaults when defining new mappings, the
user defined ones are added at the top, so you do not have redefine
all of them if you only want to tune one.
  • Loading branch information
ssbarnea committed Mar 18, 2021
1 parent 907bdfe commit 796016b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
10 changes: 10 additions & 0 deletions .ansible-lint
Expand Up @@ -59,3 +59,13 @@ extra_vars:
# Uncomment to enforce action validation with tasks, usually is not
# needed as Ansible syntax check also covers it.
# skip_action_validation: false

# List of additional kind:pattern to be added at the top of the default
# match list, first match determines the file kind.
# kinds:
# - playbook: "**/examples/*.{yml,yaml}"
# - galaxy: "**/folder/galaxy.yml"
# - tasks: "**/tasks/*.yml"
# - vars: "**/vars/*.yml"
# - meta: "**/meta/main.yml"
# - yaml: "**/*.YML"
6 changes: 6 additions & 0 deletions src/ansiblelint/cli.py
Expand Up @@ -10,6 +10,7 @@

import yaml

from ansiblelint.config import DEFAULT_KINDS
from ansiblelint.constants import (
CUSTOM_RULESDIR_ENVVAR,
DEFAULT_RULESDIR,
Expand Down Expand Up @@ -358,6 +359,11 @@ def merge_config(file_config: Dict[Any, Any], cli_config: Namespace) -> Namespac
for entry, value in file_config.items():
setattr(cli_config, entry, value)

# append default kinds to the custom list
kinds = getattr(file_config, 'kinds', [])
kinds.extend(DEFAULT_KINDS)
setattr(cli_config, 'kinds', kinds)

return cli_config


Expand Down
2 changes: 1 addition & 1 deletion src/ansiblelint/config.py
Expand Up @@ -67,7 +67,7 @@
tags=[],
verbosity=False,
warn_list=[],
kinds=DEFAULT_KINDS,
kinds=[],
mock_modules=[],
mock_roles=[],
loop_var_prefix=None,
Expand Down

0 comments on commit 796016b

Please sign in to comment.