Merge "Remove RoleNames ansible-lint custom rule"
This commit is contained in:
commit
df9d56f922
|
@ -4,6 +4,19 @@ parseable: true
|
||||||
quiet: false
|
quiet: false
|
||||||
rulesdir:
|
rulesdir:
|
||||||
- .ansible-lint_rules/
|
- .ansible-lint_rules/
|
||||||
|
|
||||||
|
# Mock modules or roles in order to pass ansible-playbook --syntax-check
|
||||||
|
mock_modules: []
|
||||||
|
mock_roles:
|
||||||
|
- fetch-devstack-log-dir
|
||||||
|
- fetch-output
|
||||||
|
- fetch-python-sdist-output
|
||||||
|
- fetch-subunit-output
|
||||||
|
- ensure-if-python
|
||||||
|
- ensure-pip
|
||||||
|
- ensure-tox
|
||||||
|
- ensure-virtualenv
|
||||||
|
|
||||||
skip_list:
|
skip_list:
|
||||||
# Lines should be no longer than 120 chars.
|
# Lines should be no longer than 120 chars.
|
||||||
- '204'
|
- '204'
|
||||||
|
|
|
@ -1,57 +0,0 @@
|
||||||
# Copyright (c) 2020 Gael Chamoulaud <gchamoul@redhat.com>
|
|
||||||
# Copyright (c) 2020 Sorin Sbarnea <ssbarnea@redhat.com>
|
|
||||||
#
|
|
||||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
# of this software and associated documentation files (the "Software"), to deal
|
|
||||||
# in the Software without restriction, including without limitation the rights
|
|
||||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
# copies of the Software, and to permit persons to whom the Software is
|
|
||||||
# furnished to do so, subject to the following conditions:
|
|
||||||
#
|
|
||||||
# The above copyright notice and this permission notice shall be included in
|
|
||||||
# all copies or substantial portions of the Software.
|
|
||||||
#
|
|
||||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
# THE SOFTWARE.
|
|
||||||
|
|
||||||
import re
|
|
||||||
from ansiblelint import AnsibleLintRule
|
|
||||||
ROLE_NAME_REGEX = '^[a-z][a-z0-9_]+$'
|
|
||||||
|
|
||||||
|
|
||||||
class RoleNames(AnsibleLintRule):
|
|
||||||
id = '710'
|
|
||||||
shortdesc = (
|
|
||||||
"Role name {} does not match `%s` pattern" % ROLE_NAME_REGEX
|
|
||||||
)
|
|
||||||
description = (
|
|
||||||
"Role names are now limited to contain only lowercase alphanumeric "
|
|
||||||
"characters, plus '_' and start with an alpha character. See "
|
|
||||||
"`developing collections "
|
|
||||||
"<https://docs.ansible.com/ansible/devel/dev_guide/developing_"
|
|
||||||
"collections.html#roles-directory>`_"
|
|
||||||
)
|
|
||||||
severity = 'HIGH'
|
|
||||||
done = [] # already noticed roles list
|
|
||||||
tags = ['metadata']
|
|
||||||
version_added = 'v4.3.0'
|
|
||||||
|
|
||||||
ROLE_NAME_REGEXP = re.compile(ROLE_NAME_REGEX)
|
|
||||||
|
|
||||||
def match(self, file, text):
|
|
||||||
|
|
||||||
path = file['path'].split("/")
|
|
||||||
if "roles" in path:
|
|
||||||
role_name = path[path.index("roles") + 1]
|
|
||||||
if role_name not in self.done:
|
|
||||||
self.done.append(role_name)
|
|
||||||
if not re.match(self.ROLE_NAME_REGEXP, role_name):
|
|
||||||
return self.shortdesc.format(role_name)
|
|
||||||
else:
|
|
||||||
return False
|
|
||||||
return False
|
|
|
@ -23,12 +23,14 @@ repos:
|
||||||
files: \.(yaml|yml)$
|
files: \.(yaml|yml)$
|
||||||
types: [file, yaml]
|
types: [file, yaml]
|
||||||
entry: yamllint --strict -f parsable
|
entry: yamllint --strict -f parsable
|
||||||
- repo: https://github.com/ansible/ansible-lint.git
|
- repo: https://github.com/ansible-community/ansible-lint
|
||||||
rev: v4.2.0
|
rev: v5.0.3
|
||||||
hooks:
|
hooks:
|
||||||
- id: ansible-lint
|
- id: ansible-lint
|
||||||
always_run: true
|
always_run: true
|
||||||
pass_filenames: false
|
pass_filenames: false
|
||||||
|
additional_dependencies:
|
||||||
|
- 'ansible<2.10'
|
||||||
verbose: true
|
verbose: true
|
||||||
entry: ansible-lint --force-color -p -v
|
entry: ansible-lint --force-color -p -v
|
||||||
- repo: https://github.com/openstack-dev/bashate.git
|
- repo: https://github.com/openstack-dev/bashate.git
|
||||||
|
|
|
@ -1,15 +0,0 @@
|
||||||
---
|
|
||||||
# Copyright 2019 Red Hat, Inc.
|
|
||||||
# All Rights Reserved.
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
# not use this file except in compliance with the License. You may obtain
|
|
||||||
# a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
|
@ -1,15 +0,0 @@
|
||||||
---
|
|
||||||
# Copyright 2019 Red Hat, Inc.
|
|
||||||
# All Rights Reserved.
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
# not use this file except in compliance with the License. You may obtain
|
|
||||||
# a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
Loading…
Reference in New Issue