feat: allow to set standards version in config file (#69)

* feat: allow to set standards version in config file

* add documentation
This commit is contained in:
Robert Kaussow 2021-02-01 20:27:00 +01:00 committed by GitHub
parent b1dd83cea6
commit 53444a4a75
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 7 deletions

View File

@ -43,6 +43,13 @@ class Candidate(object):
def _get_version(self):
path = self.path
version = None
config_version = self.config["rules"]["version"].strip()
if config_version:
version_config_re = re.compile(r"([\d.]+)")
match = version_config_re.match(config_version)
if match:
version = match.group(1)
if not self.binary:
if isinstance(self, RoleFile):
@ -54,11 +61,10 @@ class Candidate(object):
break
parentdir = os.path.dirname(parentdir)
version_re = re.compile(r"^# Standards:\s*([\d.]+)")
version_file_re = re.compile(r"^# Standards:\s*([\d.]+)")
with codecs.open(path, mode="rb", encoding="utf-8") as f:
for line in f:
match = version_re.match(line)
match = version_file_re.match(line)
if match:
version = match.group(1)

View File

@ -121,7 +121,8 @@ class Settings(object):
"filter": [],
"exclude_filter": [],
"ignore_dotfiles": True,
"exclude_files": []
"exclude_files": [],
"version": ""
},
"logging": {
"level": "WARNING",

View File

@ -13,6 +13,7 @@ ansible:
# Modules which are bundled with the role and placed in a './library'
# directory will be auto-detected and don't need to be added to this list.
custom_modules: []
# Settings for variable formatting rule (ANSIBLE0004)
double-braces:
max-spaces-inside: 1
@ -24,12 +25,16 @@ ansible:
logging:
# You can enable JSON logging if a parsable output is required
json: False
# Possible options debug | info | warning | error | critical
level: "warning"
# Global settings for all defined rules
rules:
# list of files to exclude
# Disable build-in rules if required
buildin: True
# List of files to exclude
exclude_files: []
# Examples:
# - molecule/
@ -45,8 +50,13 @@ rules:
# All dotfiles (including hidden folders) are excluded by default.
# You can disable this setting and handle dotfiles by yourself with `exclude_files`.
ignore_dotfiles: True
# Path to the folder containing your custom standards file
standards: ansiblelater/data
# List of directories to load standard rules from (defaults to build-in)
standards: []
# Standard version to use. Standard version set in a roles meta file
# or playbook will takes precedence.
version:
# Block to control included yamllint rules.
# See https://yamllint.readthedocs.io/en/stable/rules.html